From beb092f93eacde92e300c15cbbc0c4081d2676d0 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Tue, 11 Dec 2018 16:24:55 +0100 Subject: change where audio/joystick are inited, attempting to fix potential COM initialize issues --- src/libui_sdl/main.cpp | 54 ++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'src/libui_sdl/main.cpp') diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index fff49df..6aa6c5d 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -185,32 +185,8 @@ int EmuThreadFunc(void* burp) ScreenDrawInited = false; Touching = false; - - SDL_AudioSpec whatIwant, whatIget; - memset(&whatIwant, 0, sizeof(SDL_AudioSpec)); - whatIwant.freq = 47340; - whatIwant.format = AUDIO_S16LSB; - whatIwant.channels = 2; - whatIwant.samples = 1024; - whatIwant.callback = AudioCallback; - SDL_AudioDeviceID audio = SDL_OpenAudioDevice(NULL, 0, &whatIwant, &whatIget, 0); - if (!audio) - { - printf("Audio init failed: %s\n", SDL_GetError()); - } - else - { - SDL_PauseAudioDevice(audio, 0); - } - KeyInputMask = 0xFFF; - // TODO: support more joysticks - if (SDL_NumJoysticks() > 0) - Joystick = SDL_JoystickOpen(0); - else - Joystick = NULL; - u32 nframes = 0; u32 starttick = SDL_GetTicks(); u32 lasttick = starttick; @@ -365,10 +341,6 @@ int EmuThreadFunc(void* burp) EmuStatus = 0; - if (Joystick) SDL_JoystickClose(Joystick); - - if (audio) SDL_CloseAudioDevice(audio); - NDS::DeInit(); return 44203; @@ -1581,6 +1553,29 @@ int main(int argc, char** argv) OnSetScreenRotation(MenuItem_ScreenRot[ScreenRotation], MainWindow, (void*)&kScreenRot[ScreenRotation]); + SDL_AudioSpec whatIwant, whatIget; + memset(&whatIwant, 0, sizeof(SDL_AudioSpec)); + whatIwant.freq = 47340; + whatIwant.format = AUDIO_S16LSB; + whatIwant.channels = 2; + whatIwant.samples = 1024; + whatIwant.callback = AudioCallback; + SDL_AudioDeviceID audio = SDL_OpenAudioDevice(NULL, 0, &whatIwant, &whatIget, 0); + if (!audio) + { + printf("Audio init failed: %s\n", SDL_GetError()); + } + else + { + SDL_PauseAudioDevice(audio, 0); + } + + // TODO: support more joysticks + if (SDL_NumJoysticks() > 0) + Joystick = SDL_JoystickOpen(0); + else + Joystick = NULL; + EmuRunning = 2; RunningSomething = false; EmuThread = SDL_CreateThread(EmuThreadFunc, "melonDS magic", NULL); @@ -1609,6 +1604,9 @@ int main(int argc, char** argv) EmuRunning = 0; SDL_WaitThread(EmuThread, NULL); + if (Joystick) SDL_JoystickClose(Joystick); + if (audio) SDL_CloseAudioDevice(audio); + Config::ScreenRotation = ScreenRotation; Config::ScreenGap = ScreenGap; Config::ScreenLayout = ScreenLayout; -- cgit v1.2.3