[wdmaudiodev] Re: setting sample rate in the control panel in Vista

  • From: Hakon Strande <hakons@xxxxxxxxxxxxxxxxxxxxx>
  • To: <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Sat, 27 Oct 2007 20:12:32 -0700

There is no supported/documented way to set the default device format
programmatically/dynamically from the device on Vista. This is a user
only setting on this OS version.

There have been many requests for this design to change and we are
looking into this for the next version of Windows (no - the next version
of Windows does not mean Service Pack 1) especially since it will be
required to properly support HDMI Audio sinks.

HakonS, Windows Sound Team PM

-----Original Message-----
From: wdmaudiodev-bounce@xxxxxxxxxxxxx
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of Eugene Gavrilov
Sent: Saturday, October 27, 2007 6:09 PM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] setting sample rate in the control panel in Vista

Hi,

This question was being discussed some time ago, but I still was unable
to
find   acceptable   solution   for   the problem. I'm writing a driver
(AVStream-based) for Windows  Vista  that  supports:

(1) dynamic sample rate change based on a switch located on the device
(2) external clock source, such as an external SPDIF-in  connector
(3) sample rate change by using our vendor-provided control panel

All the events  are processed by the driver successfully and it
updates  the hardware parameters accordingly. It also sets KSDATARANGE
for  the  current  sample  rate in the KSFILTERFACTORY structure. This
works  fine in Windows XP - as soon as new sample rate is detected
and an audio application is restarted, or as soon as it re-opens
the audio device (re-instantiates audio filter and/or pin), everything
is OK.

In  Windows  Vista  this requires manual change of the preferred audio
format  in  the  'Sounds  and  audio' control panel. I found no way to
avoid this. I already tried the following:

1. The  PKEY_AudioEngine_DeviceFormat  property cannot be set without
administrative  rights  from  a user-level control panel, moreover, this
does not always work.

2. PKEY_AudioEngine_OEMFormat is not documented, although it seems to
be required as well.

3. I  cannot  create  a set of 'virtual subdevices' for each possible
sample  rate,  because this can only be done at install time in an INF
file,  but we are using the same INF file for a wide range of our
devices,
and  the  list  of sample rates is quite large. And this would require
significant development effort.

4.  Restarting  the  device  does  not work either: if the device gets
sample rate change request, sets new sample rate,  and then  I  go  to
the   Device   Manager,   disable  the device and re-enable  it,  all
the  KS  structures  and  data  ranges are set properly by our driver
(with  a  single sample rate that is currently selected), but Windows
Vista    still   remembers   previous   setting   and   refuses   to
playback/record  audio.  In the 'Sounds and audio' control panel Vista
shows  two  sample  rates,  old and new, old is selected. As soon as I
select  new  sample rate and close the control panel, everything's ok,
and after that the old sample rate disappears from the list.

5. I guess using IUregisterSubdevice is not applicable for AVStream
drivers.
> You should use IUnregisterSubdevice and IUnregisterPhysicalConnection
for this
> (see portcls.h) and you should unregister/register subdevices and
physical 
> connections in the following order

6.  I  tried  KsFilterFactorySetDeviceClassesState,  too  - it returns
STATUS_SUCCESS, all WinMM/DSound clients are reset and new topology is
successfully  created, but the control panel still displays old sample
rate  and audio playback/recording fail. After I choose correct sample
rate manually, playback/recording are OK.

7.  I  tried KsFilterFactoryUpdateCacheData. No success. (I'm not sure
if this function is related to the problem).

Any  hints  or  advice,  please?  I  wonder  why  even after driver is
unloaded  and re-loaded, and a new KS topology with new data ranges is
built,  the Control Panel is still using cached values for the current
audio  format,  and  this  cannot be avoided. By the way, I noticed at
least  one  more strange thing: when the 'advanced' tab is opened, the
control  panel  enumerates  all  the  formats  (driver's  intersection
handler  is  called), however, it does only enumerate 8, 16 and 24-bit
formats,  but  not  32.  Our  hardware is using 32 bit (24-bit data in
32-bit containers).

Regards,
 Eugene Gavrilov
 Senior Software Engineer,
 CEntrance, Inc.

******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:
mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.com/


******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.com/

Other related posts: