[wdmaudiodev] Re: [EXTERNAL] DownMixing APO (Multichannel to Stereo)

  • From: Shubham Kumar <shubham.kumar.sci@xxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Thu, 21 Jan 2021 20:32:43 +0530

Our goal is to process app’s 8 channel audio and render to an endpoint
which only supports 2 channels.

We want to keep this app independent, therefore we want this 8 channel to 2
channel downmixing to happen in APO.



   - After enabling “Window Sonic for headphone” in “spatial sound”
   property tab,
    *IAudioClient::Initialize *starts returning success but SFX LockProcess
   creates Input Output connection with 2 channel format only, which defeats
   our purpose.
   - Does *IAudioClient::Initialize *internally call some other OS EFX/MFX
   APO to get Input Output connection format? =>
      - Do we need to implement all three EFX, MFX, SFX to handle our
      scenario ?
      - Or Do we need to replace some OS APO with ours to make this work ?
   - We are using SWAP APO as a template for our APO, and
   overridden/defined the following functions.
      - APOProcess
         - LockForProcess
         - Initialize
         - GetEffectsList
         - OnPropertyValueChanged
         - IsOutputFormatSupported
         - IsInputFormatSupported
      - Do we need to override some other functions of
      IAudioProcessingObject (e.g. ValidateDefaultAPOFormat,
      IsFormatTypeSupported ) and force 8 channels by returning false for other
      formats.


Thanks

*SK*


On Thu, 21 Jan 2021 at 07:30, Shubham Kumar <shubham.kumar.sci@xxxxxxxxx>
wrote:

Using following implementation with SysVad driver

   - Only HDMI speaker endpoint with stereo format support
   - Single instance of render pin (no offload, no loopback pin)
   - No audio module support



*APO – *

After Mathew suggestion we modified Swap SFX so that
*IsInputFormatSupported* returns true for surround channel (without
calling *IsFormatTypeSupported()*). With this change
*IAudioClient::IsFormatSupported* returns success for surround channel to
app.

But then we found that *IAudioClient::Initialize shared mode and surround
config *fails with error 887C001E.

When *IAudioClient::Initialize *is called from application we observe
that APO’s check format support calls and *LockForProcess* are success.
But after that it fails internally.

It also dumps following call stack in context of audiodg.exe visual studio
debugger after failure

*avcore\audiocore\engine\core\processor\audioprocessor.cpp(2265)\audioeng.dll!00007FFBCE85DCFD:
(caller: 00007FFBCE83AE41) ReturnHr(1) tid(424) 887C001E*

*avcore\audiocore\engine\core\processor\audioprocessor.cpp(2431)\audioeng.dll!00007FFBCE85E17D:
(caller: 00007FF790AE8580) ReturnHr(2) tid(424) 887C001E*

*avcore\audiocore\server\audiodg\exe\connectioninstance.cpp(345)\AUDIODG.EXE!00007FF790B0771D:
(caller: 00007FF790AE8465) ReturnHr(1) tid(424) 887C001E*

*avcore\audiocore\server\audiodg\exe\connectioninstance.cpp(242)\AUDIODG.EXE!00007FF790B0761C:
(caller: 00007FF790AE809E) ReturnHr(2) tid(424) 887C001E*

*avcore\audiocore\server\audiodg\exe\pipeinstance.cpp(2905)\AUDIODG.EXE!00007FF790B0765C:
(caller: 00007FF790AE809E) ReturnHr(3) tid(424) 887C001E*

*avcore\audiocore\server\audiodg\exe\audiodevicegraph.cpp(1440)\AUDIODG.EXE!00007FF790B07442:
(caller: 00007FF790AF7EE0) ReturnHr(4) tid(424) 887C001E*

*avcore\audiocore\server\audiodg\exe\submix.cpp(110)\AUDIODG.EXE!00007FF790B0EE35:
(caller: 00007FF790AF7CEA) ReturnHr(5) tid(424) 887C001E*

*avcore\audiocore\server\audiodg\exe\submix.cpp(852)\AUDIODG.EXE!00007FF790B0EDA0:
(caller: 00007FF790AF7D20) ReturnHr(6) tid(424) 887C001E*

*avcore\audiocore\server\audiodg\exe\submix.cpp(860)\AUDIODG.EXE!00007FF790B0EDA0:
(caller: 00007FF790AEFACE) ReturnHr(7) tid(424) 887C001E*

*avcore\audiocore\server\audiodg\exe\submix.cpp(921)\AUDIODG.EXE!00007FF790B0BF51:
(caller: 00007FF790AE3574) ReturnHr(8) tid(424) 887C001E*

*avcore\audiocore\server\audiodg\exe\streamgroup.cpp(242)\AUDIODG.EXE!00007FF790B0401D:
(caller: 00007FFC0A888FD3) ReturnHr(9) tid(424) 887C001E*



If we enable *“Windows Sonic for headphone”* in “*spatial sound*”
property tab, *IAudioClient::Initialize *starts *returning success.*



Question

   - Is it necessary to add spatial sound format same as done for sonic,
   dolby etc? and without that will it not work?
   - Are we missing something else from driver or APO side which is
   causing this error?




*Thanks*
*SK*


On Tue, 19 Jan 2021 at 23:18, Matthew van Eerde <
dmarc-noreply@xxxxxxxxxxxxx> wrote:

You can do this in a render SFX APO.



Whether the application takes advantage of it is up to the app. In
particular if the app calls IAudioClient::IsFormatSupported with the
eight-channel format then it will use your custom downmix; if not, it
won’t. It’s the app’s decision.



More on this here: How to negotiate an audio format for a Windows Audio
Session API (WASAPI) client
<https://matthewvaneerde.wordpress.com/2017/10/17/how-to-negotiate-an-audio-format-for-a-windows-audio-session-api-wasapi-client/>



Many apps use higher-level audio APIs that wrap WASAPI (e.g. Media
Foundation.) In such cases the higher-level API will often take care of
this kind of thing on the app’s behalf. (This is one of many good reasons
to use higher-level APIs.)



*From: *Shubham Kumar <shubham.kumar.sci@xxxxxxxxx>
*Sent: *Tuesday, January 19, 2021 9:39 AM
*To: *wdmaudiodev@xxxxxxxxxxxxx
*Subject: *[EXTERNAL] [wdmaudiodev] DownMixing APO (Multichannel to
Stereo)



Hi,
I'm trying to implement a APO, which can process 8 channel data and send
2 channel to the endpoint. I am trying to process the downmixing in the APO
itself.

I have few doubts:



   - Is it possible to let audio client application know to send 8
   channel data, despite the endpoint being set to 2 channels.
   - While experimenting with sysvad
   
<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FWindows-driver-samples%2Ftree%2Fmaster%2Faudio%2Fsysvad&data=04%7C01%7CMatthew.van.Eerde%40microsoft.com%7C125af4fc66d8491b827f08d8bca11931%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637466747853458092%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=QOb45iQpoX%2FQtEA3vUpzIZ5tu03jU7Yph6oJ5cXV02I%3D&reserved=0>
   code,


   - I found two functions IsInputFormatSupported
      
<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Fapi%2Faudioenginebaseapo%2Fnf-audioenginebaseapo-iaudioprocessingobject-isinputformatsupported&data=04%7C01%7CMatthew.van.Eerde%40microsoft.com%7C125af4fc66d8491b827f08d8bca11931%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637466747853468088%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=nLmqecKaCL%2BUD2befkJSYdveZRTi65tkYxVyckweCqg%3D&reserved=0>
      and IsOutputFormatSupported
      
<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Fapi%2Faudioenginebaseapo%2Fnf-audioenginebaseapo-iaudioprocessingobject-isoutputformatsupported&data=04%7C01%7CMatthew.van.Eerde%40microsoft.com%7C125af4fc66d8491b827f08d8bca11931%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637466747853468088%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=3ZrDSG63znM9j9XBe%2FreWoisMLnSLJwwaEkTguQMI04%3D&reserved=0>.
      It appears that the first one should be used to tell the client to 
render 8
      channel audio, And the second one should verify for 2 channel audio. 
Is it
      the correct understanding ?
      - What is the proper way to handle format negotiation in apo for
      such cases? Or Is there a different approach to be followed ?



Thanks,

SK




Other related posts: