diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index d42f813013..fb76515b9c 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -18,7 +18,6 @@ #ifdef _WIN32 #include -#else #endif #include "Setup.h" // Common @@ -285,12 +284,13 @@ THREAD_RETURN CpuThread(void *pArg) CCPU::Run(); cpuRunloopQuit.Set(); +#ifdef _WIN32 + gpuShutdownCall.Wait(); + // Call video shutdown from the video thread in single core mode, which is the cpuThread if (!_CoreParameter.bUseDualCore) - { - gpuShutdownCall.Wait(); Plugins.ShutdownVideoPlugin(); - } +#endif gpuShutdownCall.Shutdown(); @@ -443,10 +443,10 @@ THREAD_RETURN EmuThread(void *pArg) } else // SingleCore mode { +#ifdef _WIN32 // the spawned CPU Thread is the... CPU thread but it also does the graphics. // the EmuThread is thus an idle thread, which sleeps and wait for the emu to terminate. -#ifdef _WIN32 cpuThread = new Common::Thread(CpuThread, pArg); Common::SetCurrentThreadName("Emuthread - Idle"); @@ -459,7 +459,8 @@ THREAD_RETURN EmuThread(void *pArg) Common::SleepCurrentThread(20); } #else - // In single-core mode, the Emulation main thread is also the CPU thread + // On unix platforms, the Emulation main thread IS the CPU & video thread + // So there's only one thread, imho, that's much better than on windows :P CpuThread(pArg); #endif } @@ -476,12 +477,17 @@ THREAD_RETURN EmuThread(void *pArg) HW::Shutdown(); Plugins.ShutdownPlugins(); - // Call video shutdown from the video thread in dual core mode (EmuThread) +#ifdef _WIN32 + gpuShutdownCall.Set(); + + // Call video shutdown from the video thread, in dual core mode it's the EmuThread // Or set an event in Single Core mode, to call the shutdown from the cpuThread if (_CoreParameter.bUseDualCore) Plugins.ShutdownVideoPlugin(); - else - gpuShutdownCall.Set(); +#else + // On unix platforms, the EmuThread is ALWAYS the video thread + Plugins.ShutdownVideoPlugin(); +#endif if (cpuThread) { diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h index f7687b8d98..5f927b8732 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h @@ -185,7 +185,7 @@ private: switch (m_CRC) { case 0x42f64ac4: // Luigi - case 0x0267d05a: // http://forums.dolphin-emu.com/thread-2134.html Pikmin PAL + case 0x267fd05a: // Pikmin PAL case 0x4be6a5cb: // AC, Pikmin case 0x088e38a5: // IPL - JAP case 0xd73338cf: // IPL diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp index 5bf65ae595..5d13588c52 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp @@ -114,7 +114,7 @@ void UpdateSampleCounters10(ZeldaVoicePB &PB) void CUCode_Zelda::RenderVoice_PCM16(ZeldaVoicePB &PB, s16 *_Buffer, int _Size) { int _RealSize = SizeForResampling(PB, _Size, PB.RatioInt); - int rem_samples = _RealSize; + u32 rem_samples = _RealSize; if (PB.KeyOff) goto clear_buffer; if (PB.NeedsReset) @@ -130,7 +130,7 @@ reached_end: if (!PB.RepeatMode) { // One shot - play zeros the rest of the buffer. clear_buffer: - for (int i = 0; i < rem_samples; i++) + for (u32 i = 0; i < rem_samples; i++) *_Buffer++ = 0; PB.KeyOff = 1; return; @@ -146,13 +146,13 @@ clear_buffer: if (PB.RemLength < rem_samples) { // finish-up loop - for (int i = 0; i < PB.RemLength; i++) + for (u32 i = 0; i < PB.RemLength; i++) *_Buffer++ = Common::swap16(*read_ptr++); rem_samples -= PB.RemLength; goto reached_end; } // main render loop - for (int i = 0; i < rem_samples; i++) + for (u32 i = 0; i < rem_samples; i++) *_Buffer++ = Common::swap16(*read_ptr++); PB.RemLength -= rem_samples; @@ -171,7 +171,7 @@ void UpdateSampleCounters8(ZeldaVoicePB &PB) void CUCode_Zelda::RenderVoice_PCM8(ZeldaVoicePB &PB, s16 *_Buffer, int _Size) { int _RealSize = SizeForResampling(PB, _Size, PB.RatioInt); - int rem_samples = _RealSize; + u32 rem_samples = _RealSize; if (PB.KeyOff) goto clear_buffer; if (PB.NeedsReset) @@ -188,7 +188,7 @@ reached_end: { // One shot - play zeros the rest of the buffer. clear_buffer: - for (int i = 0; i < rem_samples; i++) + for (u32 i = 0; i < rem_samples; i++) *_Buffer++ = 0; PB.KeyOff = 1; return; @@ -205,13 +205,13 @@ clear_buffer: if (PB.RemLength < rem_samples) { // finish-up loop - for (int i = 0; i < PB.RemLength; i++) + for (u32 i = 0; i < PB.RemLength; i++) *_Buffer++ = (s8)(*read_ptr++) << 8; rem_samples -= PB.RemLength; goto reached_end; } // main render loop - for (int i = 0; i < rem_samples; i++) + for (u32 i = 0; i < rem_samples; i++) *_Buffer++ = (s8)(*read_ptr++) << 8; PB.RemLength -= rem_samples; @@ -356,7 +356,7 @@ void Decoder21_ReadAudio(ZeldaVoicePB &PB, int size, s16 *_Buffer); void CUCode_Zelda::RenderVoice_Raw(ZeldaVoicePB &PB, s16 *_Buffer, int _Size) { // Decoder0x21 starts here. - int _RealSize = SizeForResampling(PB, _Size, PB.RatioInt); + u32 _RealSize = SizeForResampling(PB, _Size, PB.RatioInt); // Decoder0x21Core starts here. u32 AX0 = _RealSize; @@ -440,7 +440,7 @@ void Decoder21_ReadAudio(ZeldaVoicePB &PB, int size, s16 *_Buffer) const u8 *source = g_dspInitialize.pGetMemoryPointer(0x80000000); const u16 *src = (u16 *)(source + (ACC0 & ram_mask)); - for (int i = 0; i < (ACC1 >> 16); i++) { + for (u32 i = 0; i < (ACC1 >> 16); i++) { _Buffer[i] = Common::swap16(src[i]); } diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCodes.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCodes.cpp index 2bfded6422..0bd7a5f179 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCodes.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCodes.cpp @@ -57,7 +57,7 @@ IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler) case 0x088e38a5: // IPL - JAP case 0xd73338cf: // IPL case 0x42f64ac4: // Luigi - case 0x0267d05a: // http://forums.dolphin-emu.com/thread-2134.html Pikmin PAL + case 0x267fd05a: // Pikmin PAL case 0x4be6a5cb: // AC, Pikmin INFO_LOG(DSPHLE, "CRC %08x: JAC (early Zelda) ucode chosen", _CRC); return new CUCode_Zelda(_rMailHandler, _CRC); diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp index 130cb2c47e..178287926d 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp @@ -302,12 +302,20 @@ void Shutdown() #ifdef _DEBUG DEBUG_QUIT(); #endif + + #ifdef _WIN32 + // Free DInput before closing SDL, or get a crash ! + FreeDirectInput(); + #elif defined(__linux__) + close(fd); + #endif // Don't shutdown the gamepad if the configuration window is still showing // Todo: Coordinate with the Wiimote plugin, SDL_Quit() will remove the pad for it to #if defined(HAVE_WX) && HAVE_WX if (m_ConfigFrame) return; #endif + /* Close all devices carefully. We must check that we are not accessing any undefined vector elements or any bad devices */ for (int i = 0; i < 4; i++) @@ -331,12 +339,6 @@ void Shutdown() // Remove the pointer to the initialize data g_PADInitialize = NULL; - - #ifdef _WIN32 - FreeDirectInput(); - #elif defined(__linux__) - close(fd); - #endif }