libtgvoip: audioClient->Initialize failed: HRESULT=0x80070057

I get the below message in the debug log whenever I try to make a call with Telegram on Windows:

libtgvoip v2.4.4 on Windows 6.0.6002 Service Pack 2 x86
Log started on 24/10/2021 at 2:57:07
....
10-24 02:57:07 E: audioClient->Initialize failed: HRESULT=0x80070057
10-24 02:57:07 E: audioClient->Initialize failed: HRESULT=0x80070057
10-24 02:57:07 I: AEC: 1 NS: 1 AGC: 1
10-24 02:57:07 E: Error initializing audio playback

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:

	const GUID guid = { 0x2c693079, 0x3f59, 0x49fd, { 0x96, 0x4f, 0x61, 0xc0, 0x5, 0xea, 0xa5, 0xd3 } };
	res = audioClient->Initialize(AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST | AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY, 60 * 10000, 0, &format, &guid);
	CHECK_RES(res, "audioClient->Initialize");

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

Parameter pFormat points to an invalid format description; or the AUDCLNT_STREAMFLAGS_LOOPBACK flag is set but ShareMode is not equal to AUDCLNT_SHAREMODE_SHARED; or the AUDCLNT_STREAMFLAGS_CROSSPROCESS flag is set but ShareMode is equal to AUDCLNT_SHAREMODE_EXCLUSIVE. A prior call to SetClientProperties was made with an invalid category for audio/render streams.

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?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

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.