diff --git a/crates/engine/src/playback.rs b/crates/engine/src/playback.rs index 1cb53c5..17878bd 100644 --- a/crates/engine/src/playback.rs +++ b/crates/engine/src/playback.rs @@ -40,6 +40,10 @@ struct Audio { fed: Arc, /// The decoder ran out and `fed` is final. fed_all: Arc, + /// The output plugin failed mid-stream. Its position is frozen from here on, + /// so it can never satisfy [`Audio::played_out`] -- the flag is what lets + /// [`PlaybackSession::tick`] hand the timeline to wall time instead. + died: Arc, } impl Audio { @@ -137,6 +141,13 @@ impl PlaybackSession { if self.clock.source() != ClockSource::Audio { return; } + if audio.died.load(Ordering::Acquire) { + // Output died mid-stream: its position will never reach `fed`, so + // the EOF comparison below is unreachable. Wall time takes over + // from wherever the clock last stood. + self.clock.switch_to_wall(); + return; + } // `None` until the device's first callback: the clock holds at its // anchor rather than guessing, which is why playback starts on time // instead of a quantum early. @@ -176,16 +187,18 @@ fn open_audio(path: &Path) -> Option