I am new to alsa, pulseAudio, needed help with this issue.
This is the truncated output of pacmd command on my system pacmd list-sources:
name: <alsa_input.pci-0000_00_1f.3.analog-stereo>
properties:
alsa.resolution_bits = "16"
device.profile.name = "analog-stereo"
device.profile.description = "Analog Stereo"
device.description = "Built-in Audio Analog Stereo"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
I want to fetch the field: device.description = "Built-in Audio Analog Stereo" using a simple C++ program
When I try fetching description using
desc = snd_device_name_get_hint(*n, "DESC");
I get the following output for the same device
Name of device: hw:CARD=PCH,DEV=0
Description of device: HDA Intel PCH, ALC3235 Analog
Direct hardware device without any conversions
I/O type of device: (null)
Is there a way I can fetch the description similar to pacmd output?
If it is not possible does anyone know how to fetch the name: <alsa_input.pci-0000_00_1f.3.analog-stereo> field from the pacmd output.
I tried a bunch pf APIs from the official page: https://www.alsa-project.org/alsa-doc/alsa-lib/group___control.html but no luck
Code that I am currently running:
#include <alsa/asoundlib.h>
void listdev(char *devname)
{
char** hints;
int err;
char** n;
char* name;
char* desc;
char* ioid;
/* Enumerate sound devices */
err = snd_device_name_hint(-1, devname, (void***)&hints);
if (err != 0) {
fprintf(stderr, "*** Cannot get device names\n");
exit(1);
}
n = hints;
while (*n != NULL) {
name = snd_device_name_get_hint(*n, "NAME");
desc = snd_device_name_get_hint(*n, "DESC");
ioid = snd_device_name_get_hint(*n, "IOID");
printf("Name of device: %s\n", name);
printf("Description of device: %s\n", desc);
printf("I/O type of device: %s\n", ioid);
printf("\n");
if (name && strcmp("null", name)) free(name);
if (desc && strcmp("null", desc)) free(desc);
if (ioid && strcmp("null", ioid)) free(ioid);
n++;
}
//Free hint buffer too
snd_device_name_free_hint((void**)hints);
}
Got those required values using proplist https://freedesktop.org/software/pulseaudio/doxygen/structpa__card__info.html#a61d544035431d68f87e5e1cb27c3bf2e
more information about proplist: https://freedesktop.org/software/pulseaudio/doxygen/proplist_8h.html