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 8, 2024
1 parent cc8ba75 commit 23f2c73
Showing 3 changed files with 12 additions and 4 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`.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cpal"
version = "0.15.3"
version = "0.15.4"
description = "Low-level cross-platform audio I/O library in pure Rust."
repository = "https://github.com/rustaudio/cpal"
documentation = "https://docs.rs/cpal"
12 changes: 9 additions & 3 deletions src/host/alsa/mod.rs
Original file line number Diff line number Diff line change
@@ -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());

0 comments on commit 23f2c73

Please sign in to comment.