You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We recently received a report from a user who has encountered audio distortion and app crashes as a result of plugging/unplugging his headphones. He appears to have a somewhat rare audio setup where his speakers and headphones are connected as separate playback devices with different default device periods. As a result, the WASAPI driver assigns this->spec.samples = 236 for the speakers, and this->spec.samples = 221 for the headphones. This can be observed in the logs from our game client that he provided to us in the issue report.
When the WASAPI driver updates the number of samples in the audio spec, it calls SDL_CalculateAudioSpec(&this->spec) to update device->spec.size. But that does nothing to device->callbackspec.
I believe that if the channels, format, or freq are also updated, then SDL will create an audio stream to resample internally. But if only the number of samples changes, then it will "use the existing audio stream" which means that nothing actually changes. Even if the stream was created, I have doubts about whether the callback would be providing the right number of samples to the resampler.
We recently received a report from a user who has encountered audio distortion and app crashes as a result of plugging/unplugging his headphones. He appears to have a somewhat rare audio setup where his speakers and headphones are connected as separate playback devices with different default device periods. As a result, the WASAPI driver assigns
this->spec.samples = 236
for the speakers, andthis->spec.samples = 221
for the headphones. This can be observed in the logs from our game client that he provided to us in the issue report.diasurgical/devilutionX#7452 (comment)
Speakers:
VERBOSE: Aulib sampleRate=22050 channels=2 frameSize=236 format=0x8120
Headphones:
VERBOSE: Aulib sampleRate=22050 channels=2 frameSize=221 format=0x8120
This version of our application uses SDL release version 2.30.5.
In
SDL_RunAudio()
, the callback is invoked withdata
anddata_len
parameters.udata
is irrelevant in our case.SDL/src/audio/SDL_audio.c
Line 736 in 2eef7ca
data
is the return value ofWASAPI_GetDeviceBuf()
.SDL/src/audio/SDL_audio.c
Line 707 in 2eef7ca
data_len
is assigned the value fromdevice->callbackspec.size
.SDL/src/audio/SDL_audio.c
Line 703 in 2eef7ca
When the WASAPI driver updates the number of samples in the audio spec, it calls
SDL_CalculateAudioSpec(&this->spec)
to updatedevice->spec.size
. But that does nothing todevice->callbackspec
.SDL/src/audio/wasapi/SDL_wasapi.c
Lines 486 to 500 in 2eef7ca
WASAPI_GetDeviceBuf()
usesthis->spec.samples
to allocate the buffer for audio samples.SDL/src/audio/wasapi/SDL_wasapi.c
Line 183 in 2eef7ca
I believe that if the
channels
,format
, orfreq
are also updated, then SDL will create an audio stream to resample internally. But if only the number of samples changes, then it will "use the existing audio stream" which means that nothing actually changes. Even if the stream was created, I have doubts about whether the callback would be providing the right number of samples to the resampler.SDL/src/audio/wasapi/SDL_wasapi.c
Lines 82 to 93 in 2eef7ca
Therefore, unless I've missed something, after the device change the callback is made to fill a 221-sample buffer with 236 samples or vice versa.
The text was updated successfully, but these errors were encountered: