Skip to content

SDL3 WASAPI Audio Format Oddities #14426

@CasualPokePlayer

Description

@CasualPokePlayer

I'm noticing some oddities with the audio format handling, at least with SDL3's WASAPI handling (haven't checked other backends).

My code currently attempts to set the current audio device if it sees that it's been removed (SDL_EVENT_AUDIO_DEVICE_REMOVED), or attempts to adjust to a format change if that occurs (SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED).

However, for one of my devices, I'm seeing rather strange behavior. My headphones are a soundcore Space Q45. This pair of headphones has an odd case of having options for either "Headphones" or "Headset" with the latter having much worse audio quality. Nothing problematic for SDL (that's just a quirk of these headphones), but SDL oddly is supposedly "changing" the format of this "Headset" option underneath me (telling me the frequency has changed from 16000Hz to 44100Hz), without firing a SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED event telling me so (although there is a SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED event being fired, just with a different device ID?), the change only being visible if I just call SDL_GetAudioDeviceFormat periodically and check if the format has changed.

However, doing an adjustment with this change seems to result in "wrong" results? The audio appears to be rather distorted treating the device as 44100Hz as opposed to 16000Hz (16000Hz instead having obvious aliasing issues, but otherwise sounds correct). This could just be some weird hardware bug perhaps? (44100Hz makes sense for the "Headphones" option rather than the "Headset" option).

Another oddity comes with the default device. I set my headphones as the default device, although if I power off the headphones, the default device of course changes over to my PC speakers. Nothing unexpected. However, if I proceed to have the default device currently as PC Speakers, then proceed to power on my headphones, there appears to be another format change occurring underneath me, without the SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED event telling me so. These appears to be multiple SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED events anyways signalling something is changing, but none of the IDs end up matching the device ID returned by SDL_GetAudioStreamDevice. Again, the change becomes only visible if I just call SDL_GetAudioDeviceFormat periodically and check if the format has changed (and in this case I must adjust things, otherwise the resutling audio is distorted).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions