-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix default device not respecting ducking rules bug and handle leak #33
base: tdesktop
Are you sure you want to change the base?
Conversation
os/windows/AudioOutputWASAPI.cpp
Outdated
@@ -216,8 +216,20 @@ void AudioOutputWASAPI::ActuallySetCurrentDevice(std::string deviceID){ | |||
|
|||
if(deviceID=="default"){ | |||
isDefaultDevice=true; | |||
res=enumerator->GetDefaultAudioEndpoint(eRender, eCommunications, &device); | |||
IMMDevice* temp_device; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks strange since all other variables are in camelCase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Y
If the problem is in GetDefaultAudioEndpoint, then just selecting the device itself instead of "default" in settings should solve the issue as well, does that solve it (i guess you need a version before video calls were added for the test)? |
Of course it won't occur since the stream is not a communication stream anymore and, therefore, call reducing feature is not called by the os. |
Looks like you just disabled the ducking feature entirely, didn't you? |
I think it could work.
I tested it and ducking does not work. You're right. |
I think the latest version of Because of this, and I found some informations about |
No, it uses WASAPI via webrtc
Yeah, and I guess it is better to leave it as is, since a lot of users except ducking
Oh, core developers are against adding new switches usually... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SpriteOvO:tdesktop
Issue: telegramdesktop/tdesktop#8192
For my network reasons I was unable to compile
tdesktop
's dependency libraryFFmpeg
, so I referencedlibtgvoip
and wrote a minimal test example that successfully reproduced the problem.In this line:
res=enumerator->GetDefaultAudioEndpoint(eRender, eCommunications, &device);
The problem only occurs in devices returned via
GetDefaultAudioEndpoint
witheCommunications
. If replaceeCommunications
witheConsole
oreMultimedia
, the problem will not occur.I think it's a Windows bug, but we can't fix it that way because the msdn docs say that the
role
argument may affect the returned default device in the future.But there is a workaround to fix it, that we just get the name of the default device from
GetDefaultAudioEndpoint
, and then callGetDevice
with the name to get the device.Some references:
https://social.microsoft.com/Forums/SECURITY/zh-CN/1b500f1e-744b-41d7-9c20-66ed83bda055/wasapi-stream-with-default-communictaions-device-does-not-trigger-ducking-for-other-applications?forum=windowspro-audiodevelopment
https://chromium.googlesource.com/chromium/src/media/+/d3d352cbce26b68596104356a5420d65544fe903%5E!/
https://github.com/mumble-voip/mumble/blob/54e313481d2fe2fe36fbd30f55c5f055cbbee615/src/mumble/WASAPI.cpp#L335-L359
Minimal test example:
https://github.com/SpriteOvO/TgCallBugTest
BTW, there is a handle leak in the device enumeration, that is, the device
Release
should be called afterIMMDeviceCollection::Item
.Finally, since I cannot compile tdesktop, the changes in this PR are untested. I only tested successfully with my minimal test example. But I'm happy to help test the compiled files.