-
Notifications
You must be signed in to change notification settings - Fork 2.4k
SDL2: Implement SDL_GetDefaultAudioInfo() on the ALSA backend. #13333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…entation on ALSA.
spec->freq = 48000; | ||
spec->format = AUDIO_S16SYS; | ||
spec->channels = 2; | ||
spec->samples = 512; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what ALSA prefers by default if the hardware doesn't specify; the channel count is Good Enough(TM) but I wonder if there's a preference for format
and samples
in particular.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To my knowledge, ALSA doesn't have any explicit preference, but we can rely on S16_LE
and/or S16_BE
support in ALSA for every device ALSA supports, and AUDIO_S16SYS
choses the one supported by the system. That makes it a very sane default.
As for 512, it offers a good compromise between latency and buffer underrun protection, a good historic value. ALSA doesn't have any preference in this regard either to my knowledge, but other higher-level APIs that work on ALSA like OpenAL or Portaudio use 512 samples in ALSA too.
@icculus Can you please greenlight this small commit? There's another ALSA backend bug I'd need to take care of but I'd like to close the issue related to this commit first :) |
Yeah, why not, let's merge! |
yay! Thanks! :) |
@icculus, is there an equivalent of this change that needs to go into SDL3? |
This API was removed from SDL3. |
Yes, so it seems. For good, if you ask me. |
Description
Implements SDL_GetDefaultAudioInfo() on the ALSA backend, needed for programs that explicitly look for the default audio device, like current MAME (since 0.278).
It's done by opening the default ALSA device, getting the info and closing it.
The alternative was to manually parse the ALSA config files, which would be a way more convoluted and weak solution.
Existing Issue(s)
Fixes issue #13318