[Scummvm-cvs-logs] CVS: residual smush.cpp,1.37,1.38 timer.cpp,1.5,1.6 timer.h,1.3,1.4
Pawel Kolodziejski
aquadran at users.sourceforge.net
Sat Mar 27 06:48:02 CET 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword2 mouse.cpp,1.54,1.55 save_rest.cpp,1.50,1.51 sword2.cpp,1.106,1.107
- Next message: [Scummvm-cvs-logs] CVS: residual smush.cpp,1.38,1.39 timer.cpp,1.6,1.7 timer.h,1.4,1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29999
Modified Files:
smush.cpp timer.cpp timer.h
Log Message:
try again
Index: smush.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/smush.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- smush.cpp 26 Mar 2004 22:37:46 -0000 1.37
+++ smush.cpp 27 Mar 2004 14:28:53 -0000 1.38
@@ -68,6 +68,7 @@
_videoFinished = false;
_videoPause = false;
_updateNeeded = false;
+
if (!_surface) {
_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, _width, _height, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000);
_dst = (byte *)_surface->pixels;
@@ -77,17 +78,15 @@
_buf = (byte *)_bufSurface->pixels;
}
- {
- StackLock lock(_timerMutex);
- g_timer->installTimerProc(&timerCallback, _speed, NULL);
- }
+ while (g_timerCallbackRunning) {};
+ g_timerLock = true;
+ g_timer->installTimerProc(&timerCallback, _speed, NULL);
+ g_timerLock = false;
}
void Smush::deinit() {
- {
- StackLock lock(_timerMutex);
- g_timer->removeTimerProc(&timerCallback);
- }
+ g_timer->removeTimerProc(&timerCallback);
+ g_timerLock = false;
_videoFinished = true;
_videoPause = true;
Index: timer.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/timer.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- timer.cpp 26 Mar 2004 22:37:46 -0000 1.5
+++ timer.cpp 27 Mar 2004 14:28:53 -0000 1.6
@@ -22,6 +22,8 @@
#include <SDL.h>
Timer *g_timer = NULL;
+bool g_timerLock;
+bool g_timerCallbackRunning;
Timer::Timer() :
_mutex(0),
@@ -31,6 +33,8 @@
create_mutex();
g_timer = this;
+ g_timerLock = false;
+ g_timerCallbackRunning = false;
for (int i = 0; i < MAX_TIMERS; i++) {
_timerSlots[i].procedure = NULL;
@@ -66,6 +70,9 @@
// 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) {
@@ -78,6 +85,13 @@
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);
@@ -95,6 +109,8 @@
}
}
+ g_timerCallbackRunning = false;
+
return t;
}
@@ -102,16 +118,22 @@
assert(interval > 0);
StackLock lock(_mutex);
+ while (g_timerCallbackRunning) {};
+ g_timerLock = true;
+
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;
}
@@ -119,6 +141,9 @@
void Timer::removeTimerProc(TimerProc procedure) {
StackLock lock(_mutex);
+ while (g_timerCallbackRunning) {};
+ g_timerLock = true;
+
for (int l = 0; l < MAX_TIMERS; l++) {
if (_timerSlots[l].procedure == procedure) {
_timerSlots[l].procedure = 0;
@@ -127,6 +152,8 @@
_timerSlots[l].refCon = 0;
}
}
+
+ g_timerLock = false;
}
MutexRef Timer::getMutex() {
Index: timer.h
===================================================================
RCS file: /cvsroot/scummvm/residual/timer.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- timer.h 26 Mar 2004 22:37:46 -0000 1.3
+++ timer.h 27 Mar 2004 14:28:53 -0000 1.4
@@ -70,6 +70,8 @@
};
extern Timer *g_timer;
+extern bool g_timerLock;
+extern bool g_timerCallbackRunning;
#endif
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword2 mouse.cpp,1.54,1.55 save_rest.cpp,1.50,1.51 sword2.cpp,1.106,1.107
- Next message: [Scummvm-cvs-logs] CVS: residual smush.cpp,1.38,1.39 timer.cpp,1.6,1.7 timer.h,1.4,1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list