Fix a hang on stop on linux (why is that done better on linux ?? strange :P)

Fix what must have been a typo for Pikmin PAL CRC, the game still doesn't work though :(
Fix a crash on stop in nJoy 

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3821 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
sl1nk3.s 2009-07-17 16:20:55 +00:00
parent 8c466e1a62
commit 664f017fec
5 changed files with 35 additions and 27 deletions

View File

@ -18,7 +18,6 @@
#ifdef _WIN32
#include <windows.h>
#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)
{

View File

@ -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

View File

@ -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]);
}

View File

@ -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);

View File

@ -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
}