[Scummvm-cvs-logs] CVS: scummvm/scumm/smush smush_mixer.cpp,1.39,1.40 smush_mixer.h,1.13,1.14 smush_player.cpp,1.152,1.153

Max Horn fingolfin at users.sourceforge.net
Mon Apr 4 11:43:09 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm/smush
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26299/smush

Modified Files:
	smush_mixer.cpp smush_mixer.h smush_player.cpp 
Log Message:
Got rid of isSoundHandleActive usage; made the SmushMixer thread safe

Index: smush_mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_mixer.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- smush_mixer.cpp	12 Mar 2005 18:55:45 -0000	1.39
+++ smush_mixer.cpp	4 Apr 2005 18:42:35 -0000	1.40
@@ -39,16 +39,19 @@
 	for (int32 i = 0; i < NUM_CHANNELS; i++) {
 		_channels[i].id = -1;
 		_channels[i].chan = NULL;
+		_channels[i].stream = NULL;
 	}
 }
 
 SmushMixer::~SmushMixer() {
+	Common::StackLock lock(_mutex);
 	for (int32 i = 0; i < NUM_CHANNELS; i++) {
 		_mixer->stopHandle(_channels[i].handle);
 	}
 }
 
 SmushChannel *SmushMixer::findChannel(int32 track) {
+	Common::StackLock lock(_mutex);
 	debugC(DEBUG_SMUSH, "SmushMixer::findChannel(%d)", track);
 	for (int32 i = 0; i < NUM_CHANNELS; i++) {
 		if (_channels[i].id == track)
@@ -58,6 +61,7 @@
 }
 
 void SmushMixer::addChannel(SmushChannel *c) {
+	Common::StackLock lock(_mutex);
 	int32 track = c->getTrackIdentifier();
 	int i;
 
@@ -86,6 +90,7 @@
 }
 
 bool SmushMixer::handleFrame() {
+	Common::StackLock lock(_mutex);
 	debugC(DEBUG_SMUSH, "SmushMixer::handleFrame()");
 	for (int i = 0; i < NUM_CHANNELS; i++) {
 		if (_channels[i].id != -1) {
@@ -120,7 +125,7 @@
 				}
 
 				if (_mixer->isReady()) {
-					if (!_mixer->isSoundHandleActive(_channels[i].handle)) {
+					if (!_channels[i].stream) {
 						_channels[i].stream = makeAppendableAudioStream(rate, flags, 500000);
 						_mixer->playInputStream(SoundMixer::kSFXSoundType, &_channels[i].handle, _channels[i].stream);
 					}
@@ -136,6 +141,7 @@
 }
 
 bool SmushMixer::stop() {
+	Common::StackLock lock(_mutex);
 	debugC(DEBUG_SMUSH, "SmushMixer::stop()");
 	for (int i = 0; i < NUM_CHANNELS; i++) {
 		if (_channels[i].id != -1) {

Index: smush_mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_mixer.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- smush_mixer.h	12 Mar 2005 18:55:45 -0000	1.13
+++ smush_mixer.h	4 Apr 2005 18:42:35 -0000	1.14
@@ -45,6 +45,8 @@
 
 	int _soundFrequency;
 
+	Common::Mutex _mutex;
+
 public:
 
 	SmushMixer(SoundMixer *);

Index: smush_player.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_player.cpp,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -d -r1.152 -r1.153
--- smush_player.cpp	3 Apr 2005 06:40:44 -0000	1.152
+++ smush_player.cpp	4 Apr 2005 18:42:35 -0000	1.153
@@ -509,7 +509,7 @@
 						}
 					} while (--count);
 
-					if (!_vm->_mixer->isSoundHandleActive(_IACTchannel)) {
+					if (!_IACTstream) {
 						_IACTstream = makeAppendableAudioStream(22050, SoundMixer::FLAG_STEREO | SoundMixer::FLAG_16BITS, 400000);
 						_vm->_mixer->playInputStream(SoundMixer::kSFXSoundType, &_IACTchannel, _IACTstream);
 					}





More information about the Scummvm-git-logs mailing list