👕 refactor

main
_ 2023-09-12 21:41:39 -05:00
parent 554bcb41cb
commit cd0a0883c8
1 changed files with 10 additions and 11 deletions

View File

@ -199,9 +199,9 @@ struct Controller
gui_rgba_gen: Instant, gui_rgba_gen: Instant,
gui_needs_frame: bool, 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, jpeg_needs_frame: bool,
rgba_frame: (Vec <u8>, Instant), rgba_frame: (Vec <u8>, Instant),
@ -217,9 +217,8 @@ impl Controller
gui_needs_frame: false, gui_needs_frame: false,
gui_rgba_gen: now, gui_rgba_gen: now,
capture: ().into (), capture_is_running: false,
jpeg_decoder_is_running: false,
jpeg_decoder: ().into (),
jpeg_needs_frame: false, jpeg_needs_frame: false,
rgba_frame: (Default::default (), now), rgba_frame: (Default::default (), now),
@ -233,13 +232,13 @@ impl Controller
fn handle_rgba_frame (&mut self, data: Vec <u8>, gen: Instant) 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); self.rgba_frame = (data, gen);
} }
fn handle_capture (&mut self, jpeg: JpegFrame) fn handle_capture (&mut self, jpeg: JpegFrame)
{ {
self.capture.stop (()).unwrap (); self.capture_is_running = false;
self.jpeg_frame = jpeg; self.jpeg_frame = jpeg;
} }
@ -257,15 +256,15 @@ impl Controller
Some (MsgFromController::RepaintGui (self.rgba_frame.clone ())) 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; self.jpeg_needs_frame = false;
Some (MsgFromController::StartJpegDecoder (self.jpeg_frame.clone ())) 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) Some (MsgFromController::StartCapture)
} }
else if self.gui_needs_frame && self.jpeg_frame.time == self.rgba_frame.1 else if self.gui_needs_frame && self.jpeg_frame.time == self.rgba_frame.1