fix delay after first unpause of stream

This commit is contained in:
Joe Ardent 2023-08-08 11:48:41 -07:00
parent c579cc0851
commit 67c8883254

View file

@ -80,12 +80,11 @@ fn paused(sc: &mut StreamedContent, ui: &mut Ui, height: f32, tsize: f32) {
fn streaming(sc: &mut StreamedContent, ui: &mut Ui, height: f32, tsize: f32, sleep: Duration) { fn streaming(sc: &mut StreamedContent, ui: &mut Ui, height: f32, tsize: f32, sleep: Duration) {
let dur = Instant::now() - sc.last_packet_time; let dur = Instant::now() - sc.last_packet_time;
let img = if dur < sleep { // don't grab a new packet unless enough time has passed or we've never seen a
if let Some(bytes) = sc.last_packet.clone() { // packet before
RetainedImage::from_image_bytes("last packet", &mk_qr_bytes(&bytes, height)).unwrap() let img = if dur < sleep && sc.last_packet.is_some() {
} else { let bytes = sc.last_packet.clone().unwrap();
return; RetainedImage::from_image_bytes("last packet", &mk_qr_bytes(&bytes, height)).unwrap()
}
} else { } else {
let bytes = sc.rx.recv().unwrap(); let bytes = sc.rx.recv().unwrap();
sc.last_packet = Some(bytes.clone()); sc.last_packet = Some(bytes.clone());