[Scummvm-cvs-logs] CVS: scummvm/scumm imuse_digi.cpp,1.21,1.22 imuse_digi.h,1.4,1.5 sound.cpp,1.139,1.140

Max Horn fingolfin at users.sourceforge.net
Sat Jun 21 16:30:02 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv15126

Modified Files:
	imuse_digi.cpp imuse_digi.h sound.cpp 
Log Message:
lots of mixer cleanup / refactoring / reengineering

Index: imuse_digi.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- imuse_digi.cpp	21 Jun 2003 21:17:08 -0000	1.21
+++ imuse_digi.cpp	21 Jun 2003 23:29:34 -0000	1.22
@@ -94,16 +94,16 @@
 	memset(_channel, 0, sizeof(Channel) * MAX_DIGITAL_CHANNELS);
 	_scumm = scumm;
 	for (int32 l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
-		_channel[l]._initialized = false;
+		_channel[l]._mixerChannel = -1;
 	}
-	_scumm->_mixer->beginSlots(MAX_DIGITAL_CHANNELS + 1);
 	_scumm->_timer->installProcedure(imus_digital_handler, 200000);
 	_pause = false;
 }
 
 IMuseDigital::~IMuseDigital() {
 	for (int32 l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
-		_scumm->_mixer->stop(l);
+		if (_channel[l]._mixerChannel != -1)
+			_scumm->_mixer->stop(_channel[l]._mixerChannel);
 	}
 	_scumm->_timer->releaseProcedure(imus_digital_handler);
 }
@@ -708,17 +708,20 @@
 void IMuseDigital::handler() {
 	uint32 l = 0, i = 0;
 
-	if (_pause == true)
+	if (_pause)
 		return;
 
 	for (l = 0; l < MAX_DIGITAL_CHANNELS;l ++) {
 		if (_channel[l]._used) {
 			if (_channel[l]._toBeRemoved == true) {
-				_scumm->_mixer->stop(l);
+				if (_channel[l]._mixerChannel != -1) {
+					_scumm->_mixer->stop(_channel[l]._mixerChannel);
+					_channel[l]._mixerChannel = -1;
+				}
 				if (_scumm->_mixer->_channels[l] == NULL) {
 					free(_channel[l]._data);
 					_channel[l]._used = false;
-					_channel[l]._initialized = false;
+					_channel[l]._mixerChannel = -1;
 				}
 				continue;
 			}
@@ -764,7 +767,7 @@
 			uint32 new_size = _channel[l]._mixerSize;
 			uint32 mixer_size = new_size;
 
-			if (_channel[l]._initialized == false) {
+			if (_channel[l]._mixerChannel == -1) {
 				mixer_size *= 2;
 				new_size *= 2;
 			}
@@ -820,12 +823,11 @@
 			}
 
 			if (_scumm->_silentDigitalImuse == false) {
-				if (_channel[l]._initialized == false) {
-					_scumm->_mixer->playStream(l, buf, mixer_size,
-					                           _channel[l]._freq, _channel[l]._mixerFlags, 3, 100000);
-					_channel[l]._initialized = true;
+				if (_channel[l]._mixerChannel == -1) {
+					_channel[l]._mixerChannel = _scumm->_mixer->playStream(buf, mixer_size,
+					                           _channel[l]._freq, _channel[l]._mixerFlags, 100000);
 				} else {
-					_scumm->_mixer->append(l, buf, mixer_size);
+					_scumm->_mixer->append(_channel[l]._mixerChannel, buf, mixer_size);
 				}
 			}
 			free(buf);

Index: imuse_digi.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- imuse_digi.h	15 Jun 2003 01:42:15 -0000	1.4
+++ imuse_digi.h	21 Jun 2003 23:29:34 -0000	1.5
@@ -69,9 +69,9 @@
 		int32 _idSound;
 		uint32 _mixerSize;
 		uint8 _mixerFlags;
+		int _mixerChannel;
 		bool _used;
 		bool _toBeRemoved;
-		bool _initialized;
 	};
 	
 	Channel _channel[MAX_DIGITAL_CHANNELS];

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -d -r1.139 -r1.140
--- sound.cpp	21 Jun 2003 21:17:08 -0000	1.139
+++ sound.cpp	21 Jun 2003 23:29:34 -0000	1.140
@@ -1176,8 +1176,8 @@
 
 	_bundleMusicPosition += final_size;
 	if (_bundleMusicTrack == -1) {
-		_bundleMusicTrack = _scumm->_mixer->playStream(_scumm->_mixer->_beginSlots - 1, buffer, final_size, rate,
-															SoundMixer::FLAG_16BITS | SoundMixer::FLAG_STEREO, -1, 300000);
+		_bundleMusicTrack = _scumm->_mixer->playStream(buffer, final_size, rate,
+															SoundMixer::FLAG_16BITS | SoundMixer::FLAG_STEREO, 300000);
 	} else {
 		_scumm->_mixer->append(_bundleMusicTrack, buffer, final_size);
 	}





More information about the Scummvm-git-logs mailing list