我如何从设备文件描述符中获取设备信息,包括设备名称?
例如,在 SKYPE 中,我可以看到设备“/dev/snd/pcmC2D0c”的名称为:“USB 2.0 Camera.USB Audio Default Audio Device (default:CARD=Camera)”
我如何使用 C++ 获得这样的设备名称?
int file = open("/dev/snd/pcmC2D0c", O_RDWR | O_NONBLOCK, 0);
if (-1 == file) // check is error occurred during opening?
{
perror("open");
return -1;
}
if (-1 == ioctl(file, /* appropriate ioctl value to get the device info? */, /* appropriate structure to fill with device info? */))
{
perror("ioctl");
return -1;
}