-
Notifications
You must be signed in to change notification settings - Fork 160
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
Invalid SDL_AUDIODRIVER environment variable may prevent audio to initialize #1692
Comments
So they only adjusted the case of I also am not fully sure, but I believe we are initializing the SDL Audio twice, once in sys_main and another time in audio_core, through MojoAL. The MojoAL initialization also pass an additional information describing what the driver must have. The following code is wrong, but I had this idea of iterating to find a working audio driver, but this would have to happen in audio_core in case my previous observation is correct. Of course, we may also decide this is a non issue and simply close this. |
MojoAL passes the information when it initializes device, not driver, these are different things. For the device initialization it passes its name (optional), frequency, etc. For more information: EDIT: in mojoAl's code I can see a call to |
This is correct from the documentation, indeed. But this is what is weird, if I set an environment variable
I followed this with the debugger and turns out Edit: it's not. Maybe they don't consider it a bug. Perhaps we should override using something like I opened an additional upstream bug regarding this specifically to see if this is intended behavior or not: libsdl-org/SDL#5841 |
Apparently the result is just never use SDL_AudioInit. Maybe we need to override those weird environment variables of sdl2 with some value for each driver and clean it when selecting AUTO. I opened an additional issue in MojoAL to see if there's something specific in MojoAL I am missing: icculus/mojoAL#17 |
@ericoporto tbh I'm getting confused by this issue thread. The original problem was that AGS fails to init if the requested driver id is not valid (not recognized by SDL). But is the mojoAl's problem is a separate one? If so, may it be opened as a separate ticket? Because frankly I still dont fully understand the problem with mojoAL, even after reading the linked issues. Maybe some details are missing in the description. Was the original problem solved though? |
ags/Engine/platform/base/sys_main.cpp Lines 96 to 102 in f8a90c3
These lines are wrong and instead it should write an empty SDL_setenv or the specific driver name selected. SDL_AudioInit should not be used since it's not ref counted.
In SDL 2.24, it will accept |
EDIT: sorry, I have to gather this from multiple comments, because I already forgot what the problem was. Re-reading everything once more: the problem is that SDL_AudioInit does not set a flag inside SDL2 saying that audio system is initialized, and so when MojoAL wants to initialize it (using SDL_InitSubSystem), SDL2 cannot tell that audio is ready, so it tries to initialize again, potentially a different driver id, taken from the enviromental variable. So, I have got a question. If we must use SDL_InitSubSystem to let SDL2 set the ref count, and mojoAl detect that, then may we do this in sys_main:
Will this work? EDIT: Hmm, maybe this is precisely what you were suggesting above. |
@ericoporto opened a pr: #1747 Note, I found there's no need to have your own list of drivers, as SDL2 already tries this list if the env SDL_AUDIODRIVER is null. (Of course if above list is bad for some reason, in that case we could still have our own, as a last resort, but hopefully that won't be necessary) |
Describe the bug
If you set an environment variable
SDL_AUDIODRIVER
to an invalid value, AGS may not initialize, due to SDL complaining the system does not exist.AGS Version
Current master (5c3a5ea).
Game
It can happen in any game.
To Reproduce
Steps to reproduce the behavior:
SDL_AUDIODRIVER
and set it to an invalid value (say,dsound2
).Expected behavior
The expected behavior is for AGS to figure a good known driver and start anyway.
Desktop:
Additional context
I am not sure if this is an AGS bug, so I opened it upstream too libsdl-org/SDL#5818
The text was updated successfully, but these errors were encountered: