mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 11:51:52 +00:00
mutex was not set to variable before
This commit is contained in:
parent
6af090d5c5
commit
83e37e34e0
1
smush.h
1
smush.h
@ -56,7 +56,6 @@ private:
|
|||||||
zlibFile _file;
|
zlibFile _file;
|
||||||
PlayingSoundHandle _soundHandle;
|
PlayingSoundHandle _soundHandle;
|
||||||
AppendableAudioStream *_stream;
|
AppendableAudioStream *_stream;
|
||||||
MutexRef _timerMutex;
|
|
||||||
|
|
||||||
int32 _frame;
|
int32 _frame;
|
||||||
bool _updateNeeded;
|
bool _updateNeeded;
|
||||||
|
29
timer.cpp
29
timer.cpp
@ -22,19 +22,15 @@
|
|||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
Timer *g_timer = NULL;
|
Timer *g_timer = NULL;
|
||||||
bool g_timerLock;
|
|
||||||
bool g_timerCallbackRunning;
|
|
||||||
|
|
||||||
Timer::Timer() :
|
Timer::Timer() :
|
||||||
_mutex(0),
|
_mutex(0),
|
||||||
_timerHandler(0),
|
_timerHandler(0),
|
||||||
_lastTime(0) {
|
_lastTime(0) {
|
||||||
|
|
||||||
create_mutex();
|
_mutex = create_mutex();
|
||||||
|
|
||||||
g_timer = this;
|
g_timer = this;
|
||||||
g_timerLock = false;
|
|
||||||
g_timerCallbackRunning = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_TIMERS; i++) {
|
for (int i = 0; i < MAX_TIMERS; i++) {
|
||||||
_timerSlots[i].procedure = NULL;
|
_timerSlots[i].procedure = NULL;
|
||||||
@ -70,9 +66,6 @@ Timer::~Timer() {
|
|||||||
// we might end up unlocking the mutex then immediately deleting it, while
|
// we might end up unlocking the mutex then immediately deleting it, while
|
||||||
// the timer thread is about to lock it.
|
// the timer thread is about to lock it.
|
||||||
delete_mutex(_mutex);
|
delete_mutex(_mutex);
|
||||||
|
|
||||||
g_timerLock = false;
|
|
||||||
g_timerCallbackRunning = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Timer::timer_handler(int t) {
|
int Timer::timer_handler(int t) {
|
||||||
@ -85,13 +78,6 @@ int Timer::handler(int t) {
|
|||||||
StackLock lock(_mutex);
|
StackLock lock(_mutex);
|
||||||
uint32 interval, l;
|
uint32 interval, l;
|
||||||
|
|
||||||
g_timerCallbackRunning = true;
|
|
||||||
|
|
||||||
if (g_timerLock) {
|
|
||||||
g_timerCallbackRunning = false;
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
_lastTime = _thisTime;
|
_lastTime = _thisTime;
|
||||||
_thisTime = SDL_GetTicks();
|
_thisTime = SDL_GetTicks();
|
||||||
interval = 1000 * (_thisTime - _lastTime);
|
interval = 1000 * (_thisTime - _lastTime);
|
||||||
@ -109,8 +95,6 @@ int Timer::handler(int t) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_timerCallbackRunning = false;
|
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,22 +102,16 @@ bool Timer::installTimerProc(TimerProc procedure, int32 interval, void *refCon)
|
|||||||
assert(interval > 0);
|
assert(interval > 0);
|
||||||
StackLock lock(_mutex);
|
StackLock lock(_mutex);
|
||||||
|
|
||||||
g_timerLock = true;
|
|
||||||
while (g_timerCallbackRunning) {};
|
|
||||||
|
|
||||||
for (int l = 0; l < MAX_TIMERS; l++) {
|
for (int l = 0; l < MAX_TIMERS; l++) {
|
||||||
if (!_timerSlots[l].procedure) {
|
if (!_timerSlots[l].procedure) {
|
||||||
_timerSlots[l].procedure = procedure;
|
_timerSlots[l].procedure = procedure;
|
||||||
_timerSlots[l].interval = interval;
|
_timerSlots[l].interval = interval;
|
||||||
_timerSlots[l].counter = interval;
|
_timerSlots[l].counter = interval;
|
||||||
_timerSlots[l].refCon = refCon;
|
_timerSlots[l].refCon = refCon;
|
||||||
g_timerLock = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_timerLock = false;
|
|
||||||
|
|
||||||
warning("Couldn't find free timer slot!");
|
warning("Couldn't find free timer slot!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -141,9 +119,6 @@ bool Timer::installTimerProc(TimerProc procedure, int32 interval, void *refCon)
|
|||||||
void Timer::removeTimerProc(TimerProc procedure) {
|
void Timer::removeTimerProc(TimerProc procedure) {
|
||||||
StackLock lock(_mutex);
|
StackLock lock(_mutex);
|
||||||
|
|
||||||
g_timerLock = true;
|
|
||||||
while (g_timerCallbackRunning) {};
|
|
||||||
|
|
||||||
for (int l = 0; l < MAX_TIMERS; l++) {
|
for (int l = 0; l < MAX_TIMERS; l++) {
|
||||||
if (_timerSlots[l].procedure == procedure) {
|
if (_timerSlots[l].procedure == procedure) {
|
||||||
_timerSlots[l].procedure = 0;
|
_timerSlots[l].procedure = 0;
|
||||||
@ -152,6 +127,4 @@ void Timer::removeTimerProc(TimerProc procedure) {
|
|||||||
_timerSlots[l].refCon = 0;
|
_timerSlots[l].refCon = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_timerLock = false;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user