Tdesktop: Telegram keeps unnecessary handle on audio driver

Created on 31 Aug 2015  路  24Comments  路  Source: telegramdesktop/tdesktop

Not sure of the correct terminology here, but Telegram keeps the audio driver open for longer than it needs to (in Windows, at least). This is a HUGE pain for people who use programs that require the audio driver to be free (e.g., music producers using FL Studio, Pro Tools, etc.) In order for me to run FL Studio, I have to first go into the system tray to close Telegram, otherwise the ASIO4ALL drivers in FL Studio (and other DAW programs) don't work properly.

Telegram should instead open the audio driver, play a sound, then close it when it's finished.

bug

Most helpful comment

This is a massive problem on Linux. I use ALSA, and ALSA only supports one audio channel at a time. Due to Telegram being constantly open in the background for notifications, I have to run killall telegram in my terminal before I can start using audio in another application.

All 24 comments

Which version do you use?

It should be fixed with 0.8.22.dev (see #457)

But yes, there are still issues with the sound output and input (#418, #776, #783)

I have version 0.8.52.

It's still permanent.
Even worse, I played no sound (and the "play sound" setting in notifications is disabled), and telegram desktop can still be seen 24/7 in the windows mixer.

This is a massive problem on Linux. I use ALSA, and ALSA only supports one audio channel at a time. Due to Telegram being constantly open in the background for notifications, I have to run killall telegram in my terminal before I can start using audio in another application.

@ix That's strange :( I pause OpenAL device between notifications (when sound is not playing), so it should release the handle..

I don't even have notifications enabled. However, I don't have OpenAL installed; let me try installing it.

I can confirm this behaviour in version 0.9.15. On my Win7 laptop I have an integrated Conexant HD Audio soundcard. It has normally an auto power off feature that kicks in when no sound is played back. But it is not doing that as long as I have running Telegram. With the headphones I can hear the typical faint background noise of the soundcard until I quit Telegram by right clicking on the symbol in the notification area.

Another big problem with this is that it doesn't switch devices. I connect my bluetooth headset and I hear _everything_ but telegram. I missed some important messages because of that.

In other words, every time it plays a sound, it should open the default device, and close it when it's done.

I second j54n1n's problem. The audiocard on my laptop is rather awful, when theres open audiostreams like youtube video, music, videofile there's a hiss coming from the speakers. But it usually stops after some seconds when exiting whatever app or webpage that played something with audio.

However, when telegram is opened this hiss is there at all times. I would really like it, if this could be fixed. Telegram should just let go of the audio-stream when it's done playing a sound. Something which I actually rarely use in Telegram

I can confirm that, for Ubuntu 15.10, Ubuntu 16.04 and ArchLinux.

When using two different audio devices (e.g. Scarlet 2i2 USB with headphones connected and an HDMI-to-audio-jack connector) telegram results in issues with audio. The audio frequency is changed for _all devices_ by telegram.

That means sound playback is double as fast (probably 41kHz as audio sampling via USB is typically 21kHz) for all devices. You have to reboot your computer to get rid of that. Sometimes going back to sound settings in GNOME fixes the problem as they reload pulseaudio configuration, but often it doesn't fix it since the last updates.

Why does Telegram use ALSA / OpenAL and not say, pulseaudio or libSDL APIs? libSDL is battle-tested in the whole Steam world and is very common for cross-platform usage, so I'm wondering why all the OpenAL stuff is being reinvented in the audio.cpp.

Related issue is probably also #1573

@cookiengineer Switching APIs may solve it for PulseAudio users, but the problem is still there for ALSA and Windows users. The problem is that Telegram, for most use cases, is completely silent most of the time, so it makes no sense keeping the audio device open at all times, or not switching devices when you connect another device. When someone sends me an audio message I have to use the phone to hear it (even if I disconnect the headphones to go back to the initial device), or to restart Telegram in the PC.

@DiThi That's why I was mentioning SDL in the first place. The APIs there are pretty neat as they are cross-platform for all OSes and have simple OpenAudio/CloseAudio methods.

See: https://wiki.libsdl.org/SDL_OpenAudioDevice

Does it switch devices automatically? Then it's a good suggestion, although it wouldn't solve all.

My suggestion is just to close the device, and open the default device when it has to play sound. It would fix all problems mentioned in this thread.

@DiThi Yes and it supports pretty much every sound daemon you can imagine: https://hg.libsdl.org/SDL/file/aa9904a56acf/src/audio

In my case (pulseaudio) it also correctly tests different audio formats without overriding them to the device itself.

@cookiengineer that's not my point. I know that it supports many audio APIs, and that PulseAudio allows you to change frequencies and devices seamlessly. But if the application is in Windows (or using ALSA) and it doesn't release the audio device, it won't support switching devices on the fly. That's sort of OK for old games or multimedia applications (annoying, but understandable), but not for an application that is open 24/7. I don't want to restart it every time I connect the bluetooth headset so I can hear notifications and voice messages.

Even worse, after turning the heatset off, it doesn't even play on the original device anymore.

So I've seen issues from more then a year ago describing this BUG, and it's still not fixed..

It's incredibly annoying on a laptop. When I plug my headset in, the audio still comes from the speakers. Never ever have I seen this behavior on other software!

I would also like being able to dock my laptop without having to restart Telegram to get the right sound output... and be able to change record input etc, without having to restart the program... moreover, the constant hook on the audio driver makes my speakers hizz. With all other programs, that only happens when audio is actually being played.. alas, I'm probably alone with that, just saying it would be really nice to have this fixed.

I also think that it is important BUG to fix. It blocks the sound card and needs more power from the device especially on laptops/tablets. It is annoying...

Hi all.
Version 0.9.56 - Windows 10

Have to exit Telegram to free up audio driver for other applications like Fruity loops.

Any solutions available?

I add a problem.
With Telegram open, on my notebook the sound is scratchy (seems a problem with the speakers). I have to completely close TG to have a clear sound

Confirm.

ArchLinux with ALSA here. Output device is NVidia HDMI sound via DisplayPort.
When TG is running, no single application is able to play a sound. It says that device is doing really serious business (busy). Web browsers, media players, games, any of the apps that uses ALSA throw an error. So even to watch Youtube I have to terminate TG.

Even worse when I'm using my Win10 setup which is a KVM guest with GPU and sound passed through PCIe natively. When TG is running and some thing touches the sound device it makes a repeating sound like something hanged while playing. That sound can't be stopped even after TG shutdown, only reboot helps.

Confirm.

Cannot start jackd when telegram is running.

@drdrdr Please try the latest alpha version 1.0.3 from the bottom of https://desktop.telegram.org/changelog#alpha-version page. It is not holding any audio device opened while it is not playing audio.

@john-preston Thank you! Now jackd works with telegram

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TotalKrill picture TotalKrill  路  3Comments

DRSDavidSoft picture DRSDavidSoft  路  3Comments

LeonTheOriginal picture LeonTheOriginal  路  3Comments

Liudvikas picture Liudvikas  路  3Comments

hosseinab picture hosseinab  路  3Comments