Looks like #4250 solved the crashing problem, but @Reikion still reported that the audio sound is glitchy.
I start this issue just want to see how many people encounter this problem, so we can have an idea about what platforms is influenced.
In addition, just to facilitate debugging, I create a patch that can dump all decoded audio samples directly from our buffer. https://gist.github.com/TerryGeng/432a75f520f28b3e3daf1df830772159
Please use git apply to apply this patch on the head of #4250.
The file name includes the sample rate and stereo/mono. The sample is in the 32-bit IEEE float format. It can be opened with Adobe Audition or Audacity. FFmpeg also has a decoder f32le to deal with it:
ffmpeg -f f32le -ar 44100 -ac 1 -i input_filename.raw output.wav
where ar is the sample rate and ac is 1 for mono, 2 for stereo.
I believe these samples would provide more details about this bug.
I noticed that if AudioOutput is initialized to 48 kHz, than samples 44,1kHz doesn't work and vice versa. IIRC my sound card should support from 44,1 kHz up to 96 kHz.
1: ServerConnected.ogg: Ogg data, Vorbis audio, mono, 48000 Hz, ~86000 bps, created by: Xiph.Org libVorbis I (1.2.3)
2: User Left Server.ogg: Ogg data, Vorbis audio, stereo, 48000 Hz, ~256000 bps, created by: Xiph.Org libVorbis I (1.2.3)
3: Recording State Change.ogg: Ogg data, Vorbis audio, stereo, 44100 Hz, ~192000 bps, created by: Xiph.Org libVorbis I (1.2.3)
<W>2020-06-07 17:15:57.710 AudioOutput: Initialized 2 channel 48000 hz mixer
<W>2020-06-07 17:15:57.714 AudioInput: Initialized mixer for 1 channel 44100 hz mic and 0 channel 48000 hz echo
Thanks for the reply! Problem reproduced. I initialized my audio interface to 48kHz and all samples start sounding strange. From the sample files you have provided, I see

The sample is cut abruptly in the middle. I think maybe I have made some mistakes when calculating sample counts. I will look into it tomorrow.
Hi @Reikion, I made another patch that fixes this problem on my laptop. https://gist.github.com/TerryGeng/432a75f520f28b3e3daf1df830772159#file-fix_sample_count-patch
Can you apply this again, on the HEAD of #4250? If this works, I will open a new PR regarding this.
Can you apply this again, on the HEAD of #4250? If this works, I will open a new PR regarding this.
Isn't this patch kinda related to the problem this PR here addresses? I think we don't need a separate PR for it then :)
I applied fix_sample_count.patch end it looks like that everything works fine :D
Most helpful comment
I applied
fix_sample_count.patchend it looks like that everything works fine :D