[wdmaudiodev] Wave ID from DirectSound GUID

  • From: "Jeff Pages" <jeff@xxxxxxxxxxxxxxxx>
  • To: <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Wed, 21 Dec 2005 15:49:52 +1100

Following the procedure described in the DirectSound documentation under System 
Property Sets, I'm trying to use the DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION 
property call to obtain the waveOut ID corresponding to a DirectSound GUID. The 
call succeeds, but it appears to only fill in the Type field of the 
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA structure (which it sets to 
DIRECTSOUNDDEVICE_TYPE_WDM), and the Description, Module, Interface and 
WaveDeviceID fields are left untouched.

This is the code I'm using (the machine is running Windows XP SP2):

typedef HRESULT (__stdcall tDllGetClassObject) (REFCLSID, REFIID, LPVOID *);

UINT WaveDeviceID = 0;
HMODULE mDSound = LoadLibrary ("dsound.dll");
tDllGetClassObject *pDllGetClassObject = (tDllGetClassObject *) GetProcAddress 
(mDSound, "DllGetClassObject");
if (pDllGetClassObject) {
    IClassFactory *pClassFactory;
    if ((*pDllGetClassObject) (CLSID_DirectSoundPrivate, IID_IClassFactory, 
(PVOID *) &pClassFactory) == S_OK) {
        IKsPropertySet *pPropertySet;
        if (pClassFactory->CreateInstance (NULL, IID_IKsPropertySet, (PVOID *) 
&pPropertySet) == S_OK) {
            DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA Property;
            memset (&Property, 0, sizeof Property);
            Property.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
            Property.DeviceId = PlaybackGuid;    // PlaybackGuid is obtained 
elsewhere from enumerating the DSound devices
            ULONG BytesReturned;
            HRESULT rc = pPropertySet->Get (
                DSPROPSETID_DirectSoundDevice,
                DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
                NULL,
                0,
                &Property,
                sizeof Property,
                &BytesReturned
            );
            WaveDeviceID = Property.WaveDeviceId;
            pPropertySet->Release ();
        }
        pClassFactory->Release ();
    }
}
FreeLibrary (mDSound);


Any thoughts on what I might be doing wrong?

Jeff Pages
Innes Corporation Pty Ltd

Other related posts:

  • » [wdmaudiodev] Wave ID from DirectSound GUID