fix delay after first unpause of stream
This commit is contained in:
parent
c579cc0851
commit
67c8883254
1 changed files with 5 additions and 6 deletions
|
@ -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() {
|
||||
RetainedImage::from_image_bytes("last packet", &mk_qr_bytes(&bytes, height)).unwrap()
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
// 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 {
|
||||
let bytes = sc.rx.recv().unwrap();
|
||||
sc.last_packet = Some(bytes.clone());
|
||||
|
|
Loading…
Reference in a new issue