本文整理汇总了C++中DeviceInfo::SetDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ DeviceInfo::SetDevice方法的具体用法?C++ DeviceInfo::SetDevice怎么用?C++ DeviceInfo::SetDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceInfo
的用法示例。
在下文中一共展示了DeviceInfo::SetDevice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateDevicesList
void AlsaBackend::UpdateDevicesList()
{
Log("AlsaBackend::UpdateDeviceList\n");
DeviceInfo info;
void **hints, **n;
char *name, *descr, *desc;
unsigned devices = 0;
InitDevicesList();
info.SetDevice(devices++, "default", "Default device", "default");
info.type = DeviceInfo::TYPE_PLUG;
info.direction = 0;
PcmPreProbe(info, OUTPUT);
PcmPreProbe(info, INPUT);
devicesList.push_back(info);
// Start with safe alsa detection, list the devices from software config.
snd_config_update();
if (snd_device_name_hint(-1, "pcm", &hints) < 0)
return;
n = hints;
while (*n != NULL) {
name = snd_device_name_get_hint(*n, "NAME");
descr = snd_device_name_get_hint(*n, "DESC");
if (!descr)
desc = (char*)"";
else
{
desc = descr;
for (int i = strlen(desc); i > 0; i--)
if (desc[i-1] == '\n')
desc[i-1] = ' ';
}
if (IgnorePlugin(name))
{
Log("Ignoring ALSA device %s", name);
}
else
{
info.SetDevice(devices++, name, desc, name);
info.type = DeviceInfo::TYPE_PLUG;
info.probed = false;
info.direction = 0;
PcmPreProbe(info, OUTPUT);
PcmPreProbe(info, INPUT);
if (info.direction != 0)
devicesList.push_back(info);
}
if (name != NULL)
free(name);
if (descr != NULL)
free(descr);
n++;
}
snd_device_name_free_hint(hints);
// Continue with new detection, this is a more thorough test with probing device characteristics
enum { IDLEN = 12 };
char hwdev[IDLEN+1];
int card, err, dev;
snd_ctl_t* handle = NULL;
snd_ctl_card_info_t* cardinfo;
snd_pcm_info_t* pcminfo;
snd_ctl_card_info_alloca(&cardinfo);
snd_pcm_info_alloca(&pcminfo);
card = -1;
while (snd_card_next(&card) == 0 && card >= 0)
{
snprintf(hwdev, IDLEN, "hw:%d", card);
err = snd_ctl_open(&handle, hwdev, 0);
if (sc_errcheck(err, "opening control interface", card, -1))
continue;
err = snd_ctl_card_info(handle, cardinfo);
if (sc_errcheck(err, "obtaining card info", card, -1))
{
snd_ctl_close(handle);
continue;
}
Log("Card %d, ID '%s', name '%s'", card, snd_ctl_card_info_get_id(cardinfo), snd_ctl_card_info_get_name(cardinfo));
dev = -1;
//.........这里部分代码省略.........