change where audio/joystick are inited, attempting to fix potential COM initialize issues

This commit is contained in:
StapleButter 2018-12-11 16:24:55 +01:00
parent 3dd8c7b152
commit beb092f93e
2 changed files with 30 additions and 32 deletions

View File

@ -82,13 +82,13 @@ void ARMv5::UpdateDTCMSetting()
{ {
DTCMBase = DTCMSetting & 0xFFFFF000; DTCMBase = DTCMSetting & 0xFFFFF000;
DTCMSize = 0x200 << ((DTCMSetting >> 1) & 0x1F); DTCMSize = 0x200 << ((DTCMSetting >> 1) & 0x1F);
printf("DTCM [%08X] enabled at %08X, size %X\n", DTCMSetting, DTCMBase, DTCMSize); //printf("DTCM [%08X] enabled at %08X, size %X\n", DTCMSetting, DTCMBase, DTCMSize);
} }
else else
{ {
DTCMBase = 0xFFFFFFFF; DTCMBase = 0xFFFFFFFF;
DTCMSize = 0; DTCMSize = 0;
printf("DTCM disabled\n"); //printf("DTCM disabled\n");
} }
} }
@ -97,12 +97,12 @@ void ARMv5::UpdateITCMSetting()
if (CP15Control & (1<<18)) if (CP15Control & (1<<18))
{ {
ITCMSize = 0x200 << ((ITCMSetting >> 1) & 0x1F); ITCMSize = 0x200 << ((ITCMSetting >> 1) & 0x1F);
printf("ITCM [%08X] enabled at %08X, size %X\n", ITCMSetting, 0, ITCMSize); //printf("ITCM [%08X] enabled at %08X, size %X\n", ITCMSetting, 0, ITCMSize);
} }
else else
{ {
ITCMSize = 0; ITCMSize = 0;
printf("ITCM disabled\n"); //printf("ITCM disabled\n");
} }
} }

View File

@ -185,32 +185,8 @@ int EmuThreadFunc(void* burp)
ScreenDrawInited = false; ScreenDrawInited = false;
Touching = 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; KeyInputMask = 0xFFF;
// TODO: support more joysticks
if (SDL_NumJoysticks() > 0)
Joystick = SDL_JoystickOpen(0);
else
Joystick = NULL;
u32 nframes = 0; u32 nframes = 0;
u32 starttick = SDL_GetTicks(); u32 starttick = SDL_GetTicks();
u32 lasttick = starttick; u32 lasttick = starttick;
@ -365,10 +341,6 @@ int EmuThreadFunc(void* burp)
EmuStatus = 0; EmuStatus = 0;
if (Joystick) SDL_JoystickClose(Joystick);
if (audio) SDL_CloseAudioDevice(audio);
NDS::DeInit(); NDS::DeInit();
return 44203; return 44203;
@ -1581,6 +1553,29 @@ int main(int argc, char** argv)
OnSetScreenRotation(MenuItem_ScreenRot[ScreenRotation], MainWindow, (void*)&kScreenRot[ScreenRotation]); 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; EmuRunning = 2;
RunningSomething = false; RunningSomething = false;
EmuThread = SDL_CreateThread(EmuThreadFunc, "melonDS magic", NULL); EmuThread = SDL_CreateThread(EmuThreadFunc, "melonDS magic", NULL);
@ -1609,6 +1604,9 @@ int main(int argc, char** argv)
EmuRunning = 0; EmuRunning = 0;
SDL_WaitThread(EmuThread, NULL); SDL_WaitThread(EmuThread, NULL);
if (Joystick) SDL_JoystickClose(Joystick);
if (audio) SDL_CloseAudioDevice(audio);
Config::ScreenRotation = ScreenRotation; Config::ScreenRotation = ScreenRotation;
Config::ScreenGap = ScreenGap; Config::ScreenGap = ScreenGap;
Config::ScreenLayout = ScreenLayout; Config::ScreenLayout = ScreenLayout;