openal-soft
openal-soft copied to clipboard
Crackling Telegram notifications sound
Steps to reproduce
- Receive a message
Expected behaviour
I expect to hear a clean notification sound as Windows10's
Actual behaviour
Every Telegram notification start with a popping noise in my Linux system. I thought there may be an alsa/pulseaudio related problem with audio sleep for saving battery, but I hear them disturbed even if I have a music playing in the background or youtube playing on Chrome. I don't have this problem with other app or notification sounds.
I recorded the audio with OBD studio but the output is clean: https://drive.google.com/file/d/1tRkZRuqp49azhcDoJl83vzYBXuhyxAPn/view?usp=sharing
The laptop is new and it doesn't have speaker problem. I have it only with Telegram unfortunately.
Video proof: Linux: https://drive.google.com/file/d/1sWJZE_33-1tAXo_O0izc4p6TrxYafk1R/view?usp=sharing Windows: https://drive.google.com/file/d/1sZzUDrQBH8t4gVDayLAnD7f5X6L6EQiZ/view?usp=sharing
I used to get
[ALSOFT] (EE) Failed to set real-time priority for thread: Operation not permitted (1)
every time I heard the popping noise. I then added my user to audio group and created audio.conf
cat /etc/security/limits.d/audio.conf
@audio - rtprio 95
@audio - memlock 512000
@audio - nice -19
This fixed the errors but not the popping sound.
I'm also testing with the noitification mp3 uploaded in a chat and the only first play makes noise. Next (without pausing) plays are clear.
I opened a duplicate of https://github.com/telegramdesktop/tdesktop/issues/10591 because the Telegram devs confirmed tdesktop uses openal API on all platforms.
Configuration
Operating system: OS: Pop!_OS 20.10 x86_64 Host: Blade 15 Advanced Model (Early 2020) - RZ09-033 5.04 Kernel: 5.11.0-7612-generic Packages: 3056 (dpkg), 30 (flatpak) Shell: bash 5.0.17 Resolution: 2560x1440 DE: GNOME 3.38.3 WM: Mutter WM Theme: Pop Theme: Pop-dark [GTK2/3] Icons: Pop [GTK2/3] Terminal: gnome-terminal CPU: Intel i7-10875H (16) @ 2.300GHz GPU: Intel UHD Graphics Memory: 4118MiB / 15863MiB
Version of Telegram Desktop: 2.7.1 (official website)
Pulseaudio ( pactl list ): https://pastebin.com/9DGRd8U0 Alsa ( aplay -l ): https://pastebin.com/hyUS5Zv9
If you configure OpenAL Soft to use ALSA (instead of the default PulseAudio), does it still happen? Either set the ALSOFT_DRIVERS
env var to alsa
, or create/edit $HOME/.config/alsoft.conf
and add
[general]
drivers = alsa
This could be due to OpenAL Soft requesting PulseAudio to start playback before it has written anything, expecting the start to begin asking for samples to play. It might be that PulseAudio tries to start playing the stream before anything has been written, and plays a little bit of junk before realizing it needs to request samples. That's just conjecture on my part, but if using the ALSA API lets it start without popping, that would suggest something in that direction.
Yes, you get it! Adding alsoft.conf in my config fixed the problem.
Shall be this considered the right way to fix it or just a workaround? I'm also in contact with Telegram and PulseAudio devs and I wonder if I may close the other tickets as well. Thank you!
It's just a workaround. It ultimately sounds like a PulseAudio bug (it should make sure it has enough valid samples before starting), but I may be able to do something cleaner so you don't have to make OpenAL use the alsa->pulse wrapper.
I've just upgraded Pop!_OS to 21.04 and the crackling noise is back :/ The file alsoft.conf is still in .config folder but it doesn't seem to work anymore. Any idea why? Something changed between "Ubuntu" 20.10 and 21.04?
gorgo@pop-os
------------
OS: Pop!_OS 21.04 x86_64
Host: Blade 15 Advanced Model (Early 2020) - RZ09-033 5.04
Kernel: 5.11.0-7620-generic
Uptime: 3 hours, 33 mins
Packages: 3095 (dpkg), 19 (flatpak)
Shell: bash 5.1.4
Resolution: 2560x1440
DE: GNOME 3.38.4
WM: Mutter
WM Theme: Pop
Theme: Pop-dark [GTK2/3]
Icons: Pop [GTK2/3]
Terminal: gnome-terminal
CPU: Intel i7-10875H (16) @ 5.100GHz
GPU: Intel CometLake-H GT2 [UHD Graphics]
GPU: NVIDIA GeForce RTX 2080 SUPER Mobile / Max-Q
Memory: 3646MiB / 15862MiB
Can you get a trace log? Set the ALSOFT_LOGLEVEL
environment variable to 3
when you run the app and play a sound, and it'll print a log to stderr
(make sure it crackles, if possible).
I am not sure if this is related, since your description and sound samples seem quite different in detail, but try increasing period count in alsoft-config
to 4 or 6. This is basically just a multiplicator for the period size value, which gives you the total buffer size. A smaller buffer results in less latency, at the expense of possibly introducing crackling.
#763