From c3bc7d657e84824bb2cfdea39f604c33110eaa14 Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Sat, 2 Mar 2019 00:05:36 +0000 Subject: Codechange: Remove ability for SDL to be dynamically loaded on Windows --- src/sound/sdl_s.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/sound') 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 @@ -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 */ -- cgit v1.2.3-54-g00ecf