Skip to content

Audio pipeline: WorkingAudioStreamListener path to StreamHistorySession - #1671

Merged
Mysticial merged 2 commits into
mainfrom
audio-working-path
Oct 22, 2026
Merged

Mysticial merged 2 commits into
mainfrom
audio-working-path

Conversation

@pa-devbot

Copy link
Copy Markdown
Collaborator

Adds a parallel listener path that taps the pipeline tree's working stream, alongside the legacy AudioFloatStreamListener path. The legacy path is left fully in place (punted) until PR #1563 moves off of it. +149/−22.

The path (AudioPassthroughPair.h, AudioPassthroughPairQt, AudioPassthroughPairQtThread, AudioSession):

  • add_listener(WorkingAudioStreamListener&) / remove_listener() on the pair (overloads alongside the float/FFT ones); AudioSession::add_working_stream_listener() / remove_working_stream_listener().
  • Taps the tree at m_source_decoder's output via a per-tree InternalWorkingListener (created in build_tree() with the decoder's physical shape, destroyed in teardown_tree() before the decoder — same lifecycle pattern as the branch heads and InternalFFTListener).
  • What a working listener receives: the tree's working float stream — split (planar) channels at the source's physical rate/channel count, with the input volume already applied. push_samples(samples, stride, data): channel c starts at data[c*stride] and runs samples floats (stride may be 0 for the 1ch passthrough). The per-tree tap has the exact shape (validated by the decoder); the pair's listener set does not validate, so persistent listeners are safe across input changes.

Carried to StreamHistorySession: it now implements WorkingAudioStreamListener (instead of AudioFloatStreamListener) and ConsoleSystemSession attaches it through the new path (add_working_stream_listener / remove_working_stream_listener). The session:

  • re-interleaves the planar stream for the tracker, applying the INTERLEAVE_RL_96000 channel swap (matching the legacy reader's reverse_channels);
  • re-derives the active shape from the preset's physical working-stream shape on input change. The tracker's audio args now match what the tree delivers — this corrects two latent mismatches: DUAL_44100 was misreported to the tracker as mono, and MONO_96000 was framed as 2-sample frames @ 48000. The active tracker's audio handling is dormant (#if 0), so this is inert today but correct when it's revived.

Not changed (punted for #1563): AudioStreamToFloat, SampleListener, m_stream_listeners, AudioSession::add_stream_listener() — all still present; the reader now simply has no consumers. See the companion hand-off doc PR for the migration plan.

Verified: -Werror clean, full suite 18,207/0 (aarch64).

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.
…uction.

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.
@Mysticial
Mysticial merged commit 3524a8f into main Oct 22, 2026
7 checks passed
@Mysticial
Mysticial deleted the audio-working-path branch October 22, 2026 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants