Skip to content

Commit 72489df

Browse files
committed
Swap the order of streaming loop operation and state modification operation
1 parent d7caba6 commit 72489df

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

cameleon/src/camera.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,20 @@ impl<Ctrl, Strm, Ctxt> Camera<Ctrl, Strm, Ctxt> {
303303
return Err(StreamError::InStreaming.into());
304304
}
305305

306-
// Enable streaimng.
306+
// Lock TLParams to prevent changing parameters while streaming.
307+
// Some camera models require this to obtain parameters for streaming.
307308
self.ctrl.enable_streaming()?;
308309
let mut ctxt = self.params_ctxt()?;
309310
expect_node!(&ctxt, "TLParamsLocked", as_integer).set_value(&mut ctxt, 1)?;
310-
expect_node!(&ctxt, "AcquisitionStart", as_command).execute(&mut ctxt)?;
311311

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

316+
// Enable streaming.
317+
let mut ctxt = self.params_ctxt()?;
318+
expect_node!(&ctxt, "AcquisitionStart", as_command).execute(&mut ctxt)?;
319+
316320
info!("start streaming successfully");
317321
Ok(receiver)
318322
}
@@ -358,14 +362,13 @@ impl<Ctrl, Strm, Ctxt> Camera<Ctrl, Strm, Ctxt> {
358362
return Ok(());
359363
}
360364

361-
// Stop streaming loop.
362-
self.strm.stop_streaming_loop()?;
363-
364365
// Disable streaming.
365366
let mut ctxt = self.params_ctxt()?;
366367
expect_node!(&ctxt, "AcquisitionStop", as_command).execute(&mut ctxt)?;
367368
expect_node!(&ctxt, "TLParamsLocked", as_integer).set_value(&mut ctxt, 0)?;
368369
self.ctrl.disable_streaming()?;
370+
// Stop streaming loop.
371+
self.strm.stop_streaming_loop()?;
369372

370373
info!("stop streaming successfully");
371374
Ok(())

0 commit comments

Comments
 (0)