diff options
author | StapleButter <thetotalworm@gmail.com> | 2018-12-11 16:24:55 +0100 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2018-12-11 16:24:55 +0100 |
commit | beb092f93eacde92e300c15cbbc0c4081d2676d0 (patch) | |
tree | 1bd73d0c3812efc59b1321d2bf9c86279c84df1a /src/libui_sdl/main.cpp | |
parent | 3dd8c7b152109df09f2f1bcecc52b05ecf6f9ead (diff) |
change where audio/joystick are inited, attempting to fix potential COM initialize issues
Diffstat (limited to 'src/libui_sdl/main.cpp')
-rw-r--r-- | src/libui_sdl/main.cpp | 54 |
1 files changed, 26 insertions, 28 deletions
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; |