-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Native pipewire AO #9587
Native pipewire AO #9587
Conversation
You might also want to make docs changes. |
@etircopyh I added a mention to the manpage. It's really tiny, but there is not much to document. |
@@ -87,6 +88,9 @@ static const struct ao_driver * const audio_out_drivers[] = { | |||
#endif | |||
#if HAVE_SDL2_AUDIO | |||
&audio_out_sdl, | |||
#endif | |||
#if HAVE_PIPEWIRE | |||
&audio_out_pipewire, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nitpick. Why is pipewire placed under wrappers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal was to make it explicitly opt-in, to give it some time to stabilize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. Makes sense, especially with this issue not being resolved.
Trying to figure out why I'm having much lower volume with ao_pipewire. The funny thing it only occurs on my KDE setup, the Sway one doesn't have the problem. And I don't know what's the culprit. I have two separate installations of Arch on my laptop. KDE has the volume issue and Sway doesn't. I even tried to run mpv with --no-config, no luck. UPD: The cause seems to be |
@etircopyh Please make sure you are modifying |
@etircopyh Please test with the latest commit on this PR. |
No, it doesn't work with this property and it won't. PW_KEY_NODE_RATE is used to suggest a sample rate. Here's some changes: ao_pipewire-mpv.patch.txt |
@etircopyh Is this patch supposed to fix the issue or just do some cleanups? |
It does fix the issue and doing a bit of cleanup along the way. It does not interfere with anything. You can reproduce the issue with current state of PR with playing some 44.1 kHz file and running And yeah, you need to have 44100 in your allowed-rates in your |
It's the part that sets PW_KEY_NODE_RATE as I said before. |
Thanks for the information. I messed up A few more questions:
|
As far as I understand it's supposed to make life easier for people that have no device node or are playing around with virtual sinks/sources, like connecting them together, etc. Some explanation. It seems like there's more to come on this one.
I kind of looked it up but I think it's to make sure these properties don't collide with ones that pipewire sets. Because pw_properties_set() does set a property and overrides it. |
Good, thanks for the explanation!
Yes it would replace existing values. But as we are constructing the properties from scratch there should be no conflict. |
Just wanted to say I've been testing this patch since the latest changes, and while I can't comment on the code, I can say it works as advertised. No audio glitches as far as I can tell. Hopefully someone will have time for a more thorough review soon. Thank you for making this PR. |
Well, as soon as the issue resolved I hope this PR will make it to upstream, more so as prioritized AO if pipewire is driving audio. |
I've been using this for a couple of weeks now (after experiencing the mentioned issue about detecting if pipewire will be useful or not...) and it's been working as well as the pulse AO for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm no pipewire expert, but the change looks reasonable from an mpv perspective, and it's worked fine in my local testing.
Can you squash all the changes please. This should only need to be one commit. |
ae7efa4
to
e9a44b1
Compare
@philipl Done. |
Perhaps we are looking at similar symptoms. Maybe the issue here is that the quantum calcuation is off? @t-8ch Can you push another branch with the buffer size still being managed by size rather than time? Maybe I didn't notice the juddering before because that was testing before that change (which I admit I asked you to do :-P) |
@etircopyh Did you test the latest state including 158d0f5 for pausing and seeking? |
@t-8ch yes, I'm currently testing with latest PR changes.
It seems to be kind of "just in case" value. Here's a comment from OpenAL code. |
The default is 100ms. |
No, I don't think so. |
@t-8ch If I revert the change to express buffers in miliseconds, the juddering goes away. So it's clearly related to that. Did you set the default to keep the total buffer size the same? Or does it result in a different (larger) buffer. As I noted previously, a small buffer (I tested with 10ms) does not judder, while the default value does, and larger buffers judder more badly. I notice @etircopyh said OpenAL had the smallest default buffer size and the best performance in his tests. Maybe that's related. So, it's not clear if the problem is with the calculation or that big buffers are bad. |
@philipl The previous default was 2048 samples. The current default is 100ms, so probably 4800 samples. |
Isn't it considered that buffer for communicating with PW needs to be as small as possible while internal buffer may be whatever app wants ? Meaning that sane values would be somewhere around 4-24ms. OpenAL defaults to 20ms so it's on a safe side from both missing its time-frame and being too unwieldy. |
Yea, 20ms is smooth for me. I remain confused that @t-8ch can't see anything wrong at higher buffer sizes but if it's more correct to have the small buffer, then let's just make 20ms the default and be happy with that. |
@philipl Sounds good, it's commited. I'll rebase before the final merge |
Thanks. Let's give it a few more days to see if we get any more feedback. |
Tested this PR on a few videos while debugging pipewire issue https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1200 No visible/audible problems so far, at least to my untrained eyes and ears. |
Edit: nvm, I see, this is a pipewire issue, not an issue with the AO |
Is there any way you could add |
The AO provides a way for mpv to directly submit audio to the PipeWire audio server. Doing this directly instead of going through the various compatibility layers provided by PipeWire has the following advantages: * It reduces complexity of going through the compatibility layers * It allows a richer integration between mpv and PipeWire (for example for metadata) * Some users report issues with the compatibility layers that to not occur with the native AO For now the AO is ordered after all the other relevant AOs, so it will most probably not be picked up by default. This is for the following reasons: * Currently it is not possible to detect if the PipeWire daemon that mpv connects to is actually driving the system audio. (https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1835) * It gives the AO time to stabilize before it is used by everyone. Based-on-patch-by: Oschowa <oschowa@web.de> Based-on-patch-by: Andreas Kempf <aakempf@gmail.com> Helped-by: Ivan <etircopyhdot@gmail.com>
Sorry, I missed this comment. Yes that's possible, I have a halfway done branch for it.
Done |
@t-8ch Thanks so much for working on this and addressing all the feedback! Please open a new PR for the |
Sometimes the most obvious things can be missed. Reflects authorship described in the original commit. * #7902 * Oschowa@fddb143 * #9587
Does it output audio to pipewire by default? |
It does not. You need to specifiy |
There is now a mostly-functionial PR for the device selection at #9734 |
This PR adds a native AO for pipewire and closes #8569.
The original code has been written by @Oschowa which was extended by me. (See the different commits)
@Oschowa did not propose the PR themselves as they were experiencing vsync jitter with this AO.
For other users however this AO works as good as or better than the existing ones, and they have been using it for some time with custom builds.
When running on a native pipewire system this AO saves intermediate steps through libpulse and pipewires pulseaudio server.
set_pause
uau
wonders if there is a problem in accurately reporting the remaining buffered audio.