all repos — mgba @ 8a90066965a5d256fb6a7ba04ab98246f83a5b15

mGBA Game Boy Advance Emulator

GBA Thread: Make GBASyncWaitFrameStart time out
Jeffrey Pfau jeffrey@endrift.com
Sat, 21 Feb 2015 03:44:15 -0800
commit

8a90066965a5d256fb6a7ba04ab98246f83a5b15

parent

37fd51df39b9802446e1a89cfe6d993f3ec74558

3 files changed, 32 insertions(+), 1 deletions(-)

jump to
M CHANGESCHANGES

@@ -64,6 +64,7 @@ - Debugger: Rename read/write commands

- Qt: Optimize logo drawing - Qt: Move frame upload back onto main thread - All: Enable link-time optimization + - GBA Thread: Make GBASyncWaitFrameStart time out 0.1.1: (2015-01-24) Bugfixes:
M src/gba/supervisor/thread.csrc/gba/supervisor/thread.c

@@ -659,7 +659,9 @@ if (!sync->videoFrameOn && !sync->videoFramePending) {

return false; } if (sync->videoFrameOn) { - ConditionWait(&sync->videoFrameAvailableCond, &sync->videoFrameMutex); + if (ConditionWaitTimed(&sync->videoFrameAvailableCond, &sync->videoFrameMutex, 20)) { + return false; + } } sync->videoFramePending = 0; sync->videoFrameSkip = frameskip;
M src/util/threading.hsrc/util/threading.h

@@ -10,6 +10,7 @@ #include "util/common.h"

#ifdef USE_PTHREADS #include <pthread.h> +#include <sys/time.h> #define THREAD_ENTRY void* typedef THREAD_ENTRY (*ThreadEntry)(void*);

@@ -46,6 +47,21 @@ static inline int ConditionWait(Condition* cond, Mutex* mutex) {

return pthread_cond_wait(cond, mutex); } +static inline int ConditionWaitTimed(Condition* cond, Mutex* mutex, int32_t timeoutMs) { + struct timespec ts; + struct timeval tv; + + gettimeofday(&tv, 0); + ts.tv_sec = tv.tv_sec; + ts.tv_nsec = (tv.tv_usec + timeoutMs * 1000L) * 1000L; + if (ts.tv_nsec >= 1000000000L) { + ts.tv_nsec -= 1000000000L; + ++ts.tv_sec; + } + + return pthread_cond_timedwait(cond, mutex, &ts); +} + static inline int ConditionWake(Condition* cond) { return pthread_cond_broadcast(cond); }

@@ -101,6 +117,11 @@ }

static inline int ConditionWait(Condition* cond, Mutex* mutex) { SleepConditionVariableCS(cond, mutex, INFINITE); + return GetLastError(); +} + +static inline int ConditionWaitTimed(Condition* cond, Mutex* mutex, int32_t timeoutMs) { + SleepConditionVariableCS(cond, mutex, timeoutMs); return GetLastError(); }

@@ -160,6 +181,13 @@

static inline int ConditionWait(Condition* cond, Mutex* mutex) { UNUSED(cond); UNUSED(mutex); + return 0; +} + +static inline int ConditionWaitTimed(Condition* cond, Mutex* mutex, int32_t timeoutMs) { + UNUSED(cond); + UNUSED(mutex); + UNUSED(timeoutMs); return 0; }