Repository navigation
fix: complete PipeWire dynamic loading and channel mapping - #2
Closed
bot-for-imitoy wants to merge 10 commits into
Closed
bot-for-imitoy wants to merge 10 commits into
bot-for-imitoy wants to merge 10 commits into
Conversation
Add a new "PipeWire" AudioIODeviceType for Linux, driven by native libpipewire-0.3. Like the JACK backend, libpipewire is loaded dynamically at run-time, so no extra library has to be linked into the app, but the PipeWire development headers are required to compile with JUCE_PIPEWIRE enabled (which is off by default). The device type lists the sinks and sources of the PipeWire graph as separate input/output devices and reads the session manager's "default" metadata to pick sensible default devices. Opening a device creates a playback and/or capture stream, negotiates float32 planar audio, and runs the JUCE callback from a dedicated high-priority thread; full-duplex I/O is aligned to the playback block, with input data buffered by one block. This is a plain config flag: JUCE_PIPEWIRE can be set to 1 by any app that has the libpipewire-0.3-dev headers installed.
PipeWire always delivers string properties (node.name, node.description, object.path, port channels, the default-device metadata) as UTF-8, but the backend built juce::String objects from these with the plain 'const char*' constructor, which treats the data as single-byte ASCII/Latin-1 text. Any non-ASCII characters in a device name or description (e.g. a localized device description) were therefore shown as mojibake. Construct those strings with String::fromUTF8() instead.
The format negotiation events can arrive asynchronously after the streams are up, so before the first process callback the device currently reported a sample rate and block size of zero. Fall back to the values requested in open() so that host code which queries the device straight after opening sees sensible numbers.
Document the libpipewire-0.3-dev package which is needed to build JUCE with the PipeWire audio device type enabled, and add it to the full apt install command.
feat: Linux Pipewire support
PipeWire always delivers string properties (node.name, node.description, object.path, port channels, the default-device metadata) as UTF-8, but the backend built juce::String objects from these with the plain 'const char*' constructor, which treats the data as single-byte ASCII/Latin-1 text. Any non-ASCII characters in a device name or description (e.g. a localized device description) were therefore shown as mojibake. Construct those strings with String::fromUTF8() instead.
Document the libpipewire-0.3-dev package which is needed to build JUCE with the PipeWire audio device type enabled, and add it to the full apt install command.
- Clamp block sizes to each plane's capacity, honour chunk->offset and validate the buffer pointers, so a growing quantum can no longer read or write past a buffer. - Destroy the streams on the loop thread via pw_loop_invoke and drain in-flight callbacks before swapping the JUCE callback; the process path no longer allocates or locks, because all callback buffers are preallocated when the streams are created. - Report the real routed device by following the graph links, and refresh the stream node id once the stream is ready. - Bound the synchronous registry scan with a timeout and a core error handler, and convert pw_time.delay to samples correctly. - Detect a dead stream or server, notify the host via audioDeviceError and audioDeviceStopped, and rebuild the streams when the server returns. - Follow the session default sink and source when they change. - Watch the graph from the device type and inform listeners when the device list changes, including server loss and recovery. - Reset the xrun count when playback starts and make the shared state (sample rate, block size, error string) thread safe.
Pipewire support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two issues found during review of the PipeWire backend:
pw_stream_state_as_string, avoiding an unintended link-time dependency on libpipewireAlso includes the required raw channel type declaration for the channel-position conversion.