-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
pipewire full features #20483
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
base: master
Are you sure you want to change the base?
pipewire full features #20483
Conversation
While it's unlikely I would devote myself to writing any code for this, I have some ideas for you that may or may not help. I don't really know pipewire much, but it seems to me that a more "proper" way to implement this would be writing an "SPA plugin" (for oobe), but maybe writing "modules" is fine as well (maybe they don't really differ and it just depends on the complexity of your "implementation"; but I feel like you may want to figure it out first)
I think you might have asked the wrong question, and/or they didn't get what you really want to know.
What you need isn't a similar "message queue", but really just any way that allows you to pass a buffer pointer and the number of frames the Android side wants to the pipewire side, and ask pipewire to do the copy. (sles is a bit different, due to the design of the API; it expects you to pass a buffer pointer to it and tell it how much data it holds; note that it's still "pulling" though; just that it doesn't create the buffer for you or tell you how much it wants; I think oboe offers an interface that is more similar to aaudio) (The The sles and aaudio sink modules in pulseaudio work a lot like the jack sink module (from upstream). Therefore, I think at least potentially, you may want to implement the oboe support in a way like the jack tunnel module / client (what allows you to connect pipewire to a "real" jack server) / SPA plugin in pipewire. Either way, the point is, I think you'll still want to implement it in the "pull" manner anyway (as in, let the Android side "request" audio data from pipewire), instead of making pipewire "push" audio data to it. (AFAIK, you will eventually find that it's not possible to make it work well for different devices or audio device type with the latter approach. I could be wrong though.) It does seem that "architecturally" it would be significantly more complicated in pipewire (due to the design of it?) than in pulse. Either way, you may want to look at these code lines / sections first to get some idea regarding the "flow": https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/1.1.83/spa/plugins/jack/plugin.c?ref_type=tags#L24 As you can see, the JACK client in pipewire also register a callback to the JACK server: https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/1.1.83/spa/plugins/jack/jack-client.c?ref_type=tags#L9 I believe the last linked line would result in this method to be called: And finally, what the callback registered to Android side really need to trigger: It might be worth highlighting these lines to show that it is obviously possible to pass stuff from the callback to the actual function that calls the data copying function: https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/1.1.83/spa/plugins/jack/jack-client.c?ref_type=tags#L19 One thing I do want to note is that, AFAICT, |
Actually, maybe what you need to do is just eliminate (some of) the "client" bits (since in the Android case we are not exposed a single server that handles both audio input and audio output), but keep the "node" bits (instead of implementing the sink and source as "streams"), then open and start the aaudio / oboe stream at the very end of |
+ 'module-aaudio-source.c', | ||
+ 'module-aaudio-sink.c', | ||
+ 'module-oboe-sink.cpp', | ||
+ 'module-aaudio-sink.cpp', |
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.
Probably some typo here. module-aaudio-sink.c
and module-aaudio.sink.cpp
?
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.
Yes, I was aware of the typo and it was fixed it in the below dev branch. This branch is functional (uses oboe, accepts alsa/jack/pulseaudio clients and works with qpwgraph
) and is much better than the existing pipewire package sitting in termux-packages
.
https://github.com/termux/termux-packages/compare/master...knyipab:termux-packages:dev/pipewire-group?expand=1
But as indicated in the TODO list, it is far from being perfect. Most importantly, I do not have time to complete this work (likely will never have time to work on it). If you prefer, I can tidy it up a little bit for merging and at least some progress will be made. But you know, that is probably not a good consideration for maintainer.
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.
This is a huge amount of work already.
I think it'd be great if we can get that reorganized and merged, even if it's not the full solution.
Thank you a lot for putting in the time and effort.
As an active user of PW on desktop I'm quite happy about this work so far and would gladly help it move forward :)
IMO not necessary, in the pro-audio/jack world it's not expected that apps connect automatically by default, since often you'd manually want to wire them in a modular way (like audio plugins) or they internally allow the user to select an output (e.g. ardour).
Sounds reasonable, but is it actually possible to play back on multiple output devices simultaneously on Android? Further thoughts:
Anyway thanks for all your work, I'll look into compiling and testing this branch soon! |
Intro
We know that pipewire is the future of Linux audio. Pipewire could serve
pulseaudio
,jack
,alsa
(and probablygstreamer
) clients.This PR is currently more an initial attempt and also serves as a tracker. Cuz this initial attempt already consumed me a lot of time, I want to gauge whether devs are interested in this PR.
A screenshot of
qpwgraph
from my phone:What we have now in this PR
qpwgraph
that can play with software audio I/OTest script
pipewire
,wireplumber
andpipewire-pulse
.PULSE_SERVER=tcp:127.0.0.1:4713 vlc
PULSE_SERVER=...
can be dropped afterln -sfn $PREFIX/tmp/pulse ~/.config/pulse/[device-id]-runtime
mpv
in this PR as an example):pw-jack mpv --ao=jack test.wav
and then useqpwgraph
to feed that into oboe sinkaplay test.wav
andmpv --ao=alsa test.wav
prompts errorsTODO (tracking the staging
dev/pipewire-group
branch)Some of these TODOs I might have indeed raised in https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4032.
pa_asyncmsgq_send
equivalence).PULSE_SERVER=
. Soft linking$PREFIX/tmp/pulse
to~/.config/pulse/<device-id>-runtime
, reimplementing of this legacy fallback inpa_get_runtime_dir
(pulseaudio/src/pulsecore/core-util.c) because that part is not implemented by pipewire'smodule-protocol-native.c
qpwgraph
)-Dalsa=enabled
is really neededpwvucontrol
(await for wireplumber-5.0 support: Support wireplumber 0.5 saivert/pwvucontrol#10)helvum
(await for next release new package: helvum termux-user-repository/tur#1087)qpwgraph
(await forQSharedMemory
fix)pthread_cancel
patch topipewire-jack.c
. Currently jack client does not get killed properly whenmpv
is still connected andpipewire
exitspipewire-jack
subpackage (so it don't need to run command withpw-jack
), seems requiringjack2
or at least its/include
files (see Archlinux build script)pipewire-alsa
subpackageAudioManager.getDevices()
)ardour
audacity
shotcut
chromium
firefox
mpv-x
Off topic thought
Off topic but it would really be great to have a metapackage like
termux-desktop
to fire up the best practice software at once: Termux:X11, a DE, pipewire (this is where include the command combopipewire
,wireplumber
andpipewire-pulse
), CUPS, system-wide dbus, IME, and even mesa (and perhaps a functioninglibusb
in the future). The script should also clean everything up after user logs out or intercepts in the terminal with Ctrl+C. It could really save everyone's time for reinventing the wheel (for example, a usual Linux user may take quite some time to figure that three command combos to fire up a working pipwire, because pipewire is usually what Linux distros have done for us). It alsp helps to align a baseline settings for community's discussion and promote to new Termux users who may just want a full-fledged working Linux desktop.