bondagit / ravenna-alsa-lkm

RAVENNA ALSA LKM
20 stars 9 forks source link

Error 77 retrieving hardware parameters through ALSA C/Rust API #23

Closed JulienH2000 closed 1 month ago

JulienH2000 commented 2 months ago

Hello, I'm having trouble with the Ravenna driver and the ALSA API. Using Alsa-rs rust bindings of the Alsa C library, once instancing the ravenna driver as a new alsa::PCM device, it fails to retrieve the device parameters (using snd_pcm_hw_params_current C function binding). Here's the Cargo error returned : called Result::unwrap() on an Err value: ALSA function 'snd_pcm_hw_params_current' failed with error 'Unknown errno (77)' note: run with RUST_BACKTRACE=1 environment variable to display a backtrace.

And here's a snippet of the code :

pub fn new_ip (label: String) -> Self {
    let new_pcm = alsa::PCM::new("hw:CARD=RAVENNA,DEV=0", Direction::Capture, false).unwrap();
    let hwp = new_pcm.hw_params_current().unwrap();
    //let hwp = HwParams::any(&new_pcm).unwrap();
    println!("HwP : {:?}\n", hwp);
    let leg_width = hwp.get_channels().unwrap();
    let format = hwp.get_format().unwrap();
    let buffer_size = hwp.get_buffer_size().unwrap();
    let _ = new_pcm.drop();

    return pcm_device {
        label: label,
        direction: Direction::Capture,
        alsa_pcm: alsa::PCM::new("hw:CARD=RAVENNA,DEV=0", Direction::Capture, false).unwrap(),
        leg_width: leg_width,
        format: format,
        buffer_size: buffer_size,
    }
}  

Note that the same error occurs in both capture and playback. Thanks