From cd0a0883c80155ee8b8c4062562080d73695cfa7 Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Tue, 12 Sep 2023 21:41:39 -0500 Subject: [PATCH] :shirt: refactor --- src/main.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1efb7c8..6369296 100644 --- a/src/main.rs +++ b/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 , 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 , 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