mutex was not set to variable before

This commit is contained in:
Pawel Kolodziejski 2004-03-27 15:41:32 +00:00
parent 6af090d5c5
commit 83e37e34e0
3 changed files with 1 additions and 31 deletions

View File

@ -56,7 +56,6 @@ private:
zlibFile _file;
PlayingSoundHandle _soundHandle;
AppendableAudioStream *_stream;
MutexRef _timerMutex;
int32 _frame;
bool _updateNeeded;

View File

@ -22,19 +22,15 @@
#include <SDL.h>
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;
}

View File

@ -69,8 +69,6 @@ protected:
};
extern Timer *g_timer;
extern bool g_timerLock;
extern bool g_timerCallbackRunning;
#endif