Skip to content

Commit 8412683

Browse files
silent ALSA PCM.try_recover (#909)
1 parent 8a1dbd2 commit 8412683

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Unreleased
22

3+
- ALSA(process_output): pass `silent=true` to `PCM.try_recover`, so it doesn't write to stderr
4+
35
# Version 0.16.0 (2025-06-07)
46

57
- Migrate from `oboe` to `ndk::audio`. **NOTE:** This raises the minimum Android API version to 26 (Android 8/Oreo).

src/host/alsa/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,15 @@ fn process_output(
870870
loop {
871871
match stream.channel.io_bytes().writei(buffer) {
872872
Err(err) if err.errno() == libc::EPIPE => {
873-
// buffer underrun
874-
// TODO: Notify the user of this.
875-
let _ = stream.channel.try_recover(err, false);
873+
// ALSA underrun or overrun.
874+
// See https://github.com/alsa-project/alsa-lib/blob/b154d9145f0e17b9650e4584ddfdf14580b4e0d7/src/pcm/pcm.c#L8767-L8770
875+
// Even if these recover successfully, they still may cause audible glitches.
876+
877+
// TODO:
878+
// Should we notify the user about successfully recovered errors?
879+
// Should we notify the user about failures in try_recover, rather than ignoring them?
880+
// (Both potentially not real-time-safe)
881+
_ = stream.channel.try_recover(err, true);
876882
}
877883
Err(err) => {
878884
error_callback(err.into());

0 commit comments

Comments
 (0)