Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: drop undelivered mixed audio at the stop deadline instead of failing

Richie McIlroy3e2e21285170
diff --git a/crates/recording/src/sources/audio_mixer.rs b/crates/recording/src/sources/audio_mixer.rs
index e22c8d5a1..e6d0669ba 100644
--- a/crates/recording/src/sources/audio_mixer.rs
+++ b/crates/recording/src/sources/audio_mixer.rs
@@ -823,11 +823,17 @@ impl AudioMixer {
match self.output.try_send(frame) {
Ok(()) => break,
Err(err) if err.is_full() => {
- anyhow::ensure!(
- self.drain_deadline
- .is_none_or(|deadline| Instant::now() < deadline),
- "Audio mixer output did not drain before the stop deadline"
- );
+ // At stop, a consumer that stopped draining costs the
+ // audio not yet delivered, never the recording.
+ if self
+ .drain_deadline
+ .is_some_and(|deadline| Instant::now() >= deadline)
+ {
+ warn!(
+ "Audio mixer output did not drain before the stop deadline; dropping the rest"
+ );
+ return Ok(false);
+ }
frame = err.into_inner();
std::thread::sleep(Duration::from_millis(1));
}