Skip to content

pipewire-plugin: fix capture and concurrent playback issues - #30

Open
tkanfade wants to merge 3 commits into
AudioReach:masterfrom
tkanfade:fix/capture-playback-issues
Open

tkanfade wants to merge 3 commits into
AudioReach:masterfrom
tkanfade:fix/capture-playback-issues

Conversation

@tkanfade

@tkanfade tkanfade commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

CRs-Fixed: 4395510, 4395054, 4394776

Three issues fixed:

  1. Fix capture producing silence
    The capture buffer size was too small, causing the DSP to
    reject every read request and return no data. Aligned the
    buffer size to match the PipeWire quantum size so the DSP
    always has enough data to serve each read.

  2. Fix incomplete/short recordings
    The audio capture was being driven directly from the
    PipeWire real-time thread which has a strict scheduling
    deadline. The DSP fills audio data slower than this
    deadline, causing the real-time thread to miss its
    deadline repeatedly. Over time PipeWire throttles the
    capture node resulting in very short recordings.
    Moved the DSP read into a dedicated background thread
    with a ring buffer in between, so the real-time thread
    only does a fast memory copy and never blocks.

  3. Fix playback muted when started during active capture
    When playback starts while capture is already running,
    the echo cancellation setup takes 13-27 seconds to
    complete. During this time the playback stream is not
    yet ready but audio data is already being sent to it,
    resulting in muted output for that duration.
    Moved the playback stream startup into a background
    thread so the real-time thread is never blocked. Audio
    data is held back silently until the stream is ready.

Tested on: LEMANS EVK (IQ-9075)

@tkanfade
tkanfade requested review from a team July 28, 2026 13:02
@tkanfade
tkanfade force-pushed the fix/capture-playback-issues branch 3 times, most recently from 90364b0 to 6ca0e1c Compare September 10, 2026 10:31
The capture buffer size was hardcoded to 512 bytes, which is too
small for the DSP. The DSP rejects every read request and returns
no data, causing the capture node to produce silence.

Align the buffer size to match the PipeWire quantum size
(PW_DEFAULT_CAPTURE_QUANTUM_FRAMES * frame_size) so the DSP always
has enough data to serve each read. Also reduce buf_count from 8
to 4 since larger individual buffers need fewer slots.

Tested on: LEMANS EVK (IQ-9075)

Signed-off-by: Tejas Vijay Kanfade <tkanfade@qti.qualcomm.com>
@tkanfade
tkanfade force-pushed the fix/capture-playback-issues branch from 6ca0e1c to afca793 Compare September 15, 2026 08:41
The audio capture was driven directly from the PipeWire real-time
thread which has a strict scheduling deadline. The DSP fills audio
data slower than this deadline, causing the real-time thread to miss
its deadline repeatedly. Over time PipeWire throttles the capture
node resulting in very short recordings.

Move the DSP read into a dedicated background thread
(pw_pal_reader_thread) with a power-of-two ring buffer in between.
The real-time process() callback now only does a fast non-blocking
memcpy from the ring buffer and never blocks on the DSP.

Tested on: LEMANS EVK (IQ-9075)

Signed-off-by: Tejas Vijay Kanfade <tkanfade@qti.qualcomm.com>
When playback starts while capture is already running, the echo
cancellation setup takes 13-27 seconds to complete. During this
time the playback stream is not yet ready but audio data is already
being sent to it, resulting in muted output for that duration.

Move the playback stream startup (pal_stream_start + volume set)
into a detached background thread (pw_pal_starter_thread). The
real-time process() callback sends silence until stream_ready is
set, so the RT thread is never blocked waiting for PAL.

Also handle the teardown race: if the stream is closed before the
starter thread finishes, stop_requested is set so the thread skips
the volume call and exits cleanly.

Tested on: LEMANS EVK (IQ-9075)

Signed-off-by: Tejas Vijay Kanfade <tkanfade@qti.qualcomm.com>
@tkanfade
tkanfade force-pushed the fix/capture-playback-issues branch from afca793 to e48bc13 Compare September 15, 2026 08:52
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.

1 participant