[wdmaudiodev] Re: IKsControl

  • From: Harry Graham <Harry_Graham@xxxxxxxxxx>
  • To: "wdmaudiodev@xxxxxxxxxxxxx" <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Thu, 4 Feb 2010 08:51:22 -0800

You must enumerate the raw device, not the system audio device.

Harry

________________________________
From: wdmaudiodev-bounce@xxxxxxxxxxxxx 
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of Mark Walker
Sent: Thursday, February 04, 2010 8:44 AM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] Re: IKsControl

Tim, yes I'm using the Windows SDK.  I think I need to get a copy of VC++ with 
ATL before I try this any further. Express seems to have a history of weird 
definition and include problems.  I mainly use Express because people I deal 
with use Express and I don't want to be out of sync.

For what it's worth this is my code.  It builds if I kludge it, but it fails at 
pBaseFilter->QueryInterface returning hr = E_NOINTERFACE for all my devices.  
It's not that big a deal in my project at this point, so I'm not too worried 
about it.


Thanks.


    HRESULT hr;
    ICreateDevEnum *pDeviceEnum = NULL;

    hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,
        CLSCTX_INPROC_SERVER,IID_ICreateDevEnum, (void **)&pDeviceEnum);
     enumDevices(CLSID_AudioRendererCategory,pDeviceEnum);
    pDeviceEnum->Release();

void enumDevices(GUID DEVICE_CLSID,ICreateDevEnum *pDeviceEnum )
{
        HRESULT hr;
        IMoniker *pDeviceMonik = NULL;
        IEnumMoniker *pEnumCat = NULL;
        VARIANT varName;

        hr = pDeviceEnum->CreateClassEnumerator(DEVICE_CLSID, &pEnumCat, 0);
        if (hr == S_OK)
        {
            ULONG cFetched;
            while (pEnumCat->Next(1, &pDeviceMonik, &cFetched) == S_OK)
            {
                IPropertyBag *pPropBag = NULL;
                hr = pDeviceMonik->BindToStorage(0, 0, IID_IPropertyBag,(void 
**)&pPropBag);
                if (SUCCEEDED(hr))
                {
                    VariantInit(&varName);
                    hr = pPropBag->Read(L"FriendlyName", &varName, 0);
                      if (SUCCEEDED(hr))
                    {
                        IBaseFilter * pBaseFilter;
                        hr = pDeviceMonik->BindToObject(NULL, NULL,  
IID_IBaseFilter,(void**)&pBaseFilter);
                        IKsControl *pControl;
                        hr = pBaseFilter->QueryInterface(IID_IKsControl, (void 
**) &pControl);
                        pBaseFilter->Release();
                    }
                    else
                        HR_Failed(hr);
                VariantClear(&varName);
                pPropBag->Release();
                }
                else HR_Failed(hr);
                pDeviceMonik->Release();
            }
            pEnumCat->Release();
        }
        else HR_Failed(hr);

}


On 2/3/2010 10:30 AM, Tim Roberts wrote:
Mark Walker wrote:
Thanks Tim & Matthew for responding.
In reference to NTDDI_VERSION >= NTDDI_WINXP I'm writing a user mode 
application that us attempting to access special features of an audio driver.  
Is NTDDI_VERSION  relevant for  user mode applications?  The driver I'm trying 
to reach targets XP and above, though.

I tried ksproxy.h as well, but it doesn't build.  I kludged ksproxy.h to get 
rid of some defines and it built, but it still doesn't give me a good pointer 
when I run it.  Do I have to explicitly expose IKsControl to user mode 
applications in my driver?

You should not need to kludge it.  This compiles for me as-is:
#include <windows.h>
#include <initguid.h>
#include <ks.h>
#include <ksmedia.h>
#include <ksproxy.h>
int main() { IKsControl * ptr = NULL;  return 0; }

You are using the SDK and not the DDK, right?

You do not need to expose IKsControl.  Ksproxy will do that for you.  How are 
you acquiring the device?  Are you using CLSID_SystemDeviceEnum to get the 
IBaseFilter instance?


--

Tim Roberts, timr@xxxxxxxxx<mailto:timr@xxxxxxxxx>

Providenza & Boekelheide, Inc.



Other related posts: