JACK and PipeWire
We would like to have PipeWire take care of all audio devices but give an option to run JACK natively on demand.
For this we would use the DBus device reservation API. As soon as JACK claims the device, we release it and substitute our device for a jack client. We would probably need to know who claimed the device so that we can know what api to use.
From then on, PipeWire is a secure frontend for JACK. Sandboxed apps can use the jack emulation API to run in PipeWire while non-sandboxed apps run in the real JACK server. Because the PipeWire graph is driven by the JACK server, we can guarantee the same latency for sandboxed apps.
From JACK, PipeWire would look like another client with in and out ports. We could also make a new client for each PipeWire stream or even node if this proves to be interesting.
PipeWire JACK implementation
There is a drop-in replacement for libjack.so. Existing clients should work unmodified. All jack API calls are mapped to equivalent PipeWire calls. Jack clients can only see ports marked with the dsp tags. These ports provide and consume float32 audio in mono.
PipeWire control ports (which can carry MIDI events among other things) are exposed as JACK midi ports.
A PipeWire session manager should provide DSP nodes that interfaces with the audio device and mix audio on the inputs. Through the ports provided by this node, jack clients (or native clients using compatible ports) can connect to the devices.
Wakeup of jack clients is very fast with an eventfd. Jack clients mix the inputs on their ports locally and can wake up the next jack client directly by signaling its evenfd.
Session handling Is not implemented at all and is probably best handled by NSM.
How to test the current JACK support:
- you will need to check out the master branch
- run the pw-uninstalled.sh script to set up library paths or run 'make shell'
- modify pipewire.conf, make sure this line is uncommented at the end:
- restart pipewire, pw-mon should list a lot of new nodes nodes with ports marked with the format.dsp property set to the dsp profile.
- in a console run a simple client like:
- it should play a beep sound. You can use a tool like Carla to see the graph and add more nodes and connections.