Closed casper closed 2 years ago
This library is no longer maintained since Pavel fired me in April 2019.
As for the audio from the Telegram app itself, it relies on a cross-platform library for that, and iirc on Windows it always uses DirectSound, which I've never implemented here.
Well that's a bummer :(
Is there any way I could debug this issue further for myself? Do you have any idea what the issue might be?
Maybe I could just pluck the init code from AudioOutputWASAPI.cpp into a dummy project and see if I can debug it in Visual Studio? Do you think that would work, or are there too many dependencies for such a simple test? I don't want to start building the whole Telegram app from scratch...
Wait.
Windows 6.0.6002
Is this Vista?..
It looks like it is, according to https://docs.microsoft.com/en-us/windows/win32/sysinfo/operating-system-version
Yes. Vista!
Lol. Yeah well that's your problem right here :D
I only ever tested on XP (with waveOut API), 7, and 10. I just assumed no one used vista any more because 7 is better in about every way. Might be an issue with how it implements WASAPI as it was the first Windows version to implement it.
But — try setting the sound card to 48000 hz 16 bit, maybe it doesn't support sample rate/format conversion. And remove AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM
.
I know but I love my Vista :-/ According to the MS docs there should not be any Win7 specific options in your Initialize code.
Is Telegram always compiled with the TGVOIP_WINXP_COMPAT flag? Maybe I could binary patch the exe to run the WINXP audio path, as you seem to check for it in only one location. I just need to patch one number in the code to switch the path I think.
Yeah I tried the 48kHz trick. I thought that was the issue also. No go. I also tried the exclusive non-exclusive settings. Very strange as Vista audio should be almost identical to Win 7 as far as I know.
Is Telegram always compiled with the TGVOIP_WINXP_COMPAT flag?
I have no idea, and the dev does like to change the build script fairly often. It may be, because he didn't touch the parts that I wrote. It may be not, because it dropped XP support 2-3 years ago.
Maybe I could binary patch the exe to run the WINXP audio path, as you seem to check for it in only one location.
You can do that. You can also hook GetVersion() and pretend that you're running XP. Oh, and actually, maybe that "compatibility mode" thingy in the properties window might do the trick. So do try that first.
Oh yeah. Great idea with the compatibility! Let's see....
Holy crap. It works! Lol. But the audio output is very choppy. Have to troubleshoot that a little bit.
Nice. I didn't really expect it to work.
Yeah the microphone input is smooth, but the speaker output is choppy. Tried sample rates and exclusive settings. Dooh...sooo close.
Maybe I have to make a test harness for your code to figure out which of the Init flags fails on Vista in the WASAPI code. Because if it's just a flag maybe I could patch the exe that way too. But getting late. Have to continue tomorrow...
Ok I didn't go to bed but spent the whole night building a test harness for the WASAPI code. Finally got it to compile and run.
Note I have no audio to test with. I only check if the Initialize call goes through or not.
Conclusion: it's the last two flags to Initialize that are incompatible with Vista.
AUTOCONVERTPCM + SRC_DEFAULT_QUALITY -> fail.
AUTOCONVERTPCM alone seems to initialize
SRC_DEFAULT_QUALITY only -> fail.
It's strange that MSDN says they should work, but apparently they don't. On Visual Studio 2010 that I use they were not even defined, had to enter them manually.
I guess I could patch the binary to remove those two, but I wonder how it will affect audio quality.
Now going to bed for real.
Good news. Patching the binary works! :) No problem with sound quality as far as I can tell.
It took a while to figure out how to do it, but in the end I searched the binary for the combined audio property flags which is 0x880c0000
. There are only two spots in the binary with that sequence.
I then patched the last byte 88
to 00
, which makes the total flag equal to 0x000c0000
, which means we removed the last two Windows 7 flags that were causing the problem.
I get the below message in the debug log whenever I try to make a call with Telegram on Windows:
The Telegram GUI then refuses the call and displays: "There seems to be a problem with your sound card."
In the code of libtgvoip I have found the spot which generates the error:
I also checked that 0x80070057 means E_INVALIDARG, which is described on this page: https://docs.microsoft.com/en-us/windows/win32/api/audioclient/nf-audioclient-iaudioclient-initialize
But that's as far as I got. I tried reinstalling and fiddling with my audio device settings in many different ways, but nothing seems to help.
Recording audio messages in Telegram works fine, as well as audio playback on videos. No problems in any other apps either. It's only when trying to make VOIP calls that it fails.
Any clue what could be the problem?