BelledonneCommunications / linphone-desktop

Linphone is a free VoIP and video softphone based on the SIP protocol. Mirror of git://git.linphone.org/linphone-desktop.git
https://linphone.org/
GNU General Public License v3.0
391 stars 200 forks source link

[Bug]: PulseAudio input stream has a bad audio quality. #810

Closed expeehaa closed 3 months ago

expeehaa commented 5 months ago

Context

I use linphone-desktop on Linux with a self-hosted freeswitch server. All other users use linphone-desktop on Linux as well.

General information

Expected behaviour

When talking, I expect that my sound is transmitted in the highest possible quality, which usually appears to have a rate of 48kHz. However, on the versions listed above, the audio seems to actually be upsampled from 8kHz. I conclude this from the following lines of the verbose logs about the creation of the capture audio stream (HEXCODE is a replacement I made for improved diffing; should not be relevant anyway).

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

For some reason, the PulseAudio stream opened with 8kHz instead of 48kHz even though the input device supports the latter. The output stream uses 48kHz, as expected.

To Reproduce

  1. Configure a PulseAudio capture device.
  2. Start a call.
  3. Listen to the call on the receiving end.

Additional context

The issue did not appear on openSUSE Leap 15.4 with linphone-desktop 4.3.2 and SDK version 5.0.53 and the same PulseAudio 15.0 as on Leap 15.5. I found that mediastreamer2 initializes a new PulseAudio stream with a sample rate of 8kHz (https://gitlab.linphone.org/BC/public/mediastreamer2/-/blob/f3d54cacde819bec31e4ce818c87dcc97a5e222b/src/audiofilters/pulseaudio.c#L339) and changing the 8000 in this line to 48000 indeed fixes the problem for me. However, I did not see any significant change in the file between the unaffected version 5.0.53 and the affected 5.2.x, and especially the linked line was not changed.

Given that I do not know the actual source of the problem, it appears highly unlikely to me that my change would fix the underlying issue or would even be accepted. I am also unsure of whether the problem is in mediastreamer2 or some other part of the application (maybe even in another external library).

SDK logs URL

No response

julonexus commented 5 months ago

Hi This line should not change: 8KHz is the "safe" format and it is used in case of issue like not able setting a rate. I reproduce the issue. We will check that. Thanks for your report

julonexus commented 5 months ago

Found it. It will be fixed into the SDK 5.3 (and so app 5.2.1). I'll close the issue when it will be available.