Skip to content

Ctl::pcm_info expected errors #145

@quaternic

Description

@quaternic

If the device exists but has no subdevices for the selected stream direction, Ctl::pcm_info returns an error, specifically libc::ENOENT. I couldn't find documentation for this, but the underlying syscall traces back to https://github.com/torvalds/linux/blob/72761a7e31225971d0b29d9195e0ffa986b77867/sound/core/pcm.c#L124-L133

In the example pcm_enumerate, function list_devices_for_card immediately returns that error to the caller, so any further devices get silently ignored. The example can be fixed by doing something like

let pcm_info = match ctl.pcm_info(device as u32, 0, direction) {
    Ok(info) => info,
    Err(e) if e.errno() == libc::ENOENT => continue,
    err => return err,
};

It's not very obvious that you have to do that, especially when the error prints as "No such file or directory".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions