本文整理汇总了C++中AEDeviceInfoList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ AEDeviceInfoList::insert方法的具体用法?C++ AEDeviceInfoList::insert怎么用?C++ AEDeviceInfoList::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AEDeviceInfoList
的用法示例。
在下文中一共展示了AEDeviceInfoList::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EnumerateDevicesEx
//.........这里部分代码省略.........
if (FAILED(hr))
{
CLog::Log(LOGERROR, __FUNCTION__": Retrieval of DirectSound endpoint device name failed.");
SAFE_RELEASE(pDevice);
SAFE_RELEASE(pProperty);
goto failed;
}
std::string strFriendlyName = localWideToUtf(varName.pwszVal);
PropVariantClear(&varName);
hr = pProperty->GetValue(PKEY_AudioEndpoint_GUID, &varName);
if (FAILED(hr))
{
CLog::Log(LOGERROR, __FUNCTION__": Retrieval of DirectSound endpoint GUID failed.");
SAFE_RELEASE(pDevice);
SAFE_RELEASE(pProperty);
goto failed;
}
std::string strDevName = localWideToUtf(varName.pwszVal);
PropVariantClear(&varName);
hr = pProperty->GetValue(PKEY_AudioEndpoint_FormFactor, &varName);
if (FAILED(hr))
{
CLog::Log(LOGERROR, __FUNCTION__": Retrieval of DirectSound endpoint form factor failed.");
SAFE_RELEASE(pDevice);
SAFE_RELEASE(pProperty);
goto failed;
}
std::string strWinDevType = winEndpoints[(EndpointFormFactor)varName.uiVal].winEndpointType;
AEDeviceType aeDeviceType = winEndpoints[(EndpointFormFactor)varName.uiVal].aeDeviceType;
PropVariantClear(&varName);
/* In shared mode Windows tells us what format the audio must be in. */
IAudioClient *pClient;
hr = pDevice->Activate(IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pClient);
if (FAILED(hr))
{
CLog::Log(LOGERROR, __FUNCTION__": Activate device failed (%s)", WASAPIErrToStr(hr));
goto failed;
}
//hr = pClient->GetMixFormat(&pwfxex);
hr = pProperty->GetValue(PKEY_AudioEngine_DeviceFormat, &varName);
if (SUCCEEDED(hr) && varName.blob.cbSize > 0)
{
WAVEFORMATEX* smpwfxex = (WAVEFORMATEX*)varName.blob.pBlobData;
deviceInfo.m_channels = layoutsByChCount[std::max(std::min(smpwfxex->nChannels, (WORD) DS_SPEAKER_COUNT), (WORD) 2)];
deviceInfo.m_dataFormats.push_back(AEDataFormat(AE_FMT_FLOAT));
deviceInfo.m_dataFormats.push_back(AEDataFormat(AE_FMT_AC3));
deviceInfo.m_sampleRates.push_back(std::min(smpwfxex->nSamplesPerSec, (DWORD) 192000));
}
else
{
CLog::Log(LOGERROR, __FUNCTION__": Getting DeviceFormat failed (%s)", WASAPIErrToStr(hr));
}
pClient->Release();
SAFE_RELEASE(pDevice);
SAFE_RELEASE(pProperty);
deviceInfo.m_deviceName = strDevName;
deviceInfo.m_displayName = strWinDevType.append(strFriendlyName);
deviceInfo.m_displayNameExtra = std::string("DirectSound: ").append(strFriendlyName);
deviceInfo.m_deviceType = aeDeviceType;
deviceInfoList.push_back(deviceInfo);
}
// since AE takes the first device in deviceInfoList as default audio device we need
// to sort it in order to use the real default device
if(deviceInfoList.size() > 1)
{
std::string strDD = GetDefaultDevice();
for (AEDeviceInfoList::iterator itt = deviceInfoList.begin(); itt != deviceInfoList.end(); ++itt)
{
CAEDeviceInfo devInfo = *itt;
if(devInfo.m_deviceName == strDD)
{
deviceInfoList.erase(itt);
deviceInfoList.insert(deviceInfoList.begin(), devInfo);
break;
}
}
}
return;
failed:
if (FAILED(hr))
CLog::Log(LOGERROR, __FUNCTION__": Failed to enumerate WASAPI endpoint devices (%s).", WASAPIErrToStr(hr));
SAFE_RELEASE(pEnumDevices);
SAFE_RELEASE(pEnumerator);
}