Created attachment 224380 [details]
There are patches to build alsa and media session. I plan on sending them upstream this week. This depends on 245321, media session requires alsa-lib >=1.1.7. Media session also has flatpak/xdg-portal related code, this might be useful for these.
PipeWire clients e.g. pw-cat pw-play can play sound via alsa backend with edited pipewire.conf to include alsa static sink adapter pointing to "pcm.default" (see asound.conf & posted known working config next). Pulse clients do not work yet because the pipewire-pulse daemon gets wrong audio formats from pipewire.
PIPEWIRE_DEBUG=5 is too verbose, the only catch for now is pipewire-pulse reports sink-name "null", but it seems that "null" means to use the default sink from pipewire; pactl confirms that the default sink is used. I plan to continue debugging this next weekend, the PR is here to make sure that the progress does not block on me.
If sound does not work after configuration change that was faulty, make sure that ~/.config/pipewire is rm'ed. PipeWire restore-session wasted a lot of my time before this was found out.
If one wants to build jack, then version >=1.9.10 is needed (bug 251125).
SDL2 is disabled because it is needed only for tests and gets enabled if devel/sdl20 is installed. If one wants to build it anyway, then make sure to add localbase to USES.
TODO: find out where the LD_PRELOAD libs are and/or how to build them, check if static alsa source (microphone) can be configured, xdg-desktop-portal stuff, OSS backend.
FreeBSD 14 poudriere bulk && poudriere testport w/ all options sets: OK.
Created attachment 224382 [details]
known good config for pw-play
It is great that you're working on this!
I'm not using PipeWire for myself, so I can't test your changes, but the patch seems fine overall.
Please, make sure to submit these changes upstream, it is pretty responsive. Also note that GitHub mirror  has Cirrus CI set up for testing FreeBSD builds (which is failing ATM). It'd be awesome if you fix it up, enable alsa and make sure it passes.
I'm a bit reluctant to push patches to the Ports repo and usually wait for a release that contains these changes. However, if you wish, I can commit it right away. Let me know what you prefer.
And thanks again for working on this.
(In reply to Gleb Popov from comment #2)
> Let me know what you prefer.
The latter (wait for a release that contains these changes).
> make sure to submit these changes upstream
> fix it up, enable alsa and make sure it passes.
I'll check this next week.
(In reply to Evgeniy Khramtsov from comment #3)
> The latter (wait for a release that contains these changes).
Great that we're agree on this. Feel free to get me on the hook when submitting a GitLab merge request.
(In reply to Gleb Popov from comment #4)
I've just built the master branch: https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/632
Nice. Can you also please fix GitHub CI? It should be as easy as adding gettext stuff to .cirrus.yml file.
It'd be also great if you enable alsa for CI.
(In reply to Gleb Popov from comment #6)
Sure, this is planned for the next week, currently away from the FreeBSD machine...
I’ll see next week if CI can build the new alsa before building the pipe. If it can’t, then the new alsa-lib has to hit the ports tree first before the CI changes.
I’ll add the alsa bug to the depends of this bug.
(In reply to Gleb Popov from comment #6)
To build with alsa, the CI has to build the new alsa-lib locally (waiting for 245321 to land into ports would be too long). I'll add alsa to the CI tomorrow.
(In reply to Evgeniy Khramtsov from comment #8)
I'd rather wait for alsa update to be committed, but if you have spare time - why not?
(In reply to Gleb Popov from comment #9)
Building alsa-lib locally is PITA, even with 'make -d x' commands from the port build pasted directly.
I resolved this via minimal ports tree (e.g. audio/alsa-lib only and several Mk related dirs) in the compressed archive.
I'm kinda slow to reply/open pages/commit, nat64.net is overloaded for some reason today :D
1. Commenting 'restore-stream' in configuration files results in much improved debug information, and also gets rid of cached configuration and negotiations in ~/.config/pipewire.
2. ALSA OSS plugin abuse does not work with pipewire-pulse due to the default configured values (ex. default.clock.rate). Configuring audio.format for alsa sinks breaks format negotiation (audioadapter.c negotiate_format()) the same way for pw-play as with pipewire-pulse. The same applies to pipewire alsa, it gets configured by default, so aplay via pipewire does not work due to defaults.
3. Doxygen documentation seems to be misleading on format negotiation because it focuses on streams.
4. Continuing to abuse pcm.plug:oss is the wrong way, because PipeWire ALSA SPA plugin inserts a converter after format negotiation, which is an another can of worms if we abuse the oss plugin in alsa. No further progress in ALSA OSS abuse anymore.
To use pipewire as a pulseaudio replacement, one should write an OSS SPA plugin.
And also, this patch misses alsa-plugins, which has the required library for ALSA OSS abuse... This doesn't matter, because alsa-plugins is not needed for media session, so the patch is not updated.