Skip to content

Commit

Permalink
Swap the order of streaming loop operation and state modification ope…
Browse files Browse the repository at this point in the history
…ration
  • Loading branch information
Y-Nak committed Mar 13, 2023
1 parent d7caba6 commit 93250a9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions cameleon/src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,16 @@ impl<Ctrl, Strm, Ctxt> Camera<Ctrl, Strm, Ctxt> {
return Err(StreamError::InStreaming.into());
}

// Start streaming loop.
let (sender, receiver) = channel(cap, DEFAULT_BUFFER_CAP);
self.strm.start_streaming_loop(sender, &mut self.ctrl)?;

// Enable streaimng.
self.ctrl.enable_streaming()?;
let mut ctxt = self.params_ctxt()?;
expect_node!(&ctxt, "TLParamsLocked", as_integer).set_value(&mut ctxt, 1)?;
expect_node!(&ctxt, "AcquisitionStart", as_command).execute(&mut ctxt)?;

// Start streaming loop.
let (sender, receiver) = channel(cap, DEFAULT_BUFFER_CAP);
self.strm.start_streaming_loop(sender, &mut self.ctrl)?;

info!("start streaming successfully");
Ok(receiver)
}
Expand Down Expand Up @@ -358,14 +358,13 @@ impl<Ctrl, Strm, Ctxt> Camera<Ctrl, Strm, Ctxt> {
return Ok(());
}

// Stop streaming loop.
self.strm.stop_streaming_loop()?;

// Disable streaming.
let mut ctxt = self.params_ctxt()?;
expect_node!(&ctxt, "AcquisitionStop", as_command).execute(&mut ctxt)?;
expect_node!(&ctxt, "TLParamsLocked", as_integer).set_value(&mut ctxt, 0)?;
self.ctrl.disable_streaming()?;
// Stop streaming loop.
self.strm.stop_streaming_loop()?;

info!("stop streaming successfully");
Ok(())
Expand Down

0 comments on commit 93250a9

Please sign in to comment.