diff --git a/Source/Core/Core/Src/HW/CommandProcessor.cpp b/Source/Core/Core/Src/HW/CommandProcessor.cpp index b9bcc3978d..f9af5f798b 100644 --- a/Source/Core/Core/Src/HW/CommandProcessor.cpp +++ b/Source/Core/Core/Src/HW/CommandProcessor.cpp @@ -157,11 +157,16 @@ void Init() #ifdef _WIN32 InitializeCriticalSection(&fifo.sync); +#else + fifo.sync = new Common::CriticalSection(0); #endif } void Shutdown() { +#ifndef _WIN32 + delete fifo.sync; +#endif } void Read16(u16& _rReturnValue, const u32 _Address) @@ -249,6 +254,8 @@ void Write16(const u16 _Value, const u32 _Address) } #ifdef _WIN32 EnterCriticalSection(&fifo.sync); + #else + fifo.sync->Enter(); #endif } @@ -332,9 +339,11 @@ void Write16(const u16 _Value, const u32 _Address) // update the registers and run the fifo // This will recursively enter fifo.sync, TODO(ector): is this good? UpdateFifoRegister(); -#ifdef _WIN32 if (Core::g_CoreStartupParameter.bUseDualCore) +#ifdef _WIN32 LeaveCriticalSection(&fifo.sync); +#else + fifo.sync->Leave(); #endif fifo.bPauseRead = false; // pauseread is not actually used anywhere! TOOD(ector): huh! } @@ -369,6 +378,10 @@ void GatherPipeBursted() Common::SleepCurrentThread(1); #ifdef _WIN32 InterlockedExchangeAdd((LONG*)&fifo.CPReadWriteDistance, GPFifo::GATHER_PIPE_SIZE); +#else + fifo.sync->Enter(); + fifo.CPReadWriteDistance += GPFifo::GATHER_PIPE_SIZE; + fifo.sync->Leave(); #endif // check if we are in sync diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp index 7f96ea1789..af2405ff28 100644 --- a/Source/Core/VideoCommon/Src/Fifo.cpp +++ b/Source/Core/VideoCommon/Src/Fifo.cpp @@ -181,7 +181,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) #if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32) while(_fifo.CPReadWriteDistance > 0) #else - int count = 200; + int count = 200; while(_fifo.CPReadWriteDistance > 0 && count) #endif { @@ -200,12 +200,17 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) u8 *uData = video_initialize.pGetMemoryPointer(_fifo.CPReadPointer); #ifdef _WIN32 EnterCriticalSection(&_fifo.sync); +#else + _fifo.sync->Enter(); #endif _fifo.CPReadPointer += 32; Video_SendFifoData(uData); #ifdef _WIN32 InterlockedExchangeAdd((LONG*)&_fifo.CPReadWriteDistance, -32); LeaveCriticalSection(&_fifo.sync); +#else + _fifo.CPReadWriteDistance -= 32; + _fifo.sync->Leave(); #endif // increase the ReadPtr if (_fifo.CPReadPointer >= _fifo.CPEnd) diff --git a/Source/PluginSpecs/pluginspecs_video.h b/Source/PluginSpecs/pluginspecs_video.h index 32df4615de..c9233d7df1 100644 --- a/Source/PluginSpecs/pluginspecs_video.h +++ b/Source/PluginSpecs/pluginspecs_video.h @@ -5,10 +5,12 @@ #ifndef _VIDEO_H_INCLUDED__ #define _VIDEO_H_INCLUDED__ +#include "Thread.h" #include "PluginSpecs.h" #include "ExportProlog.h" + typedef void (*TSetPEToken)(const unsigned short _token, const int _bSetTokenAcknowledge); typedef void (*TSetPEFinish)(void); typedef unsigned char* (*TGetMemoryPointer)(const unsigned int _iAddress); @@ -40,6 +42,8 @@ typedef struct volatile bool bPauseRead; #ifdef _WIN32 CRITICAL_SECTION sync; +#else + Common::CriticalSection *sync; #endif } SCPFifoStruct; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp index ee747d3185..7d7cb4b666 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp @@ -79,7 +79,7 @@ BOOL Callback_PeekMessages() // TODO: There is no documentation of this function and the calling code // ignores the return value, so I have no idea what would be the // proper value to return. - return FALSE; + return TRUE; #elif defined(_WIN32) //TODO: peekmessage MSG msg; @@ -94,7 +94,7 @@ BOOL Callback_PeekMessages() #else // GLX // This is called from Outside of our video thread, from EmuThread // The calls are NOT thread safe, so it breaks everything - return FALSE; + return TRUE; #endif }