From e88f3b43553d26c1523a9fa22b9710cd615aefdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Fri, 15 Aug 2014 19:25:27 -0300 Subject: [PATCH] (SDL) Fix double initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Higor Eurípedes --- audio/sdl_audio.c | 7 +++++-- gfx/sdl2_gfx.c | 7 +++++-- input/sdl_joypad.c | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/audio/sdl_audio.c b/audio/sdl_audio.c index e1bd5ab5ee..db9107e99f 100644 --- a/audio/sdl_audio.c +++ b/audio/sdl_audio.c @@ -60,8 +60,11 @@ static inline int find_num_frames(int rate, int latency) static void *sdl_audio_init(const char *device, unsigned rate, unsigned latency) { (void)device; - if (SDL_WasInit(0) == 0 && SDL_Init(SDL_INIT_AUDIO) < 0) - return NULL; + if (SDL_WasInit(0) == 0) + { + if (SDL_Init(SDL_INIT_AUDIO) < 0) + return NULL; + } else if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) return NULL; diff --git a/gfx/sdl2_gfx.c b/gfx/sdl2_gfx.c index a292a90407..215e86da47 100644 --- a/gfx/sdl2_gfx.c +++ b/gfx/sdl2_gfx.c @@ -369,8 +369,11 @@ static void *sdl2_gfx_init(const video_info_t *video, const input_driver_t **inp int i; - if (SDL_WasInit(0) == 0 && SDL_Init(SDL_INIT_VIDEO) < 0) - return NULL; + if (SDL_WasInit(0) == 0) + { + if (SDL_Init(SDL_INIT_VIDEO) < 0) + return NULL; + } else if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) return NULL; diff --git a/input/sdl_joypad.c b/input/sdl_joypad.c index 203fdd1a5a..2aee0b569a 100644 --- a/input/sdl_joypad.c +++ b/input/sdl_joypad.c @@ -124,8 +124,11 @@ static void sdl_joypad_destroy(void) static bool sdl_joypad_init(void) { unsigned i; - if (SDL_WasInit(0) == 0 && SDL_Init(SDL_INIT_JOYSTICK) < 0) - return false; + if (SDL_WasInit(0) == 0) + { + if (SDL_Init(SDL_INIT_JOYSTICK) < 0) + return false; + } else if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) return false;