Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

corrispondence between Multimedia HMIXER and DirectSound GUID

73 views
Skip to first unread message

Daniele Castagna

unread,
Dec 14, 2004, 10:28:16 AM12/14/04
to
Hello,

I've problem finding the corrispondence between the mixers, returned by
the mixerOpen() fuction, and the devices enumerated with the
DirectSoundEnumerate().

I open the mixer using mixerOpen(&mixerHandle,deviceIndex,0,0,0) with
deviceIndex ranging from 0 to mixerGetNumDevs()-1.

To retrieve DirectSound devices I use DirectSoundEnumerate() and
DirectSoundCaptureEnumerate(), in my callbacks I retrieve the GUIDs of
devices.

I've not find the way to get the corrispondence between DirectSound device
GUIDs and Multimedia mixer indices (or handles).

Thanks in advance!

Daniele Castagna


Yan-Hong Huang[MSFT]

unread,
Dec 14, 2004, 9:35:24 PM12/14/04
to
Hello Daniele,

Based on my understanding, the question is: You use mixerOpen to get a
mixerhandle of a mixer. At the same time, you use DirectSoundEnumerate to
get a GUID of a mixer device. Is there any map we can find to map a mixer
handle to a GUID, right?

I searched MSDN, but didn't find any direct information on mapping a GUID
to a mixer handle. However, In the call back function of
DirectSoundnumerate, we can find lpcstrDescription, which provides a
textual description of the DirectSound device. In Mixer functions, we also
have a mixerGetDevCaps API to get a MIXERCAPS structure of that mixer
device. In this structure, we have szPname which is the name of the
product. Could you please compare these two strings to see whether it is
the same for a mixer object?

Please test the above and let me know whether it works for you. I will also
consult our media support team to see whether there is any existing method
to do that. If you have any more concerns, please feel free to post here.
Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
-http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.as
p&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.

Yan-Hong Huang[MSFT]

unread,
Dec 14, 2004, 9:36:58 PM12/14/04
to
Hello Daniele,

I found that you posted the same topic in
microsoft.public.win32.programmer.mmedia group also. I have replied you
there. If you have any more concerns on the question, please feel free to
reply there and we will follow up.

Thanks very much for your understanding.

Yan-Hong Huang[MSFT]

unread,
Dec 14, 2004, 9:45:49 PM12/14/04
to
Sorry, please skip this post. I should post it to
microsoft.public.win32.programmer.directx.audio group. Please reply after
my first post.

Thanks very much.

Daniele Castagna

unread,
Dec 15, 2004, 4:52:51 AM12/15/04
to
Sorry, but I can't map the devices this way.

In the DirectSound enumerate, the description of two devices with the same
name, is the same.

A workaround could be setting the Preferred Playback Device in the mmedia,
and then query the GUID of the Preferred Playback Device in the Direct
Sound, but I don't know how to set it...

Thanks very much.

Daniele Castagna.


"Yan-Hong Huang[MSFT]" <yhh...@online.microsoft.com> wrote in message
news:zhHGF7k4...@cpmsftngxa10.phx.gbl...

Chris P. [MVP]

unread,
Dec 15, 2004, 2:59:04 PM12/15/04
to
On Wed, 15 Dec 2004 10:52:51 +0100, Daniele Castagna wrote:

> Sorry, but I can't map the devices this way.
>
> In the DirectSound enumerate, the description of two devices with the same
> name, is the same.
>
> A workaround could be setting the Preferred Playback Device in the mmedia,
> and then query the GUID of the Preferred Playback Device in the Direct
> Sound, but I don't know how to set it...

AFAIK the method Yan-Hong pointed is the only one that works.

It is generally not a good idea to have multiple devices with the same
name. I would be complaining to the manufacturer, the device should at
least have an instance number after it.

-Chris

Yan-Hong Huang[MSFT]

unread,
Dec 15, 2004, 8:22:19 PM12/15/04
to
Hi Daniele,

After discussing it with our developers, we did find out a more reliable
and recommended way.

We can use the CLSID_DirectSoundPrivate object:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/
directx/htm/systempropertysets.asp

This object provides an IKsPropertySet interface, which lets you Set and
Get various properties on DirectSound. Get the property
"DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING" to map between DirectSound
device GUIDs and mixer device IDs.

Thanks.

Chris P. [MVP]

unread,
Dec 15, 2004, 9:17:28 PM12/15/04
to
On Thu, 16 Dec 2004 01:22:19 GMT, Yan-Hong Huang[MSFT] wrote:

> X-Tomcat-ID: 33396055
> References: <OqodZGf4...@TK2MSFTNGP10.phx.gbl> <zhHGF7k4...@cpmsftngxa10.phx.gbl> <O$okovo4E...@TK2MSFTNGP11.phx.gbl>
> MIME-Version: 1.0
> Content-Type: text/plain
> Content-Transfer-Encoding: 7bit
> From: yhh...@online.microsoft.com (Yan-Hong Huang[MSFT])


>
> After discussing it with our developers, we did find out a more reliable
> and recommended way.
>
> We can use the CLSID_DirectSoundPrivate object:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/
> directx/htm/systempropertysets.asp
>
> This object provides an IKsPropertySet interface, which lets you Set and
> Get various properties on DirectSound. Get the property
> "DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING" to map between DirectSound
> device GUIDs and mixer device IDs.

Well they had that little beauty hidden nicely! I've been doing this for
years and never come across these property sets before, are they new?

-Chris

The March Hare [MVP]

unread,
Dec 15, 2004, 10:33:05 PM12/15/04
to
On Wed, 15 Dec 2004 21:17:28 -0500, Chris P. [MVP] wrote:


> Well they had that little beauty hidden nicely! I've been doing this for
> years and never come across these property sets before, are they new?

They were saving it as your Christmas present :p

Yan-Hong Huang[MSFT]

unread,
Dec 16, 2004, 2:24:10 AM12/16/04
to
Hi All,

:)

Yes, I think they are pretty new. See the headline of that web page:
Microsoft DirectX 9.0 SDK Update (October 2004)

Check the link and I think they come from DirectX 9.0C.

In fact, the mixer device ID is a small integer number and it will always
match the wave device ID. E.g. your Soundblaster card might have a mixer
ID of 2, in which case the ID for waveOut (or waveIn) will also be 2.

Actually, the property I mentioned lets developers get from a DirectSound
GUID to a wave/mixer ID. To go in the other direction we have to obtain
the mixer device name (using mixerGetDevCaps) and then the property lets
you get from the name to the DirectSound GUID. Here's some sample code for
your reference:


HRESULT
DirectSoundPrivateCreate
(
OUT LPKSPROPERTYSET * ppKsPropertySet
)
{
HMODULE hLibDsound = NULL;
LPFNDLLGETCLASSOBJECT pfnDllGetClassObject = NULL;
LPCLASSFACTORY pClassFactory = NULL;
LPKSPROPERTYSET pKsPropertySet = NULL;
HRESULT hr = DS_OK;

// Load dsound.dll
hLibDsound = LoadLibrary(TEXT("dsound.dll"));

if(!hLibDsound)
{
hr = DSERR_GENERIC;
}

// Find DllGetClassObject
if(SUCCEEDED(hr))
{
pfnDllGetClassObject =
(LPFNDLLGETCLASSOBJECT)GetProcAddress
(
hLibDsound,
"DllGetClassObject"
);

if(!pfnDllGetClassObject)
{
hr = DSERR_GENERIC;
}
}

// Create a class factory object
if(SUCCEEDED(hr))
{
hr =
pfnDllGetClassObject
(
CLSID_DirectSoundPrivate,
IID_IClassFactory,
(LPVOID *)&pClassFactory
);
}

// Create the DirectSoundPrivate object and query for an IKsPropertySet
// interface
if(SUCCEEDED(hr))
{
hr =
pClassFactory->CreateInstance
(
NULL,
IID_IKsPropertySet,
(LPVOID *)&pKsPropertySet
);
}

// Release the class factory
if(pClassFactory)
{
pClassFactory->Release();
}

// Handle final success or failure
if(SUCCEEDED(hr))
{
*ppKsPropertySet = pKsPropertySet;
}
else if(pKsPropertySet)
{
pKsPropertySet->Release();
}

FreeLibrary(hLibDsound);

return hr;
}

HRESULT
DSGetGuidFromName
(
IN LPWSTR szName,
IN BOOL fRecord,
OUT LPGUID pGuid
)
{
LPKSPROPERTYSET pKsPropertySet = NULL;
HRESULT hr;

DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_DATA
WaveDeviceMap;

// Create the DirectSoundPrivate object
hr =
DirectSoundPrivateCreate
(
&pKsPropertySet
);

// Attempt to map the waveIn/waveOut device string to a DirectSound
device
// GUID.
if(SUCCEEDED(hr))
{
WaveDeviceMap.DeviceName = szName;
WaveDeviceMap.DataFlow = fRecord ?
DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE : DIRECTSOUNDDEVICE_DATAFLOW_RENDER;

hr =
pKsPropertySet->Get
(
DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING,
NULL,
0,
&WaveDeviceMap,
sizeof(WaveDeviceMap),
NULL
);
}

// Clean up
if(pKsPropertySet)
{
pKsPropertySet->Release();
}

if(SUCCEEDED(hr))
{
*pGuid = WaveDeviceMap.DeviceId;
}

return hr;

Chris P. [MVP]

unread,
Dec 16, 2004, 9:39:08 AM12/16/04
to

Well, it would be Daniele's Christmas present actually. :) I'm just adding
it to my mental store of useful information and will probably post the
sample code somewhere for others to reference.

-Chris

Chris P. [MVP]

unread,
Dec 16, 2004, 9:44:25 AM12/16/04
to
On Thu, 16 Dec 2004 07:24:10 GMT, Yan-Hong Huang[MSFT] wrote:

> Hi All,
>
> :)
>
> Yes, I think they are pretty new. See the headline of that web page:
> Microsoft DirectX 9.0 SDK Update (October 2004)
>
> Check the link and I think they come from DirectX 9.0C.

Ok, at least I don't feel a complete goof. Now I'm going to have to read
all the documentation again to see what else I missed.

> In fact, the mixer device ID is a small integer number and it will always
> match the wave device ID. E.g. your Soundblaster card might have a mixer
> ID of 2, in which case the ID for waveOut (or waveIn) will also be 2.
>
> Actually, the property I mentioned lets developers get from a DirectSound
> GUID to a wave/mixer ID. To go in the other direction we have to obtain
> the mixer device name (using mixerGetDevCaps) and then the property lets
> you get from the name to the DirectSound GUID. Here's some sample code for
> your reference:

Thanks, YanHong. Much appreciate the sample code.

Regards,
Chris

Daniele Castagna

unread,
Dec 16, 2004, 12:40:12 PM12/16/04
to
Sorry, but even this way has some problems.

Here is my code:

int GetMixerIDFromDSoundGUID( GUID i_sGUID )


{
LPKSPROPERTYSET pKsPropertySet = NULL;
HRESULT hr;

DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA
sDirectSoundDeviceDescription;


memset(&sDirectSoundDeviceDescription,0,sizeof(sDirectSoundDeviceDescription
));
hr = DirectSoundPrivateCreate( &pKsPropertySet );
if(SUCCEEDED(hr))
{
sDirectSoundDeviceDescription.DeviceId = i_sGUID;
hr = pKsPropertySet->Get(DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
NULL,
0,
&sDirectSoundDeviceDescription,
sizeof(sDirectSoundDeviceDescription),
NULL
);
pKsPropertySet->Release();
}


if (SUCCEEDED(hr))
return sDirectSoundDeviceDescription.WaveDeviceId;
else return -1;
}


Now, the problem is that the pKsPropertySet->Get(...) function doesn't
change the sDirectSoundDeviceDescription.WaveDeviceId although it sets Type
and DataFlow.

Example:
if I set sDirectSoundDeviceDescription.WaveDeviceId to 0xABAC0DE before
calling pKsPropertySet->Get(...), the WaveDeviceId remains 0xABAC0DE even if
the pKsPropertySet->Get() returns S_OK.
The Type and DataFlow are set correctly.

I've tried with different devices.

Thanks.

Daniele Castagna
www.milestone.it

"Yan-Hong Huang[MSFT]" <yhh...@online.microsoft.com> wrote in message

news:kBdb52w...@cpmsftngxa10.phx.gbl...

Yan-Hong Huang[MSFT]

unread,
Dec 17, 2004, 2:01:24 AM12/17/04
to
Hello Daniele,

Based on the MSDN document,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/
directx/htm/systempropertysets.asp

DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION
This property retrieves a full description of a DirectSound device
specified by GUID.

In this property set, we need to pass in DeviceID and DataFlow, then it
will return Type, Description, Module, Interface, WaveDeviceID.

Here WaveDeviceID is a [out] parameter. I don't think you can set
WaveDeviceId to a value before calling pKsPropertySet->Get(...). This has
no effect. What we can do is to pass in a Device GUID and then get the
properties of this device including wavedeviceid.

Thanks very much.

0 new messages