Using snd_device_name_hint() with iface "card"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



alsa-project/alsa-lib issue #277 was edited from MathisMARION:

Hello,

I have been experimenting with the `alsa` library, and I tried to use the `snd_device_name_hint()` function to print information about devices. It doesn't seem documented [here](https://www.alsa-project.org/alsa-doc/alsa-lib/group___control.html) so I looked up for examples online, and explored the source code as well.

Looking at the [source code](https://github.com/alsa-project/alsa-lib/blob/master/src/control/namehint.c#L582), it seems like the function should be able to take `"card"` as a valid interface. However when I run this function, it returns `ENOENT`. I ran my program with `gdb` and found that [this call](https://github.com/alsa-project/alsa-lib/blob/master/src/control/namehint.c#L639) to `add_card()` was returning the error. `add_card` calls `snd_config_search` which loops through a list to find a match. In my case I found out that the list contained `"cards"` (with an `s`), while the code was searching for `"card"` so I am left wondering if this was done on purpose. Moreover I can get info about my sound cards using `/proc/asound/cards` (with an `s` again) so it makes me doubt even more...

I am running Ubuntu 20.04.5, and have installed `libasound2-dev` version `1.2.2-2.1ubuntu2.5`. I can give more info about my setup if needed, I am just unsure what other info would help as of right now.

Here's a simple program reproducing my issue:
```c
#include <alsa/asoundlib.h>
#include <stdio.h>

int main()
{
    void **hints;
    int ret;

    ret = snd_device_name_hint(-1, "card", &hints);
    if (ret) {
        printf("snd_device_name_hint: %s\n", snd_strerror(ret));
        return EXIT_FAILURE;
    }
    snd_device_name_free_hint(hints);
    return EXIT_SUCCESS;
}
```
```
snd_device_name_hint: No such file or directory
```
Putting `"cards"` instead results in `EINVAL`:
```
snd_device_name_hint: Invalid argument
```

Issue URL     : https://github.com/alsa-project/alsa-lib/issues/277
Repository URL: https://github.com/alsa-project/alsa-lib



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux