Thanks for your code. Perhaps I should have clarified. I want to know how I should parse information from udev for ALSA:
| struct udev *udev_obj = udev_new();
struct udev_enumerate *udev_enum = udev_enumerate_new(udev_obj);
udev_enumerate_add_match_subsystem(udev_enum, "sound");
udev_enumerate_scan_devices(udev_enum);
struct udev_list_entry *udev_entries = udev_enumerate_get_list_entry(udev_enum);
struct udev_list_entry *udev_entry = NULL;
udev_list_entry_foreach(udev_entry, udev_entries) {
printf("%s\n", udev_list_entry_get_name(udev_entry));
}
|
On my ThinkPad X1 Carbon with no external sound peripherals, this outputs:
1
2
3
4
5
6
7
8
9
10
11
12
13 | /sys/devices/pci0000:00/0000:00:1f.3/sound/card0
/sys/devices/pci0000:00/0000:00:1f.3/sound/card0/hwC0D0
/sys/devices/pci0000:00/0000:00:1f.3/sound/card0/hwC0D2
/sys/devices/pci0000:00/0000:00:1f.3/sound/card0/pcmC0D0c
/sys/devices/pci0000:00/0000:00:1f.3/sound/card0/pcmC0D0p
/sys/devices/pci0000:00/0000:00:1f.3/sound/card0/pcmC0D10p
/sys/devices/pci0000:00/0000:00:1f.3/sound/card0/pcmC0D3p
/sys/devices/pci0000:00/0000:00:1f.3/sound/card0/pcmC0D7p
/sys/devices/pci0000:00/0000:00:1f.3/sound/card0/pcmC0D8p
/sys/devices/pci0000:00/0000:00:1f.3/sound/card0/pcmC0D9p
/sys/devices/pci0000:00/0000:00:1f.3/sound/card0/controlC0
/sys/devices/virtual/sound/seq
/sys/devices/virtual/sound/timer
|
I understand that C0 = card 0, D0 = device 0, and c = capture/p = playback. However:
1. What is the difference between
card0/hw/pcm/control/seq/timer?
2. Why is there so many odd combinations, e.g card 0, device 3 and then card 0, device 7, etc. It does not seem to logically increment by one
3. Should I just parse these strings to get the arguments for
snd_pcm_open? This is definitely doable however feels clunky. E.g, with input devices you can:
| device = udev_device_get_parent_with_subsystem_devtype(device ,"input", NULL);
char const *mask = udev_device_get_sysattr_value(device, "capabilities/ev");
// Perform bit-wise operations on strl(mask) to get information about the input device
|
However, the contents of
/dev/snd/pcmC0D0p for example contain no informative files, so I don't think this method will work.