[Scummvm-cvs-logs] CVS: scummvm/sword2 sound.cpp,1.54,1.55 sound.h,1.16,1.17

Robert Göffringmann lavosspawn at users.sourceforge.net
Mon Feb 21 00:35:59 CET 2005


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

Modified Files:
	sound.cpp sound.h 
Log Message:
basically the same change as for bs1; don't keep the mutex locked while loading mp3, ogg or wave data. it blocks the playing thread for too long.
Also added index caching for the speech and music clusters to reduce seeks.

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sound.cpp,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- sound.cpp	19 Feb 2005 14:02:13 -0000	1.54
+++ sound.cpp	21 Feb 2005 08:35:18 -0000	1.55
@@ -50,9 +50,24 @@
 	for (i = 0; i < FXQ_LENGTH; i++)
 		_fxQueue[i].resource = 0;
 
-	for (i = 0; i < MAXMUS; i++)
+	for (i = 0; i < MAXMUS; i++) {
 		_music[i] = NULL;
 
+		_musicFile[i].file = new File;
+		_musicFile[i].idxTab = NULL;
+		_musicFile[i].idxLen = 0;
+		_musicFile[i].fileSize = 0;
+		_musicFile[i].fileType = 0;
+		_musicFile[i].inUse = false;
+
+		_speechFile[i].file = new File;
+		_speechFile[i].idxTab = NULL;
+		_speechFile[i].idxLen = 0;
+		_speechFile[i].fileSize = 0;
+		_speechFile[i].fileType = 0;
+		_speechFile[i].inUse = false;
+	}
+
 	_speechPaused = false;
 	_musicPaused = false;
 	_fxPaused = false;
@@ -77,8 +92,10 @@
 	free(_mixBuffer);
 
 	for (int i = 0; i < MAXMUS; i++) {
-		if (_musicFile[i].isOpen())
-			_musicFile[i].close();
+		if (_musicFile[i].file->isOpen())
+			_musicFile[i].file->close();
+		if (_speechFile[i].file->isOpen())
+			_speechFile[i].file->close();
 	}
 }
 

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sound.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- sound.h	19 Feb 2005 14:02:13 -0000	1.16
+++ sound.h	21 Feb 2005 08:35:18 -0000	1.17
@@ -93,10 +93,20 @@
 	int getRate() const	{ return 22050; }
 };
 
+struct SoundFileHandle {
+	File *file;
+	uint32 *idxTab;
+	uint32 idxLen;
+	uint32 fileSize;
+	uint32 fileType;
+	volatile bool inUse;
+};
+
 class MusicInputStream : public AudioStream {
 private:
 	int _cd;
-	File *_file;
+	//File *_file;
+	SoundFileHandle *_fh;
 	uint32 _musicId;
 	AudioStream *_decoder;
 	int16 _buffer[BUFFER_SIZE];
@@ -119,7 +129,7 @@
 	}
 
 public:
-	MusicInputStream(int cd, File *fp, uint32 musicId, bool looping);
+	MusicInputStream(int cd, SoundFileHandle *fh, uint32 musicId, bool looping);
 	~MusicInputStream();
 
 	int readBuffer(int16 *buffer, const int numSamples);
@@ -176,7 +186,9 @@
 	PlayingSoundHandle _soundHandleSpeech;
 
 	MusicInputStream *_music[MAXMUS];
-	File _musicFile[MAXMUS];
+	//File _musicFile[MAXMUS];
+	SoundFileHandle _musicFile[MAXMUS];
+	SoundFileHandle _speechFile[MAXMUS];
 
 	int16 *_mixBuffer;
 	int _mixBufferLen;





More information about the Scummvm-git-logs mailing list