Wince 下枚举音频设备

在当前的系统中只有一个audio capture filter,可以写一个简单的程序把系统中所有的filter 都枚举出来。这个和PC上的差不多。但是枚举设备和PC上就差了不少,关键是很多在PC上的API很多都不能在WINCE上用。


1Initialiseaudio capture device

CoCreateInstance(CLSID_AudioCapture,0, CLSCTX_INPROC,IID_IBaseFilter,reinterpret_cast<void**>(&pInputDevice));

2Query propertyinterface

pInputDevice->QueryInterface(&pInPropertyBag );

3set device IDand load property bag

VariantInit(&varDeviceId );

V_VT( &varDeviceId )= VT_I4;

V_I4( &varDeviceId )= deviceId;

PropBag.Write(L"WaveInId", &varDeviceId );

pInPropertyBag->Load(&PropBag,0);

VariantClear(&varDeviceId );

4) Create Graph Builder

CoCreateInstance(CLSID_FilterGraph,0, CLSCTX_INPROC_SERVER,IID_IGraphBuilder,reinterpret_cast<void**>(&pGraph));//Initialize Graph builder

pGraph->AddFilter(pInputDevice,TEXT("AudioCapture"));

5) Create Capture Graph Builder

CoCreateInstance(CLSID_CaptureGraphBuilder,0, CLSCTX_INPROC_SERVER,IID_ICaptureGraphBuilder2,reinterpret_cast<void**>(& pBuild));

pBuild->SetFiltergraph(pGraph );

6) findpin

pBuild->FindPin(

pInputDevice,// Pointerto the filter to search.

PINDIR_OUTPUT,// Search for an output pin.

&PIN_CATEGORY_CAPTURE,//Search for a preview pin.

&MEDIATYPE_Audio,//Search for a video pin.

TRUE,// The pinmust be unconnected.

0,// Return the first matching pin (index 0).

&pCapturePin);

6) query interface for stream config

pCapturePin->QueryInterface(IID_IAMStreamConfig,reinterpret_cast<void**>(&m_pIAMStreamConfig));


你可能感兴趣的:(audio,device,enume)