[Scummvm-cvs-logs] CVS: scummvm/sound audiostream.cpp,1.55,1.55.2.1 audiostream.h,1.31,1.31.2.1 mixer.cpp,1.157,1.157.2.1

Pawel Kolodziejski aquadran at users.sourceforge.net
Sun May 2 09:37:10 CEST 2004


Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13901/sound

Modified Files:
      Tag: branch-0-6-0
	audiostream.cpp audiostream.h mixer.cpp 
Log Message:
backported imuse digital from head cvs except save/load code

Index: audiostream.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/audiostream.cpp,v
retrieving revision 1.55
retrieving revision 1.55.2.1
diff -u -d -r1.55 -r1.55.2.1
--- audiostream.cpp	8 Feb 2004 17:19:09 -0000	1.55
+++ audiostream.cpp	2 May 2004 16:36:04 -0000	1.55.2.1
@@ -141,8 +141,10 @@
 	byte *_end;
 	bool _finalized;
 	const int _rate;
+	uint32 _freeSpace;
 
 	inline bool eosIntern() const { return _end == _pos; };
+	void updateFreeSpace();
 public:
 	AppendableMemoryStream(int rate, uint bufferSize);
 	~AppendableMemoryStream()		{ free(_bufferStart); }
@@ -157,8 +159,19 @@
 
 	void append(const byte *data, uint32 len);
 	void finish()				{ _finalized = true; }
+	uint32 getFreeSpace();
 };
 
+template<bool stereo, bool is16Bit, bool isUnsigned>
+void AppendableMemoryStream<stereo, is16Bit, isUnsigned>::updateFreeSpace() {
+	if (_pos <= _end) {
+		uint32 free_from_end = _bufferEnd - _end;
+		uint32 free_to_pos = _pos - _bufferStart;
+		_freeSpace = free_from_end + free_to_pos;
+	} else {
+		_freeSpace = _pos - _end;
+	}
+}
 
 template<bool stereo, bool is16Bit, bool isUnsigned>
 AppendableMemoryStream<stereo, is16Bit, isUnsigned>::AppendableMemoryStream(int rate, uint bufferSize)
@@ -173,6 +186,8 @@
 	_bufferStart = (byte *)malloc(bufferSize);
 	_pos = _end = _bufferStart;
 	_bufferEnd = _bufferStart + bufferSize;
+
+	updateFreeSpace();
 }
 
 template<bool stereo, bool is16Bit, bool isUnsigned>
@@ -186,6 +201,8 @@
 	int16 val = READSAMPLE(is16Bit, isUnsigned, _pos);
 	_pos += (is16Bit ? 2 : 1);
 
+	updateFreeSpace();
+
 	return val;
 }
 
@@ -205,6 +222,9 @@
 			samples++;
 		}
 	}
+
+	updateFreeSpace();
+
 	return samples;
 }
 
@@ -239,8 +259,14 @@
 		memcpy(_end, data, len);
 		_end += len;
 	}
+
+	updateFreeSpace();
 }
 
+template<bool stereo, bool is16Bit, bool isUnsigned>
+uint32 AppendableMemoryStream<stereo, is16Bit, isUnsigned>::getFreeSpace() {
+	return _freeSpace;
+}
 
 #pragma mark -
 #pragma mark --- Procedural stream ---

Index: audiostream.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/audiostream.h,v
retrieving revision 1.31
retrieving revision 1.31.2.1
diff -u -d -r1.31 -r1.31.2.1
--- audiostream.h	12 Feb 2004 17:31:33 -0000	1.31
+++ audiostream.h	2 May 2004 16:36:05 -0000	1.31.2.1
@@ -80,6 +80,7 @@
 public:
 	virtual void append(const byte *data, uint32 len) = 0;
 	virtual void finish() = 0;
+	virtual uint32 getFreeSpace() = 0;
 };
 
 class ZeroInputStream : public AudioStream {

Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.157
retrieving revision 1.157.2.1
diff -u -d -r1.157 -r1.157.2.1
--- mixer.cpp	12 Feb 2004 16:25:28 -0000	1.157
+++ mixer.cpp	2 May 2004 16:36:05 -0000	1.157.2.1
@@ -450,10 +450,6 @@
 }
 
 bool SoundMixer::hasActiveSFXChannel() {
-	// FIXME/TODO: We need to distinguish between SFX and music channels
-	// (and maybe also voice) here to work properly in iMuseDigital
-	// games. In the past that was achieve using the _beginSlots hack.
-	// Since we don't have that anymore, it's not that simple anymore.
 	Common::StackLock lock(_mutex);
 	for (int i = 0; i != NUM_CHANNELS; i++)
 		if (_channels[i] && !_channels[i]->isMusicChannel())





More information about the Scummvm-git-logs mailing list