The shared-mode audio engine (where APOs live) deal entirely in 32-bit
floating-point formats. So your APO will see KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
and wValidBitsPerSample = wBitsPerSample = 32. The audio driver typically
expects KSDATAFORMAT_SUBTYPE_PCM; you should confirm with your hardware vendor
whether it wants wValidBitsPerSample = 24 and wBitsPerSample = 32, or
wValidBitsPerSample = 24 and wBitsPerSample = 32. Either way, the block align
should use the container bit depth, rather than the valid bit depth.
The PKEY_AudioEngine_OEMFormat value should be a PROPVARIANT, so you will need
to set the variant type etc. In the example on the page you link, the 0x41 is
VT_BLOB.
________________________________
From: wdmaudiodev-bounce@xxxxxxxxxxxxx <wdmaudiodev-bounce@xxxxxxxxxxxxx> on
behalf of Culann mac Cabe <culann@xxxxxxxxxx>
Sent: Tuesday, January 22, 2019 3:04:52 PM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] Help please: How to set default audio format for USB
headphone in via inf
Hello wdnaudiodev people.
I am writing an APO for a USB headset device. The headset hardware supports 2
audio formats: (48k Stereo 24bits) and (96k Stereo 24bits).
I would like the hardware, on installation, to default to the [48k Stereo
24bits] format and I believe I can do this in the .inf file as follows:
[OEMSettingsOverride.AddReg]
HKR,"EP\\0", %PKEY_AudioEndpoint_Association%,,%KSNODETYPE_HEADPHONES%
HKR,"EP\\0", %PKEY_AudioEngine_OEMFormat%, %REG_BINARY%, XXXX...X
- where "XXXX...X" is generated using code provided at
https://docs.microsoft.com/en-us/windows-hardware/drivers/audio/pkey-audioengine-oemformat<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows-hardware%2Fdrivers%2Faudio%2Fpkey-audioengine-oemformat&data=02%7C01%7Cmatthew.van.eerde%40microsoft.com%7C9c715535681040f1f89a08d680be2dda%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636837951673786830&sdata=5AX8kc5GVO5NCzMRuUonRRkKLGc4O8ku5hMbwbQGP50%3D&reserved=0>
This handy code allows one to define this format using WAVEFORMATEXTENSIBLE
values, which I think is where I may be going wrong.
For my desired 2 channel, 48k, 24 bit format I have:
wfx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; wfx.Format.nChannels = 2;
wfx.Format.nSamplesPerSec = 48000; wfx.Format.nAvgBytesPerSec = 6 * 48000; //
blockalign * sample rate wfx.Format.nBlockAlign = 6; // 2 channels * 24 bits
wfx.Format.wBitsPerSample = 24; wfx.Format.cbSize =
sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
wfx.Samples.wValidBitsPerSample = 24; // ???!!! In APO Format negotiation this
appears to be 32... wfx.dwChannelMask = 3; wfx.SubFormat =
KSDATAFORMAT_SUBTYPE_PCM;
Does the above look correct?
Thanks for your help as ever!
Culann