[wdmaudiodev] Re: IKsControl

  • From: Tim Roberts <timr@xxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Fri, 05 Feb 2010 10:24:10 -0800

Mark Walker wrote:
> Tim, yes, you're right I should only be interested in single device. 
> However, all devices fail in that particular loop, including the one I
> want.  Shouldn't all devices return a good interface anyway?  Anyway,
> like I said this is not such a big deal right now, but I'd like to
> understand what's going on, though.

If you bring up graphedt, does your device appear in the "Audio
Renderers" list?  Are you able to instantiate it there?  If so, then
your basic process has to work.  Graphedt uses exactly the same code.

Here, this code works on my XP machine, and prints out IBaseFilter
instances for all of my audio devices.

C:\tmp>cl amap.cpp /I..\dshow
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08
for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.


NVIDIA(R) nForce(TM) Audio
00000000 0085849C
Default DirectSound Device
00000000 0085849C
Default WaveOut Device
00000000 0085849C
DirectSound: NVIDIA(R) nForce(TM) Audio
00000000 0085849C

C:\Dev\Videology\sw\i2c>type amap.cpp

#include <streams.h>
#include <ks.h>
#include <atlbase.h>

#pragma comment( lib, "strmiids.lib" )

int main( int argc, char ** argv )
    HRESULT hr;

    CComPtr< IBaseFilter > pFilt;

    // Create an enumerator.

    CComPtr< ICreateDevEnum > pCreateDevEnum;
    pCreateDevEnum.CoCreateInstance( CLSID_SystemDeviceEnum );
    if( !pCreateDevEnum )
        return E_FAIL;

    // Enumerate the list of audio renderer devices.

    CComPtr< IEnumMoniker > pEm;
    pCreateDevEnum->CreateClassEnumerator( CLSID_AudioRendererCategory,
&pEm, 0 );

    if( !pEm )
        return E_FAIL;

    pEm->Reset( );

    // Enumerate through the list and grab the first video capture device.
    // TODO We should allow connection to multiple devices.

    while( 1 )
        ULONG ulFetched = 0;
        CComPtr< IMoniker > pM;
        hr = pEm->Next( 1, &pM, &ulFetched );
        if( FAILED(hr) || !pM )

        // Get the property bag interface from the moniker.

        CComPtr< IPropertyBag > pBag;
        hr = pM->BindToStorage( 0, 0, IID_IPropertyBag, (void**) &pBag );
        if( FAILED(hr) )

        // Go read the friendly name from the property bag.

        CComVariant var;
        var.vt = VT_BSTR;
        hr = pBag->Read( L"FriendlyName", &var, NULL );
        if( FAILED(hr) )
        printf( "%S\n", var.bstrVal );

        hr = pM->BindToObject( 0, 0,
            (void**) &pFilt

        printf( "%08x %p\n", hr, pFilt );


    return 0;


Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.

Other related posts: