[Scummvm-cvs-logs] CVS: scummvm/scumm imuse_digi.cpp,1.90,1.91 imuse_digi.h,1.24,1.25

Max Horn fingolfin at users.sourceforge.net
Fri Dec 26 13:41:02 CET 2003


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

Modified Files:
	imuse_digi.cpp imuse_digi.h 
Log Message:
change IMuseDigital to 'own' the AudioInputStream (the idea is that eventually it can use a custom AudioInputStream, and thus implement a pull interface instead of push one)

Index: imuse_digi.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi.cpp,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- imuse_digi.cpp	26 Dec 2003 20:16:34 -0000	1.90
+++ imuse_digi.cpp	26 Dec 2003 21:40:29 -0000	1.91
@@ -661,6 +661,10 @@
 	return s_size;
 }
 
+IMuseDigital::Channel::Channel()
+	: idSound(-1), used(false), stream(0) {
+}
+
 void IMuseDigital::timer_handler(void *refCon) {
 	IMuseDigital *imuseDigital = (IMuseDigital *)refCon;
 	imuseDigital->callback();
@@ -691,6 +695,7 @@
 
 	for (int l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
 		_scumm->_mixer->stopHandle(_channel[l].handle);
+		delete _channel[l].stream;
 	}
 
 	delete _bundle;
@@ -706,7 +711,8 @@
 		if (_channel[l].used) {
 			if (_channel[l].toBeRemoved) {
 				debug(5, "IMuseDigital::callback(): stoped sound: %d", _channel[l].idSound);
-				_scumm->_mixer->endStream(_channel[l].handle);
+				if (_channel[l].stream)
+					_channel[l].stream->finish();
 				free(_channel[l].data);
 				_channel[l].used = false;
 				continue;
@@ -745,12 +751,15 @@
 
 			int pan = (_channel[l].pan != 64) ? 2 * _channel[l].pan - 127 : 0;
 			if (_scumm->_mixer->isReady()) {
-				if (!_channel[l].handle.isActive())
-					_scumm->_mixer->newStream(&_channel[l].handle, _channel[l].freq,
-											_channel[l].mixerFlags, 100000);
-				_scumm->_mixer->setChannelVolume(_channel[l].handle, _channel[l].vol / 1000);
-				_scumm->_mixer->setChannelPan(_channel[l].handle, pan);
-				_scumm->_mixer->appendStream(_channel[l].handle, _channel[l].data + _channel[l].offset, mixer_size);
+				if (!_channel[l].stream) {
+					// Create an AudioInputStream and hook it to the mixer.
+					_channel[l].stream = makeWrappedInputStream(_channel[l].freq, _channel[l].mixerFlags, 100000);
+					_scumm->_mixer->playInputStream(&_channel[l].handle, _channel[l].stream, true, _channel[l].vol / 1000, _channel[l].pan, -1, false);
+				} else {
+					_scumm->_mixer->setChannelVolume(_channel[l].handle, _channel[l].vol / 1000);
+					_scumm->_mixer->setChannelPan(_channel[l].handle, pan);
+				}
+				_channel[l].stream->append(_channel[l].data + _channel[l].offset, mixer_size);
 			}
 			_channel[l].offset += mixer_size;
 		}
@@ -802,6 +811,9 @@
 
 			_channel[l].offset = 0;
 			_channel[l].idSound = sound;
+			
+			delete _channel[l].stream;
+			_channel[l].stream = 0;
 
 			uint32 tag;
 			int32 size = 0;

Index: imuse_digi.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- imuse_digi.h	26 Dec 2003 12:15:23 -0000	1.24
+++ imuse_digi.h	26 Dec 2003 21:40:30 -0000	1.25
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "scumm/music.h"
+#include "sound/audiostream.h"
 #include "sound/mixer.h"
 
 namespace Scumm {
@@ -84,11 +85,12 @@
 		int idSound;
 		int32 mixerSize;
 		int mixerFlags;
-		PlayingSoundHandle handle;
 		bool used;
 		bool toBeRemoved;
+		PlayingSoundHandle handle;
+		WrappedAudioInputStream *stream;
 		
-		Channel() : idSound(-1), used(false) {}
+		Channel();
 	};
 
 	Channel _channel[MAX_DIGITAL_CHANNELS];





More information about the Scummvm-git-logs mailing list