From 72e930a374c59c96f84ae2c6a1fc6019f3cf39ba Mon Sep 17 00:00:00 2001 From: taro Date: Sun, 8 Sep 2024 12:50:29 -0300 Subject: [PATCH] silent ALSA PCM.try_recover --- CHANGELOG.md | 2 ++ src/host/alsa/mod.rs | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d82ce0460..ed2445d7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased +- ALSA(process_output): pass `silent=true` to `PCM.try_recover`, so it doesn't write to stderr + # Version 0.15.3 (2024-03-04) - Add `try_with_sample_rate`, a non-panicking variant of `with_sample_rate`. diff --git a/src/host/alsa/mod.rs b/src/host/alsa/mod.rs index 2085c20b7..aee2560d9 100644 --- a/src/host/alsa/mod.rs +++ b/src/host/alsa/mod.rs @@ -834,9 +834,15 @@ fn process_output( loop { match stream.channel.io_bytes().writei(buffer) { Err(err) if err.errno() == libc::EPIPE => { - // buffer underrun - // TODO: Notify the user of this. - let _ = stream.channel.try_recover(err, false); + // ALSA underrun or overrun. + // See https://github.com/alsa-project/alsa-lib/blob/b154d9145f0e17b9650e4584ddfdf14580b4e0d7/src/pcm/pcm.c#L8767-L8770 + // Even if these recover successfully, they still may cause audible glitches. + + // TODO: + // Should we notify the user about successfully recovered errors? + // Should we notify the user about failures in try_recover, rather than ignoring them? + // (Both potentially not real-time-safe) + _ = stream.channel.try_recover(err, true); } Err(err) => { error_callback(err.into());