Repository navigation
Audio pipeline: simplify the tree with WorkingAudio2WorkingAudio - #1676
Merged
Merged
Conversation
The FFT and sink branches of AudioPassthroughPairQt used to hand-wire ChannelMixer and AudioResampler nodes per conversion need. They now build a single WorkingAudio2WorkingAudio node (mix + resample, in the order chosen by channel count) when a conversion is needed, and fall back to a direct connection when the source already matches the target shape (48 kHz mono for the FFT branch, the device's native shape for the sink branch), preserving today's no-conversion path bit-for-bit. The INTERLEAVE_RL_96000 swap keeps going through the node's weight matrix, exactly as the sink mixer did. Also hardens ChannelMixer::push_samples(): mix_channels() strides its output buffer at the buffer size, so pushes larger than the buffer previously corrupted adjacent channel regions and wrote past the end of the buffer. The decoder always chunked to its own buffer size, so the live tree never hit this, but the all-in-one node (and any future direct consumer) must not rely on that. push_samples() now chunks internally. Pinned by MixerOverBufferPushTest. Adds Working2WorkingOrderTest: feeds identical input through the node and through the hand-wired chain of the same kernels (in the node's internal ordering, mix -> resample or resample -> mix) and asserts bit-identical output, for both orderings, the mix-only cases, and the identity-matrix + resample case. Pushes deliberately exceed the mixer's buffer size to exercise the chunking.
Mysticial
pushed a commit
that referenced
this pull request
Oct 22, 2026
…on (#1671) * Audio pipeline: rebase the working-stream path onto the new node API. Rebased #1671 onto main (incl. #1674's AudioFormat / WorkingAudio2WorkingAudio and #1676's tree simplification), and rewrote the attach path around the per-listener conversion node: - AudioPassthroughPair gains add_listener(const AudioFormat&, WorkingAudioStreamListener&) / remove_listener(WorkingAudioStreamListener&). The Qt pair builds one WorkingAudio2WorkingAudio per attached listener (source shape -> the requested shape), plus a small forwarder that carries the requested shape as its nominal one (the node validates its listeners against that; the user's listener may have any nominal shape of its own). Entries survive tree rebuilds: the nodes are rebuilt for each new source shape in build_tree() and detached in teardown_tree(). The INTERLEAVE_RL_96000 channel swap is applied to the node's matrix, the same way as for the sink branch. Unresolvable layouts are logged and skipped rather than thrown from the calling thread. - StreamHistorySession now implements both listener interfaces: the legacy AudioFloatStreamListener::on_samples path stays exactly as it was (kept until #1563 switches off it), and the new WorkingAudioStreamListener::push_samples re-interleaves the planar working stream at the active preset's physical shape (the shape its tracker records at; the RL swap already applied by the pair's node). The session attaches at start() and re-attaches in post_input_change(), removing the old-shape attach first so no push in the old shape can ever race the shape update. While both paths are attached the tracker is fed by both (double-record) - inert in the active tracker, and #1563 drops the legacy attach when it switches. - The console wires it up: set_audio_session() before start(), and the working-listener remove in try_shutdown(). Verified: -Werror clean on aarch64; full command-line suite green. * Audio pipeline: define InternalWorkingListener before its first destruction. remove_listener() destroys a WorkingListenerEntry (m_working_entries.erase) at its call site, which instantiates ~unique_ptr<InternalWorkingListener>() there. The nested class was defined further down in the .cpp, so on GCC 15 (x86 CI) the deleter's sizeof static_assert fired on the incomplete type. aarch64's older GCC instantiated it lazily enough to miss it. Moved the definition above the first member-function body so the type is complete at every destruction site in the translation unit. Pure reordering, no behavior change. --------- Co-authored-by: PA Dev Bot <344001113+pa-devbot@users.noreply.github.com>
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.
First of the tree-redesign steps built on #1674's
WorkingAudio2WorkingAudio.Tree simplification
AudioPassthroughPairQtno longer hand-wiresChannelMixer+AudioResamplerper branch:WorkingAudio2WorkingAudio(source shape -> 48 kHz mono) when a conversion is needed; direct decoder->FFT-node connection when the source is already 48 kHz mono (unchanged, bit-for-bit).WorkingAudio2WorkingAudio(source shape -> the device's native shape) when a conversion is needed; direct decoder->encoder connection when the shapes already match. TheINTERLEAVE_RL_96000swap still goes through the node's weight matrix, as before.Four node members become two (
m_fft_conv,m_sink_conv); teardown order is unchanged in effect.Latent OOB in ChannelMixer (found while verifying the node)
mix_channels()strides its output buffer at the buffer size, butChannelMixer::push_samples()passed the whole push through in one call: any push larger than the buffer (4096 + 256) overwrote the neighboring channel's region and wrote past the end of the aligned buffer. The decoder always chunked to its own buffer size, so the live tree never hit it - but the all-in-one node (and the listener path that will push user-sized blocks in #1563) must not rely on that.push_samples()now chunks internally; output for conforming pushes is unchanged. Pinned byMixerOverBufferPushTest.New tests
Working2WorkingOrderTest(5 cases): identical input fed through the node and through the hand-wired chain of the same kernels in the node's internal ordering (mix -> resample, resample -> mix, mix-only x2, identity-matrix + resample), asserted bit-identical. Pushes deliberately exceed the mixer's buffer size to exercise the chunking.MixerOverBufferPushTest(3 cases): single over-buffer push through an identity mixer, bit-exact vs the input.Verification
-Werrorclean, full command-line suite 18,215 passed / 0 failed (was 18,207 on main; +5 node + 3 mixer).