Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 23f2c73

Browse files
committedSep 8, 2024·
silent ALSA PCM.try_recover
1 parent cc8ba75 commit 23f2c73

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed
 

‎CHANGELOG.md

+2
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.15.3 (2024-03-04)
46

57
- Add `try_with_sample_rate`, a non-panicking variant of `with_sample_rate`.

‎Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cpal"
3-
version = "0.15.3"
3+
version = "0.15.4"
44
description = "Low-level cross-platform audio I/O library in pure Rust."
55
repository = "https://github.com/rustaudio/cpal"
66
documentation = "https://docs.rs/cpal"

‎src/host/alsa/mod.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -834,9 +834,15 @@ fn process_output(
834834
loop {
835835
match stream.channel.io_bytes().writei(buffer) {
836836
Err(err) if err.errno() == libc::EPIPE => {
837-
// buffer underrun
838-
// TODO: Notify the user of this.
839-
let _ = stream.channel.try_recover(err, false);
837+
// ALSA underrun or overrun.
838+
// See https://github.com/alsa-project/alsa-lib/blob/b154d9145f0e17b9650e4584ddfdf14580b4e0d7/src/pcm/pcm.c#L8767-L8770
839+
// Even if these recover successfully, they still may cause audible glitches.
840+
841+
// TODO:
842+
// Should we notify the user about successfully recovered errors?
843+
// Should we notify the user about failures in try_recover, rather than ignoring them?
844+
// (Both potentially not real-time-safe)
845+
_ = stream.channel.try_recover(err, true);
840846
}
841847
Err(err) => {
842848
error_callback(err.into());

0 commit comments

Comments
 (0)
Please sign in to comment.