diff --git a/apps/neshub/src/dgram.rs b/apps/neshub/src/dgram.rs index 7d401279..02bb0f9b 100644 --- a/apps/neshub/src/dgram.rs +++ b/apps/neshub/src/dgram.rs @@ -318,6 +318,13 @@ pub async fn run_datagram_writer( MediaItem::Resubscribe => { seq = 0; resync = ResyncGate::default(); + // Set here, in queue order, not only by whoever queued this: a + // keyframe from the old picture still queued ahead of it would + // otherwise clear the flag, and the new picture's first delta + // would go out as the first frame after the switch. + if let Some(ref awaiting) = awaiting_keyframe { + awaiting.store(true, Ordering::Relaxed); + } continue; } // No keyframe stream and no resync gate: every PyroWave frame diff --git a/apps/neshub/src/session.rs b/apps/neshub/src/session.rs index f8d2aac8..c615548d 100644 --- a/apps/neshub/src/session.rs +++ b/apps/neshub/src/session.rs @@ -513,10 +513,10 @@ impl ClientSession { /// zero, hold deltas until a keyframe, and forget what it reported about /// the old one. The caller asks for the keyframe. pub fn restart_picture(&self) { + self.awaiting_keyframe.store(true, Ordering::Relaxed); if self.pending_video.is_none() { let _ = self.send_video.send(MediaItem::Resubscribe); } - self.awaiting_keyframe.store(true, Ordering::Relaxed); let _ = self.take_report(); }