Skip to content

Commit

Permalink
Update Alsa crate to 0.9.0
Browse files Browse the repository at this point in the history
I updated my Raspberry Pi (but not the Kernel, since that one still has
the breaking change that breaks changing params), but without any
configuration changes, I now run into this crash:

    ALSA lib confmisc.c:1377:(snd_func_refer) Unable to find definition 'cards.2.pcm.front.0:CARD=2'
    ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5727:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2721:(snd_pcm_open_noupdate) Unknown PCM front:2
    thread 'playback' panicked at 'TODO: Failed to open device.: Error("snd_pcm_open", ENOENT)', src/playback.rs:358:50

The device is present, and I didn't change the configuration, so I
assume Alsa or the Kernel had a breaking change. But before I downgrade
again, maybe updating the Alsa crate fixes things? I don't have very
high hopes, but let's try. Also, this is one of the very few updates
that _removes_ dependencies, so that's a welcome change too.
  • Loading branch information
ruuda committed Apr 3, 2024
1 parent 06555e1 commit a4d8024
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 29 deletions.
31 changes: 4 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Ruud van Asseldonk <[email protected]>"]
edition = "2018"

[dependencies]
alsa = "0.6.0"
alsa = "0.9.0"
bs1770 = "1.0.0"
chrono = "0.4.13"
crossbeam = "0.3"
Expand Down
4 changes: 3 additions & 1 deletion src/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use crate::history::PlaybackEvent;
use crate::player::{Format, Millibel, PlayerState};
use crate::prim::Hertz;

const EBUSY: i32 = 16;

type Result<T> = result::Result<T, alsa::Error>;

fn print_available_cards() -> Result<()> {
Expand Down Expand Up @@ -90,7 +92,7 @@ fn open_device(card_name: &str) -> Result<(alsa::PCM, alsa::Mixer)> {
let non_block = false;
let pcm = match alsa::PCM::new(&device, alsa::Direction::Playback, non_block) {
Ok(pcm) => pcm,
Err(error) if error.errno() == alsa::nix::errno::Errno::EBUSY => {
Err(error) if error.errno() == EBUSY => {
println!("Could not open audio interface for exclusive access, it is already use.");
return Err(error);
}
Expand Down

0 comments on commit a4d8024

Please sign in to comment.