Skip to content

CPAL not finding devices (ALSA, Linux, Raspberry Pi) / CPAL does not support devices that only does recording? #515

@JonasRSV

Description

@JonasRSV

CPAL on raspberry pi does not find or pick any usable devices.

Printing all input devices

    for device in cpal::default_host().input_devices().unwrap() {
        println!("Found {}", device.name().unwrap());
    }

Gives

ALSA lib pcm_dmix.c:1043:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dmix.c:1043:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dsnoop.c:575:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave

The output of arecord -L gives

null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=Camera
    USB2.0 Camera, USB Audio
    Default Audio Device
sysdefault:CARD=Camera
    USB2.0 Camera, USB Audio
    Default Audio Device
front:CARD=Camera,DEV=0
    USB2.0 Camera, USB Audio
    Front speakers
surround21:CARD=Camera,DEV=0
    USB2.0 Camera, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Camera,DEV=0
    USB2.0 Camera, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Camera,DEV=0
    USB2.0 Camera, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Camera,DEV=0
    USB2.0 Camera, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Camera,DEV=0
    USB2.0 Camera, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Camera,DEV=0
    USB2.0 Camera, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Camera,DEV=0
    USB2.0 Camera, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Camera,DEV=0
    USB2.0 Camera, USB Audio
    Direct sample mixing device
dsnoop:CARD=Camera,DEV=0
    USB2.0 Camera, USB Audio
    Direct sample snooping device
hw:CARD=Camera,DEV=0
    USB2.0 Camera, USB Audio
    Direct hardware device without any conversions
plughw:CARD=Camera,DEV=0
    USB2.0 Camera, USB Audio
    Hardware device with all software conversions

I have used alsa directly on the same raspberry pi and it works, what could be the reason why cpal does not find devices using alsa? :/

E.g this code

https://gist.github.com/albanpeignier/104902 can record fine with for example

gcc -o alsa-record-example -lasound simple_alsa.c && ./alsa-record-example default:CARD=Camera

audio interface opened
hw_params allocated
hw_params initialized
hw_params access setted
hw_params format setted
hw_params rate setted
hw_params channels setted
hw_params setted
hw_params freed
audio interface prepared
buffer allocated
read 0 done
read 1 done
read 2 done
read 3 done
read 4 done
read 5 done
read 6 done
read 7 done
read 8 done
read 9 done
buffer freed
audio interface closed

If I try to record with CPAL I get

A backend-specific error has occurred: ALSA function 'snd_pcm_open' failed with error 'ENOENT: No such file or directory'

If i print what device CPAL picks it says

Using device default

But that is curious since it found no device? :)

What would be next steps to get this to work with CPAL?

I am using CPAL for https://github.com/JonasRSV/Friday here is the specific code if it is relevant: https://github.com/JonasRSV/Friday/blob/main/friday/audio-io/src/lib.rs#L55 :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions