👕 refactor
parent
554bcb41cb
commit
cd0a0883c8
21
src/main.rs
21
src/main.rs
|
@ -199,9 +199,9 @@ struct Controller
|
|||
gui_rgba_gen: Instant,
|
||||
gui_needs_frame: bool,
|
||||
|
||||
capture: task::Task <(), ()>,
|
||||
capture_is_running: bool,
|
||||
|
||||
jpeg_decoder: task::Task <(), Instant>,
|
||||
jpeg_decoder_is_running: bool,
|
||||
jpeg_needs_frame: bool,
|
||||
|
||||
rgba_frame: (Vec <u8>, Instant),
|
||||
|
@ -217,9 +217,8 @@ impl Controller
|
|||
gui_needs_frame: false,
|
||||
gui_rgba_gen: now,
|
||||
|
||||
capture: ().into (),
|
||||
|
||||
jpeg_decoder: ().into (),
|
||||
capture_is_running: false,
|
||||
jpeg_decoder_is_running: false,
|
||||
jpeg_needs_frame: false,
|
||||
|
||||
rgba_frame: (Default::default (), now),
|
||||
|
@ -233,13 +232,13 @@ impl Controller
|
|||
|
||||
fn handle_rgba_frame (&mut self, data: Vec <u8>, gen: Instant)
|
||||
{
|
||||
self.jpeg_decoder.stop (()).unwrap ();
|
||||
self.jpeg_decoder_is_running = false;
|
||||
self.rgba_frame = (data, gen);
|
||||
}
|
||||
|
||||
fn handle_capture (&mut self, jpeg: JpegFrame)
|
||||
{
|
||||
self.capture.stop (()).unwrap ();
|
||||
self.capture_is_running = false;
|
||||
self.jpeg_frame = jpeg;
|
||||
}
|
||||
|
||||
|
@ -257,15 +256,15 @@ impl Controller
|
|||
|
||||
Some (MsgFromController::RepaintGui (self.rgba_frame.clone ()))
|
||||
}
|
||||
else if self.gui_needs_frame && ! self.jpeg_decoder.is_running () && self.jpeg_frame.time > self.rgba_frame.1
|
||||
else if self.gui_needs_frame && ! self.jpeg_decoder_is_running && self.jpeg_frame.time > self.rgba_frame.1
|
||||
{
|
||||
self.jpeg_decoder.start (self.jpeg_frame.time).unwrap ();
|
||||
self.jpeg_decoder_is_running = true;
|
||||
self.jpeg_needs_frame = false;
|
||||
Some (MsgFromController::StartJpegDecoder (self.jpeg_frame.clone ()))
|
||||
}
|
||||
else if self.jpeg_needs_frame && ! self.capture.is_running ()
|
||||
else if self.jpeg_needs_frame && ! self.capture_is_running
|
||||
{
|
||||
self.capture.start (()).unwrap ();
|
||||
self.capture_is_running = true;
|
||||
Some (MsgFromController::StartCapture)
|
||||
}
|
||||
else if self.gui_needs_frame && self.jpeg_frame.time == self.rgba_frame.1
|
||||
|
|
Loading…
Reference in New Issue