Bug ID 1217096
Summary Linphone opens PulseAudio recording stream with lower sample rate than expected.
Classification openSUSE
Product openSUSE Distribution
Version Leap 15.5
Hardware Other
OS openSUSE Leap 15.5
Status NEW
Severity Normal
Priority P5 - None
Component Other
Assignee screening-team-bugs@suse.de
Reporter expeehaa@outlook.com
QA Contact qa-bugs@suse.de
Target Milestone ---
Found By ---
Blocker ---

Created attachment 870732 [details]
redacted excerpt from "linphone --verbose" during the creation of the recording
stream

On Leap 15.5, the recorded sound quality in Linphone calls has a low quality on
every tested device, even though the Opus codec with 48kHz sample rate is
specified. The sound quality was good before the systems where upgraded from
Leap 15.4. The same issue also appeared in Tumbleweed a few months ago. It does
not affect the received audio.

When joining a call, a recording stream is created, which prints the attached
output (redacted excerpt) using "linphone --verbose". Compared to Leap 15.4,
most notably the following lines appear different:

[Info]Core:linphone: configuring MSPulseRead:HEXCODE-->MSOpusEnc:HEXCODE from
rate [8000] to rate [48000] and from channel [1] to channel [1]

[Info]Core:linphone: pulseaudio record stream connected (8000Hz, 1ch)

It looks like the audio stream uses an 8kHz sampling rate, whereas on Leap 15.4
it uses 48000Hz. This specific log was created when using pipewire-pulse, but
the same result appears with pulseaudio.
The above logs are printed by the mediastreamer2 library, which is a dependency
of linphone. The second line is printed by
https://github.com/BelledonneCommunications/mediastreamer2/blob/5.2.9/src/audiofilters/pulseaudio.c#467.
In line 342 in the same file, the sample spec for the pulseaudio stream is
initialized with a rate of 8000. Changing this default to 48000 fixes the audio
quality issues and changes the quoted lines above to read "48000" instead of
"8000".
However, almost all of this file (including the sample spec) is the same as in
the sources for the version provided by Leap 15.4, which did not have this
issue. This means that the sound quality issues can be fixed by applying the
following patch before building mediastreamer2.

diff --git a/src/audiofilters/pulseaudio.c b/src/audiofilters/pulseaudio.c
index 68b53221..a0b2e40b 100644
--- a/src/audiofilters/pulseaudio.c
+++ b/src/audiofilters/pulseaudio.c
@@ -341,7 +341,7 @@ static Stream *stream_new(StreamType type, MSFilter *f) {
        s->type = type;
        s->sampleSpec.format = PA_SAMPLE_S16LE;
        s->sampleSpec.channels=1;
-       s->sampleSpec.rate=8000;
+       s->sampleSpec.rate=48000;
        s->state = PA_STREAM_UNCONNECTED;
        ms_flow_controlled_bufferizer_init(&s->bufferizer, f,
s->sampleSpec.rate, s->sampleSpec.channels);
        ms_flow_controlled_bufferizer_set_max_size_ms(&s->bufferizer,
flow_control_threshold);

But this does not explain, why it worked on Leap 15.4 before, and the patch may
not be universally applicable.


You are receiving this mail because: