[Scummvm-cvs-logs] CVS: residual smush.cpp,1.39,1.40 smush.h,1.20,1.21
Pawel Kolodziejski
aquadran at users.sourceforge.net
Mon Apr 26 03:05:07 CEST 2004
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2643
Modified Files:
smush.cpp smush.h
Log Message:
added mutex for smush and cleanup
Index: smush.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/smush.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- smush.cpp 27 Mar 2004 14:52:31 -0000 1.39
+++ smush.cpp 26 Apr 2004 10:03:59 -0000 1.40
@@ -23,10 +23,11 @@
#include "smush.h"
#include "timer.h"
#include "mixer/mixer.h"
-#include "driver_gl.h"
#include "resource.h"
#include "engine.h"
+#include "driver_gl.h"
+
Smush *g_smush;
extern SoundMixer *g_mixer;
@@ -36,8 +37,10 @@
Smush::Smush() {
g_smush = this;
+ _mutex = create_mutex();
_nbframes = 0;
- _dst = NULL;
+ _internalBuffer = NULL;
+ _externalBuffer = NULL;
_width = 0;
_height = 0;
_speed = 0;
@@ -48,19 +51,24 @@
_updateNeeded = false;
_stream = NULL;
_movieTime = 0;
- _surface = NULL;
- _bufSurface = NULL;
}
Smush::~Smush() {
deinit();
- if (_surface)
- SDL_FreeSurface(_surface);
- if (_bufSurface)
- SDL_FreeSurface(_bufSurface);
+ if (_internalBuffer) {
+ free(_internalBuffer);
+ _internalBuffer = NULL;
+ }
+ if (_externalBuffer) {
+ free(_externalBuffer);
+ _externalBuffer = NULL;
+ }
+
+ delete_mutex(_mutex);
}
void Smush::init() {
+ StackLock lock(_mutex);
_stream = NULL;
_frame = 0;
_movieTime = 0;
@@ -68,19 +76,18 @@
_videoPause = false;
_updateNeeded = false;
- if (!_surface) {
- _surface = SDL_CreateRGBSurface(SDL_SWSURFACE, _width, _height, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000);
- _dst = (byte *)_surface->pixels;
+ if (!_internalBuffer) {
+ _internalBuffer = (byte *)malloc(_width * _height * 2);
}
- if (!_bufSurface) {
- _bufSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, _width, _height, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000);
- _buf = (byte *)_bufSurface->pixels;
+ if (!_externalBuffer) {
+ _externalBuffer = (byte *)malloc(_width * _height * 2);
}
g_timer->installTimerProc(&timerCallback, _speed, NULL);
}
void Smush::deinit() {
+ StackLock lock(_mutex);
g_timer->removeTimerProc(&timerCallback);
_videoFinished = true;
@@ -88,12 +95,13 @@
if (_stream) {
_stream->finish();
_stream = NULL;
+ g_mixer->stopHandle(_soundHandle);
}
_file.close();
}
void Smush::handleBlocky16(byte *src) {
- _blocky16.decode(_dst, src);
+ _blocky16.decode(_internalBuffer, src);
}
static uint16 destTable[5786];
@@ -112,7 +120,6 @@
#endif
int flags = SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE;
-// int flags = SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_LITTLE_ENDIAN;
if (_channels == 2)
flags |= SoundMixer::FLAG_STEREO;
@@ -125,6 +132,7 @@
}
void Smush::handleFrame() {
+ StackLock lock(_mutex);
uint32 tag;
int32 size;
int pos = 0;
@@ -167,7 +175,7 @@
} while (pos < size);
free(frame);
- memcpy(_buf, _dst, _width * _height * 2);
+ memcpy(_externalBuffer, _internalBuffer, _width * _height * 2);
_updateNeeded = true;
_frame++;
Index: smush.h
===================================================================
RCS file: /cvsroot/scummvm/residual/smush.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- smush.h 27 Mar 2004 15:41:32 -0000 1.20
+++ smush.h 26 Apr 2004 10:03:59 -0000 1.21
@@ -56,6 +56,7 @@
zlibFile _file;
PlayingSoundHandle _soundHandle;
AppendableAudioStream *_stream;
+ MutexRef _mutex;
int32 _frame;
bool _updateNeeded;
@@ -67,9 +68,7 @@
bool _videoPause;
int _x, _y;
int _width, _height;
- byte *_dst, *_buf;
- SDL_Surface* _surface;
- SDL_Surface* _bufSurface;
+ byte *_internalBuffer, *_externalBuffer;
public:
Smush();
@@ -80,7 +79,7 @@
void pause(bool pause) { _videoPause = pause; }
bool isPlaying() { return !_videoFinished; }
bool isUpdateNeeded() { return _updateNeeded; }
- byte *getDstPtr() { return _buf; }
+ byte *getDstPtr() { return _externalBuffer; }
int getX() { return _x; }
int getY() { return _y; }
int getWidth() {return _width; }
More information about the Scummvm-git-logs
mailing list