本文整理汇总了C++中CComQIPtr::GetLocalId方法的典型用法代码示例。如果您正苦于以下问题:C++ CComQIPtr::GetLocalId方法的具体用法?C++ CComQIPtr::GetLocalId怎么用?C++ CComQIPtr::GetLocalId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComQIPtr
的用法示例。
在下文中一共展示了CComQIPtr::GetLocalId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMicArrayGeometry
///////////////////////////////////////////////////////////////////////////////
// Function:
// GetMicArrayGeometry()
//
// Description:
// Obtains the geometry for the specified mic array.
//
// Parameters: szDeviceId -- The requested device ID, which can be obtained
// from calling EnumAudioCaptureDevices()
//
// ppGeometry -- Address of the pointer to the mic-array gemometry.
// Caller is ressponsible for calling CoTaskMemFree()
// if the call is successfull.
//
// cbSize -- size of the geometry structure
//
// Returns: S_OK on success
///////////////////////////////////////////////////////////////////////////////
HRESULT GetMicArrayGeometry(wchar_t szDeviceId[], KSAUDIO_MIC_ARRAY_GEOMETRY** ppGeometry, ULONG& cbSize)
{
HRESULT hr = S_OK;
if (szDeviceId == NULL)
return E_INVALIDARG;
if (ppGeometry == NULL)
return E_POINTER;
cbSize = 0;
CComPtr<IMMDeviceEnumerator> spEnumerator;
CComPtr<IMMDevice> spDevice;
CComQIPtr<IPart> spPart;
bool bIsMicArray;
hr = spEnumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
IF_FAILED_RETURN(hr);
hr = spEnumerator->GetDevice(szDeviceId, &spDevice);
IF_FAILED_RETURN(hr);
hr = EndpointIsMicArray(spDevice, bIsMicArray);
IF_FAILED_RETURN(hr);
if (!bIsMicArray)
return E_FAIL;
UINT nPartId = 0;
hr = GetInputJack(spDevice, spPart);
IF_FAILED_RETURN(hr);
hr = spPart->GetLocalId(&nPartId);
IF_FAILED_RETURN(hr);
CComPtr<IDeviceTopology> spTopology;
CComPtr<IMMDeviceEnumerator> spEnum;
CComPtr<IMMDevice> spJackDevice;
CComPtr<IKsControl> spKsControl;
wchar_t * pwstrDevice = 0;
// Get the topology object for the part
hr = spPart->GetTopologyObject(&spTopology);
IF_FAILED_RETURN(hr);
// Get the id of the IMMDevice that this topology object describes.
hr = spTopology->GetDeviceId(&pwstrDevice);
IF_FAILED_RETURN(hr);
// Get an IMMDevice pointer using the ID
hr = spEnum.CoCreateInstance(__uuidof(MMDeviceEnumerator));
IF_FAILED_JUMP(hr, Exit);
hr = spEnum->GetDevice(pwstrDevice, &spJackDevice);
IF_FAILED_JUMP(hr, Exit);
// Activate IKsControl on the IMMDevice
hr = spJackDevice->Activate(__uuidof(IKsControl), CLSCTX_INPROC_SERVER,
NULL, reinterpret_cast<void**>(&spKsControl));
IF_FAILED_JUMP(hr, Exit);
// At this point we can use IKsControl just as we would use DeviceIoControl
KSP_PIN ksp;
ULONG cbData = 0;
ULONG cbGeometry = 0;
// Inititialize the pin property
::ZeroMemory(&ksp, sizeof(ksp));
ksp.Property.Set = KSPROPSETID_Audio;
ksp.Property.Id = KSPROPERTY_AUDIO_MIC_ARRAY_GEOMETRY;
ksp.Property.Flags = KSPROPERTY_TYPE_GET;
ksp.PinId = nPartId & PARTID_MASK;
// Get data size by passing NULL
hr = spKsControl->KsProperty(reinterpret_cast<PKSPROPERTY>(&ksp),
sizeof(ksp), NULL, 0, &cbGeometry);
IF_FAILED_JUMP(hr, Exit);
// Allocate memory for the microphone array geometry
*ppGeometry = reinterpret_cast<KSAUDIO_MIC_ARRAY_GEOMETRY*>
(::CoTaskMemAlloc(cbGeometry));
if(*ppGeometry == 0)
//.........这里部分代码省略.........