Skip to content

Commit

Permalink
silent ALSA PCM.try_recover
Browse files Browse the repository at this point in the history
  • Loading branch information
lautarodragan committed Sep 9, 2024
1 parent cc8ba75 commit 72e930a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
12 changes: 9 additions & 3 deletions src/host/alsa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 72e930a

Please sign in to comment.