drm: switch for a new subscriber once the encoder has run

Nothing is sent in the WouldBlock arm, so the switch is needed only
when the encoder already produced frames, even if the subscribers
that got them are gone: otherwise the new one gets no keyframe until
the screen changes. A fresh encoder needs no switch. Log the expected
event at trace level.
This commit is contained in:
Mariano Abad committed 2026-11-05 22:52:42 -03:00
1 parent de139dc972
commit ea73ed51ff
1 file changed
+7 -5
+7 -5
View File
@@ -900,12 +900,14 @@ fn run(vs: VideoService) -> ResultType<()> {
match res {
Err(ref e) if e.kind() == WouldBlock => {
// A still screen may never reach handle_one_frame, which is where a subscriber
// added without a refresh (mobile display switch) is otherwise noticed. Nothing
// is sent here, so switch even when the old subscribers are gone.
// Nothing is sent here: a subscriber added without a refresh needs the switch once
// the encoder has run, even if its old subscribers left; a fresh encoder needs none.
sp.snapshot(|_| {
log::trace!("switch due to new subscriber");
bail!("SWITCH");
if !first_frame {
log::trace!("switch due to new subscriber");
bail!("SWITCH");
}
Ok(())
})?;
#[cfg(windows)]
if dxgi_recovery_started