mirror of
https://github.com/nestriness/nestri.git
synced 2026-11-03 14:12:39 +02:00
fix(neshub): a picture switch waits for the new keyframe even behind a stalled writer (#425)
Follow-up to #423 from its re-review. The dgram writer now raises awaiting_keyframe when it reaches the Resubscribe marker, in queue order, and restart_picture sets the flag before queuing the marker. Before this, an old keyframe still queued ahead of a primary switch could clear the flag, letting the new picture's first delta out as the first frame an old client saw after the switch. Needs a writer stalled for at least 1 s to trigger. Tested: cargo test -p neshub on nestripc-1, 78 passed.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user