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) {
let dur = Instant::now() - sc.last_packet_time;
let img = if dur < sleep {
if let Some(bytes) = sc.last_packet.clone() {
// don't grab a new packet unless enough time has passed or we've never seen a
// packet before
let img = if dur < sleep && sc.last_packet.is_some() {
let bytes = sc.last_packet.clone().unwrap();
RetainedImage::from_image_bytes("last packet", &mk_qr_bytes(&bytes, height)).unwrap()
} else {
return;
}
} else {
let bytes = sc.rx.recv().unwrap();
sc.last_packet = Some(bytes.clone());