[RFC] ao_wasapi: add Windows Spatial Audio output - #18389
Conversation
fa4ae3a to
16c4d16
Compare
|
Does is have to be separate AO? It complicates what normally would be auto negotiation of channel layout on output to user having to select specific AO. I would see this as an extension for WASAPI to support, non standard layouts. However, another question is, is WASAPI (non-spatial) still useful, if all channels can be sent as static objects? Is the rendering differs? Are those AO interchangeable or complementary to each other? |
I don't think it has to be separate. I kept it separate mostly so I They aren't completely interchangeable though. Static objects still go I think folding this into |
That's the main concern. I don't know either. It could be an option to use/prefer spatial even for standard layouts. But frankly I don't know at this point, I would have to dig into it. I also don't want ao_wasapi.c becoming a mess, if those two apis are really not sharing much of the code. In short, we need to think about the nominal cases. Food for thought, I myself not sure yet, what is the best approach here. |
OpenAL Soft has a useful example for this. It keeps one WASAPI backend, I think that could work here too. The spatial implementation could stay I don't think channel layout alone is enough to select it automatically, |
|
Hmm, technically
If it's explicit preference, separate AO is fine too (maybe not even called wasapi). So whether it's separate AO or an option, doesn't matter for user. The end result would be the same. So, the only consideration is code duplication and overall organization. It sounds like it will be easier with separate AO, but if there are shared code and functions they should be shared in common code. |
|
Yeah that makes sense. Most of the code is specific to |
The regular WASAPI output is constrained by the endpoint's configured
audio format and channel layout. This couples mpv's output layout to the
endpoint configuration rather than the capabilities exposed by Windows
Spatial Audio.
Add an opt-in output based on ISpatialAudioClient. It maps decoded PCM
channels to static spatial objects and leaves the final rendering to
Windows for the selected output device.
Keep the driver outside normal auto-probing. It accepts decoded PCM
only, rejects passthrough and exclusive mode, and can be followed by
regular WASAPI as a fallback:
--ao=wasapi-spatial,wasapi
Reuse the Windows device enumeration, selection, and loading helpers
used by WASAPI so --audio-device behaves consistently between the
outputs. Handle start, pause, reset, and shutdown on a dedicated render
thread.
This does not preserve Dolby Atmos or DTS:X object metadata. It submits
the decoded channel bed as static Windows Spatial Audio objects.
Implements the static-object part of mpv-player#11306.
16c4d16 to
4ada82a
Compare
|
Peanut gallery here: cheers for the wall-of-text edit. |
This adds an opt-in Windows Spatial Audio output using
ISpatialAudioClient.The regular WASAPI output uses the format and channel layout exposed by
the selected endpoint. In some setups, that means decoded surround audio
gets remixed before Windows Spatial Audio sees the original channel
layout.
wasapi-spatialinstead sends decoded PCM channels to Windows as staticspatial audio objects. Windows then renders those objects for the selected
output device. This makes the backend useful with headphones, surround
speaker systems, home theater endpoints, and supported layouts with
height channels.
The new output stays out of the normal auto-probe order. It can be
selected explicitly while leaving regular WASAPI as a fallback:
It reuses mpv's existing Windows audio device enumeration, selection,
and loading helpers, so
--audio-devicebehaves the same way as it doeswith the existing WASAPI output. The backend handles start, pause, reset,
and shutdown on its own render thread.
The backend accepts decoded PCM only. It rejects exclusive mode and
compressed passthrough. It also does not preserve native Dolby Atmos or
DTS:X object metadata. If those formats are decoded before reaching the
backend,
wasapi-spatialreceives the resulting channel bed and submitsthat to Windows as static spatial audio objects.
I tested this through Plezy, a libmpv frontend, on Windows with
multichannel content. Windows received the surround channel bed without
exclusive access, and normal endpoint processing remained available. I
have not tested every output device or Windows spatial renderer, so I am
submitting this as an RFC.
This implements the static-object part of #11306.
I used AI assistance for parts of the Windows API research and while
preparing the patch. I reviewed the resulting code, tested the behavior
described above, and understand the changes I am submitting. I take
responsibility for the contribution and confirm that the code can be
submitted under the same license as the files it changes.