How to change the preferred audio device in Vista.

Hello,

I am developing the virtual sound driver in Vista, referring to the MSVAD sample in DDK.
My driver has the renderer device (speaker) and the capture device (microphone).

I have one problem though the driver is running without trouble.
When my application called the specific control code by using DeviceIoControl(),
I want to set the renderer device to the preferred audio device (Default Endpoint).
However, I do not know how to change that from the inside of the driver.
Does anyone know?

I know that the SetupPreferredAudioDevices keyword (in INF) denotes the preferred audio device at the driver’s installation.
Cannot the same thing be done from my driver?

Thanks & best regards,

sano@as-k.co.jp wrote:

I know that the SetupPreferredAudioDevices keyword (in INF) denotes the preferred audio device at the driver’s installation.
Cannot the same thing be done from my driver?

With difficulty, apparently. It’s just a registry setting, but the open
source package created specifically to do this job
(vachanger.sourceforge.net) works by bringing up the control panel and
programmatically clicking the appropriate buttons…


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim Roberts wrote:

With difficulty, apparently. It’s just a registry setting, but the open
source package created specifically to do this job
(vachanger.sourceforge.net) works by bringing up the control panel and
programmatically clicking the appropriate buttons…

I tried vachanger. But, it is not work correctly in some case.
For example, the control panel has already been opened by user…
And, I know the APIs for changing the preferred audio device from the application does not provided in Vista.

Is there only the way of the setting via the control panel?
Is it impossible to do that from the audio driver?

I vaguely recall that the mechanism for managing preferred audio device
changed, either with Vista or even perhaps XP (from 2K). I had a similar
‘requirement’ for a virtual audio device that was met by convincing the
customer that it was not possible (and that was at the time what I believed
to be the truth!)

I wish I could find original references I used but these are the key
elements of the ‘solution’ that I put together.

The virtual audio device dynamically updated its topology by dynamically
registering and deregistering the wave sub-device similar to say how a ‘jack
presence’ capable device might do so. In this way, *if* the device had been
selected by the user as the default audio device, it would dynamically
become the default audio device when it was usable and cease to be the
default audio device when unusable.

The INF controls which were supposed to tell the class installer to make the
device the default seemed to no longer have any effect. The only way I
found to get the device to be the default was to mark it as such in the CPL
applet with UI.

Good Luck,
Dave

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of sano@as-k.co.jp
Sent: Thursday, April 16, 2009 12:09 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] How to change the preferred audio device in Vista.

Tim Roberts wrote:

With difficulty, apparently. It’s just a registry setting, but the open
source package created specifically to do this job
(vachanger.sourceforge.net) works by bringing up the control panel and
programmatically clicking the appropriate buttons…

I tried vachanger. But, it is not work correctly in some case.
For example, the control panel has already been opened by user…
And, I know the APIs for changing the preferred audio device from the
application does not provided in Vista.

Is there only the way of the setting via the control panel?
Is it impossible to do that from the audio driver?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Hi David,

Thank you for your response. And I have two question.

The virtual audio device dynamically updated its topology by dynamically
registering and deregistering the wave sub-device similar to say how a ‘jack
presence’ capable device might do so. In this way, *if* the device had been
selected by the user as the default audio device, it would dynamically
become the default audio device when it was usable and cease to be the
default audio device when unusable.

If I modify my driver to support Dynamic Subdevices(which can dynamically
change my driver’s internal topologies at run time), does the registered
sub-device become the default device?
In that case, I will modify my driver in order to allow the wave and topology
subdevices to be registered in response to an IOCTL sent from my application.

The INF controls which were supposed to tell the class installer to make the
device the default seemed to no longer have any effect. The only way I
found to get the device to be the default was to mark it as such in the CPL
applet with UI.

Sound device management tool of Realtek(HD Audio) which composed of CPL Aplet
(RTSNDMGR.CPL) and custom application(RtHDVCpl.exe) has achieved the preferred
device setting from the application that I want to do.
RtHDVCpl.exe has the button that change the speaker device to the default, and
user can change the default audio device from not control panel but custom
application.
Do you know any information about the implementation method of the vendor’s tool?

mana


If I modify my driver to support Dynamic Subdevices(which can dynamically
change my driver’s internal topologies at run time), does the registered
sub-device become the default device?

If the device was set to be the default device and is then removed, then,
when it is re-inserted, it will become the default device again.

Get yourself a USB headset. Plug it in and out a few times. Do some
experiments.


Sound device management tool of Realtek(HD Audio) which composed of CPL
Aplet
(RTSNDMGR.CPL) and custom application(RtHDVCpl.exe) has achieved the
preferred
device setting from the application that I want to do.

Well, those developers over a Realtek are just that much smarter than me.
Maybe one of them will tell you how to do this.

Good Luck,
-Dave

Mana,

Microsoft has deliberately eliminated the ability to set the default audio device programmatically in Vista for a variety of reasons. I confirm that the advice to employ the INF SetupPreferredAudioDevices and remove / add subdevices dynamically is a solid one in the mean time. Windows 7 has brand new pin / form factor specific audio default configuration.

Generally speaking, you will have a lot more luck discussing these issues on the wdmaudiodev list.

Regards,

Ilya Faenson
Rockville MD USA

Hi David, Ilya,
Thank you very much for your valuable response and sorry for my delayed response.

David R. Cattley wrote:

If the device was set to be the default device and is then removed, then,
when it is re-inserted, it will become the default device again.

Get yourself a USB headset. Plug it in and out a few times. Do some
experiments.

I experienced the change of the default device setting that you said.
I am trying this mechanism as one of the workarounds of my driver.

Ilya Faenson wrote:

Generally speaking, you will have a lot more luck discussing these issues on the
wdmaudiodev list.

The wdmaudiodev list is great!
There was a lot of information, and they were very useful for me.
I will participate in this list.

mana