diff --git a/smush.h b/smush.h index f73e8ae52e5..8bc99215dac 100644 --- a/smush.h +++ b/smush.h @@ -56,7 +56,6 @@ private: zlibFile _file; PlayingSoundHandle _soundHandle; AppendableAudioStream *_stream; - MutexRef _timerMutex; int32 _frame; bool _updateNeeded; diff --git a/timer.cpp b/timer.cpp index 1f6f455b973..ffce66a1b1a 100644 --- a/timer.cpp +++ b/timer.cpp @@ -22,19 +22,15 @@ #include Timer *g_timer = NULL; -bool g_timerLock; -bool g_timerCallbackRunning; Timer::Timer() : _mutex(0), _timerHandler(0), _lastTime(0) { - create_mutex(); + _mutex = create_mutex(); g_timer = this; - g_timerLock = false; - g_timerCallbackRunning = false; for (int i = 0; i < MAX_TIMERS; i++) { _timerSlots[i].procedure = NULL; @@ -70,9 +66,6 @@ Timer::~Timer() { // we might end up unlocking the mutex then immediately deleting it, while // the timer thread is about to lock it. delete_mutex(_mutex); - - g_timerLock = false; - g_timerCallbackRunning = false; } int Timer::timer_handler(int t) { @@ -85,13 +78,6 @@ int Timer::handler(int t) { StackLock lock(_mutex); uint32 interval, l; - g_timerCallbackRunning = true; - - if (g_timerLock) { - g_timerCallbackRunning = false; - return t; - } - _lastTime = _thisTime; _thisTime = SDL_GetTicks(); interval = 1000 * (_thisTime - _lastTime); @@ -109,8 +95,6 @@ int Timer::handler(int t) { } } - g_timerCallbackRunning = false; - return t; } @@ -118,22 +102,16 @@ bool Timer::installTimerProc(TimerProc procedure, int32 interval, void *refCon) assert(interval > 0); StackLock lock(_mutex); - g_timerLock = true; - while (g_timerCallbackRunning) {}; - for (int l = 0; l < MAX_TIMERS; l++) { if (!_timerSlots[l].procedure) { _timerSlots[l].procedure = procedure; _timerSlots[l].interval = interval; _timerSlots[l].counter = interval; _timerSlots[l].refCon = refCon; - g_timerLock = false; return true; } } - g_timerLock = false; - warning("Couldn't find free timer slot!"); return false; } @@ -141,9 +119,6 @@ bool Timer::installTimerProc(TimerProc procedure, int32 interval, void *refCon) void Timer::removeTimerProc(TimerProc procedure) { StackLock lock(_mutex); - g_timerLock = true; - while (g_timerCallbackRunning) {}; - for (int l = 0; l < MAX_TIMERS; l++) { if (_timerSlots[l].procedure == procedure) { _timerSlots[l].procedure = 0; @@ -152,6 +127,4 @@ void Timer::removeTimerProc(TimerProc procedure) { _timerSlots[l].refCon = 0; } } - - g_timerLock = false; } diff --git a/timer.h b/timer.h index a585e9c1654..44f43fc5426 100644 --- a/timer.h +++ b/timer.h @@ -69,8 +69,6 @@ protected: }; extern Timer *g_timer; -extern bool g_timerLock; -extern bool g_timerCallbackRunning; #endif