diff options
author | Charles Pigott <charlespigott@googlemail.com> | 2019-03-02 00:05:36 +0000 |
---|---|---|
committer | Patric Stout <truebrain@openttd.org> | 2019-03-02 17:13:05 +0100 |
commit | c3bc7d657e84824bb2cfdea39f604c33110eaa14 (patch) | |
tree | be2b7c082c6edac78daf1b527fb09e2a22ef60cd /src/sound/sdl_s.cpp | |
parent | 63fe6c65983a4cf2eba4995d03abd7e8a39c4a43 (diff) | |
download | openttd-c3bc7d657e84824bb2cfdea39f604c33110eaa14.tar.xz |
Codechange: Remove ability for SDL to be dynamically loaded on Windows
Diffstat (limited to 'src/sound/sdl_s.cpp')
-rw-r--r-- | src/sound/sdl_s.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/sound/sdl_s.cpp b/src/sound/sdl_s.cpp index e3fb99eaa..b37016c24 100644 --- a/src/sound/sdl_s.cpp +++ b/src/sound/sdl_s.cpp @@ -14,7 +14,6 @@ #include "../stdafx.h" #include "../mixer.h" -#include "../sdl.h" #include "sdl_s.h" #include <SDL.h> @@ -38,8 +37,14 @@ const char *SoundDriver_SDL::Start(const char * const *parm) { SDL_AudioSpec spec; - const char *s = SdlOpen(SDL_INIT_AUDIO); - if (s != NULL) return s; + /* Only initialise SDL if the video driver hasn't done it already */ + int ret_code = 0; + if (SDL_WasInit(SDL_INIT_EVERYTHING) == 0) { + ret_code = SDL_Init(SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE); + } else if (SDL_WasInit(SDL_INIT_AUDIO) == 0) { + ret_code = SDL_InitSubSystem(SDL_INIT_AUDIO); + } + if (ret_code == -1) return SDL_GetError(); spec.freq = GetDriverParamInt(parm, "hz", 44100); spec.format = AUDIO_S16SYS; @@ -47,15 +52,18 @@ const char *SoundDriver_SDL::Start(const char * const *parm) spec.samples = GetDriverParamInt(parm, "samples", 1024); spec.callback = fill_sound_buffer; MxInitialize(spec.freq); - SDL_CALL SDL_OpenAudio(&spec, &spec); - SDL_CALL SDL_PauseAudio(0); + SDL_OpenAudio(&spec, &spec); + SDL_PauseAudio(0); return NULL; } void SoundDriver_SDL::Stop() { - SDL_CALL SDL_CloseAudio(); - SdlClose(SDL_INIT_AUDIO); + SDL_CloseAudio(); + SDL_QuitSubSystem(SDL_INIT_AUDIO); + if (SDL_WasInit(SDL_INIT_EVERYTHING) == 0) { + SDL_Quit(); // If there's nothing left, quit SDL + } } #endif /* WITH_SDL */ |