[Scummvm-cvs-logs] CVS: scummvm/sword2 controls.cpp,1.83,1.84 function.cpp,1.75,1.76 resman.cpp,1.104,1.105 sound.cpp,1.52,1.53 sound.h,1.14,1.15

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Tue Feb 8 00:34:42 CET 2005


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

Modified Files:
	controls.cpp function.cpp resman.cpp sound.cpp sound.h 
Log Message:
Now there are two file handles for the music: one for each CD. This is not
the same thing as one for each music stream. If both music streams are
playing music from the same CD, they will both take turns at using the same
file handle.

The only case where both file handles are used is when music from one CD is
fading in while music from the other CD is fading out. Which of course can
only happen if you play the game from hard disk. If the game has to ask for
the other CD, it kills the music immediately.

The reason for doing this is that there was some concern about whether
having two file handles open to the same file was portable or not. I don't
think that question was ever fully answered, so I avoid the situation.


Index: controls.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/controls.cpp,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- controls.cpp	28 Jan 2005 16:33:08 -0000	1.83
+++ controls.cpp	8 Feb 2005 08:32:48 -0000	1.84
@@ -1586,7 +1586,7 @@
 	// Restart the game. To do this, we must...
 
 	// Stop music instantly!
-	_vm->_sound->stopMusic();
+	_vm->_sound->stopMusic(true);
 
 	// In case we were dead - well we're not anymore!
 	Logic::_scriptVars[DEAD] = 0;

Index: function.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/function.cpp,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- function.cpp	28 Jan 2005 16:33:09 -0000	1.75
+++ function.cpp	8 Feb 2005 08:32:49 -0000	1.76
@@ -2095,7 +2095,7 @@
 int32 Logic::fnStopMusic(int32 *params) {
 	// params:	none
 
-	_vm->_sound->stopMusic();
+	_vm->_sound->stopMusic(false);
 	return IR_CONT;
 }
 

Index: resman.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/resman.cpp,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- resman.cpp	28 Jan 2005 16:33:10 -0000	1.104
+++ resman.cpp	8 Feb 2005 08:32:49 -0000	1.105
@@ -863,11 +863,11 @@
 void ResourceManager::getCd(int cd) {
 	byte *textRes;
 
-	// stop any music from playing - so the system no longer needs the
+	// Stop any music from playing - so the system no longer needs the
 	// current CD - otherwise when we take out the CD, Windows will
 	// complain!
 
-	_vm->_logic->fnStopMusic(NULL);
+	_vm->_sound->stopMusic(true);
 
 	textRes = openResource(2283);
 	_vm->displayMsg(_vm->fetchTextLine(textRes, 5 + cd) + 2, 0);

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sound.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- sound.cpp	28 Jan 2005 22:05:51 -0000	1.52
+++ sound.cpp	8 Feb 2005 08:32:49 -0000	1.53
@@ -71,13 +71,15 @@
 	_vm->_mixer->setupPremix(0);
 
 	clearFxQueue();
-	stopMusic();
+	stopMusic(true);
 	stopSpeech();
 
-	for (int i = 0; i < MAXMUS; i++)
-		delete _music[i];
-
 	free(_mixBuffer);
+
+	for (int i = 0; i < MAXMUS; i++) {
+		if (_musicFile[i].isOpen())
+			_musicFile[i].close();
+	}
 }
 
 /**

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sound.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- sound.h	7 Feb 2005 10:51:46 -0000	1.14
+++ sound.h	8 Feb 2005 08:32:49 -0000	1.15
@@ -31,6 +31,7 @@
 #ifndef SOUND_H
 #define SOUND_H
 
+#include "common/file.h"
 #include "sound/audiostream.h"
 #include "sound/mixer.h"
 
@@ -95,6 +96,7 @@
 class MusicInputStream : public AudioStream {
 private:
 	int _cd;
+	File *_file;
 	uint32 _musicId;
 	AudioStream *_decoder;
 	int16 _buffer[BUFFER_SIZE];
@@ -117,7 +119,7 @@
 	}
 
 public:
-	MusicInputStream(int cd, uint32 musicId, bool looping);
+	MusicInputStream(int cd, File *fp, uint32 musicId, bool looping);
 	~MusicInputStream();
 
 	int readBuffer(int16 *buffer, const int numSamples);
@@ -172,8 +174,10 @@
 	int32 _loopingMusicId;
 
 	PlayingSoundHandle _soundHandleSpeech;
-	
+
 	MusicInputStream *_music[MAXMUS];
+	File _musicFile[MAXMUS];
+
 	int16 *_mixBuffer;
 	int _mixBufferLen;
 
@@ -184,9 +188,9 @@
 	// AudioStream API
 
 	int readBuffer(int16 *buffer, const int numSamples);
-	bool isStereo() const;
+	bool isStereo() const { return false; }
 	bool endOfData() const;
-	int getRate() const;
+	int getRate() const { return 22050; }
 
 	// End of AudioStream API
 
@@ -233,7 +237,7 @@
 	int32 stopSpeech();
 
 	int32 streamCompMusic(uint32 musicId, bool loop);
-	void stopMusic();
+	void stopMusic(bool immediately);
 	int32 musicTimeRemaining();
 };
 





More information about the Scummvm-git-logs mailing list