Forcing audio driver used by SDL2 from the code

Hi,

Since SDL2 is chosing Pulseaudio as default driver in some systems, I want/need to force ALSA instead since PA won’t let me set the number of samples I want,an the ALSA driver works fine, as expected.

So, is there a way to “force” an audio driver to be used within the code? I know the usual SDL_AUDIODRIVER env variable, but I mean to set it inside the code. No parameters for this seem to be available for SDL_OpenAudioDevice(), no hints for SDL_SetHint()…

Googled for a solution, searched in these forums, and I couldn’t find any way to do it.

Thanks

Hi, I think you want SDL_AudioInit: https://wiki.libsdl.org/SDL_AudioInitOn Wed, Dec 16, 2015 at 6:49 PM, vanfanel wrote:

Hi,

Since SDL2 is chosing Pulseaudio as default driver in some systems, I
want/need to force ALSA instead since PA won’t let me set the number of
samples I want,an the ALSA driver works fine, as expected.

So, is there a way to “force” an audio driver to be used within the code?
I know the usual SDL_AUDIODRIVER env variable, but I mean to set it inside
the code. No parameters for this seem to be available for
SDL_OpenAudioDevice(), no hints for SDL_SetHint()…

Googled for a solution, searched in these forums, and I couldn’t find any
way to do it.

Thanks


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

2015-12-16 22:49 GMT-03:00, vanfanel :

Since SDL2 is chosing Pulseaudio as default driver in some systems, I
want/need to force ALSA instead since PA won’t let me set the number of
samples I want,an the ALSA driver works fine, as expected.

Given how SDL2 passes the number of samples to render to the callback
regardless of what you do, I’d say that having code that relies on a
specific amount of samples per buffer is already an extremely bad idea
in the first place.

@sik: that part of the the code is not mine, can’t decide about that. I just need it to work as expected: it’s a migration from SDL1 to SDL2.

@eric.w: That was it! It works as expected: I can force the ALSA driver with that. It has to be called before SDL_Init(SDL_INIT_AUDIO).
Thanks!! Marking this as solved now.