Raising a KSEVENT_PINCAPS_FORMATCHANGE event is the correct way for a driver to
signal that its format support capabilities have changed.
Windows should then requery the format capabilities and calculate a new
PKEY_AudioEngine_DeviceFormat which honors the new capabilities.
From: wdmaudiodev-bounce@xxxxxxxxxxxxx<mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx>
Sent: Friday, November 18, 2016 4:09 AM
To: wdmaudiodev@xxxxxxxxxxxxx<mailto:wdmaudiodev@xxxxxxxxxxxxx>
Subject: [wdmaudiodev] API to set sample rate in Windows 10
Hi,
I develop and maintain an ASIO/AVS WDM driver for Windows. The driver is used
for multi-channel devices.
Per design and customer requirement the sample rate of the device is set with
the ASIO control panel or the ASIO interface, or is given by digital audio
input (S/PDIF). When the sample rate is changed by the user the AVS driver is
disabled and re-started using PDO states of my bus driver.
The AVS driver offers exactly the sample rate to Windows that is selected by
the user on ASIO interface.
Starting with Windows Vista the sound dialog offers the advanced tab to select
the sample rate and format. Unfortunately this value is cached by the system
during first enumeration after installation in registry:
\\Registry\\Machine\\Software\\Microsoft\\Windows\\CurrentVersion\\MMDevices\\Audio\\<Capture|Render>
The multi-channel device is exposed as up to 8 render and up to 8 capture
device device, each with two channels. It is no practical option for the user
to open all dialog boxes and switch the sample rate to the new one after
changing it in ASIO. Without doing this the devices cannot be used.
I have seen several discussions like:
//www.freelists.org/post/wdmaudiodev/setting-sample-rate-in-the-control-panel-in-Vista,4
but I did not see a solution for this problem.
My current workaround is the following:
I enumerate the following keys from kernel driver
L"{f19f064d-082c-4e27-bc73-6882a1bb8e4c},0"; // PKEY_AudioEngine_DeviceFormat
L"{e4870e26-3cc5-4cd2-ba46-ca0a9a70ed04},0"; // PKEY_AudioEngine_OEMFormat
L"{3d6e1656-2e50-4c4c-8d85-d0acae3c6c68},2"; // unknown
L"{a2a3fff4-353f-407c-9d86-1f9dc7d5a606},2"; // unknown
The keys contain one or more serialized PROPVARIANT structures, with a blob
type and the data structure WAVEFORMATEX. I fix the data structure with the
current sample rate before creating the filters. This seems to work but is not
stable related to operating system changes. E.g. Windows 10 anniversary update
has modified the data structures.
I have also considered the option to use KsPinGenerateEvents(KSPIN,
KSEVENTSETID_PinCapsChange, KSEVENT_PINCAPS_FORMATCHANGE, ...), but my problem
is: in error case no KsPin is created and for that reason I cannot call it.
The access from user mode seems to be possible with IPropertyStore::SetValue(),
but it requires administrator privileges and the data format for the unknown
GUIDs is not documented. I do not see an advantage in comparison to my existing
workaround when using this interface.
Is there in the meantime an API for Windows 10 or a workaround to set the
sample rate for an audio device by program?
Thank you.
Regards,
Guenter Hildebrandt
--
Dr. G?nter Hildebrandt
Senior Software Developer