Bug 523693 - Hardcoded 44.1kHz sample rate in MicrophoneTest causes unnecessary PipeWire clock rate switching
Summary: Hardcoded 44.1kHz sample rate in MicrophoneTest causes unnecessary PipeWire c...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Audio Volume widget (other bugs)
Version First Reported In: 6.7.3
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-07-31 10:14 UTC by Dan
Modified: 2026-08-17 18:54 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 6.8.0
Sentry Crash Report:


Attachments
Query native sample rate from source instead of hardcoding 44.1kHz (3.45 KB, patch)
2026-08-12 20:07 UTC, Dan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dan 2026-07-31 10:14:39 UTC
In plasma-pa's MicrophoneTest component, the sample rate for recording and playback is hardcoded to 44.1 kHz (constexpr int SAMPLE_RATE = 44100;).  When performing a microphone test, this hardcoded rate forces audio servers like PipeWire to switch the stream/node clock rate to 44100 Hz. For microphones and devices operating natively at 48000 Hz (or higher), this triggers unnecessary resamplers or clock rate switching across the audio graph.

Steps to reproduce:

1. Use an audio interface or microphone operating at 48000 Hz on PipeWire.

2. Open System Settings -> Sound and initiate a microphone test.

3. Observe the PipeWire graph / stream properties (pw-top).

Expected behavior:

MicrophoneTest should query and use the native sample rate of the selected source (m_source) rather than enforcing a fixed 44.1 kHz rate.  

Proposed solution:

Query the native sample rate from PulseAudioQt::Source / m_source during startRecording().  

Store the detected sample rate and pass it to pa_sample_spec for both recording and playback streams (startRecording and playRecording).
Comment 1 Nate Graham 2026-08-12 19:27:12 UTC
Good find. Would you like to submit a patch to change that?
Comment 2 Dan 2026-08-12 20:07:28 UTC
Created attachment 195100 [details]
Query native sample rate from source instead of hardcoding 44.1kHz

Ok Nate, here's the patch. Thanks!

***

Use the source's native sample rate for the microphone test

MicrophoneTest hardcoded the record/playback sample rate to
44.1 kHz. When the selected source (m_source) actually runs at a
different native rate — 48 kHz being common with PipeWire — this
forces the audio server to switch the stream/node clock rate for
the whole graph, triggering unnecessary resampling.

Query the source's native sample rate via
pa_context_get_source_info_by_name() before starting the record
stream, and reuse the detected rate for both the record and the
playback pa_sample_spec. The previous synchronous stream setup is
now split into startRecording() (kicks off the async query) and
beginRecording() (does the actual stream setup), invoked from the
source_info_callback(). Falls back to the previous 44.1 kHz default
if the query cannot be issued.

BUG: 523693
Comment 3 Nate Graham 2026-08-12 20:09:02 UTC
Thanks, but how about in the form of a merge request over at https://invent.kde.org/plasma/plasma-pa/-/merge_requests/?
Comment 4 Dan 2026-08-12 20:10:29 UTC
(In reply to Nate Graham from comment #3)
> Thanks, but how about in the form of a merge request over at
> https://invent.kde.org/plasma/plasma-pa/-/merge_requests/?

Ok, I'll do it.
Comment 5 Bug Janitor Service 2026-08-12 20:48:56 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-pa/-/merge_requests/418
Comment 6 Nate Graham 2026-08-17 18:54:24 UTC
Git commit 459256d5482cab598da6e87642e72dffa93a99c9 by Nate Graham, on behalf of Dan Fi.
Committed on 17/08/2026 at 18:54.
Pushed by ngraham into branch 'master'.

Use the source's native sample rate for the microphone test

MicrophoneTest hardcoded the record/playback sample rate to
44.1 kHz. When the selected source (m_source) actually runs at a
different native rate — 48 kHz being common with PipeWire — this
forces the audio server to switch the stream/node clock rate for
the whole graph, triggering unnecessary resampling.

Query the source's native sample rate via
pa_context_get_source_info_by_name() before starting the record
stream, and reuse the detected rate for both the record and the
playback pa_sample_spec. The previous synchronous stream setup is
now split into startRecording() (kicks off the async query) and
beginRecording() (does the actual stream setup), invoked from the
source_info_callback(). Falls back to the previous 44.1 kHz default
if the query cannot be issued.

Test Plan:

Tested microphone test with a source running at 48 kHz
on PipeWire; confirmed via `pw-top` that the node clock rate no
longer switches to 44100 Hz during the test. Also verified the
fallback path (default 44.1 kHz) still works when the source info
query fails.
FIXED-IN: 6.8.0

M  +44   -3    src/microphonetest.cpp
M  +6    -0    src/microphonetest.h

https://invent.kde.org/plasma/plasma-pa/-/commit/459256d5482cab598da6e87642e72dffa93a99c9