[Scummvm-cvs-logs] SF.net SVN: scummvm: [25836] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Feb 25 00:19:53 CET 2007


Revision: 25836
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25836&view=rev
Author:   fingolfin
Date:     2007-02-24 15:19:53 -0800 (Sat, 24 Feb 2007)

Log Message:
-----------
Added numLoops parameter to DigitalTrackInfo::play

Modified Paths:
--------------
    scummvm/trunk/engines/saga/music.cpp
    scummvm/trunk/sound/audiocd.cpp
    scummvm/trunk/sound/audiocd.h
    scummvm/trunk/sound/flac.cpp
    scummvm/trunk/sound/mp3.cpp
    scummvm/trunk/sound/vorbis.cpp

Modified: scummvm/trunk/engines/saga/music.cpp
===================================================================
--- scummvm/trunk/engines/saga/music.cpp	2007-02-24 23:19:17 UTC (rev 25835)
+++ scummvm/trunk/engines/saga/music.cpp	2007-02-24 23:19:53 UTC (rev 25836)
@@ -416,7 +416,7 @@
 			break;
 		}
 	if (_track) {
-		_track->play(_mixer, &_musicHandle, (flags == MUSIC_LOOP) ? -1 : 1, 10000);
+		_track->play(_mixer, &_musicHandle, 1, (flags == MUSIC_LOOP) ? -1 : 1, 10000);
 		return;
 	}
 

Modified: scummvm/trunk/sound/audiocd.cpp
===================================================================
--- scummvm/trunk/sound/audiocd.cpp	2007-02-24 23:19:17 UTC (rev 25835)
+++ scummvm/trunk/sound/audiocd.cpp	2007-02-24 23:19:53 UTC (rev 25836)
@@ -91,7 +91,13 @@
 		if (index >= 0) {
 			_mixer->stopHandle(_cd.handle);
 			_cd.playing = true;
-			_trackInfo[index]->play(_mixer, &_cd.handle, _cd.start, _cd.duration);
+			/*
+			FIXME: Seems numLoops == 0 and numLoops == 1 both indicate a single repetition,
+			while all other positive numbers indicate precisely the number of desired
+			repetitions. Finally, -1 means infinitely many
+			*/
+			numLoops = (numLoops < 1) ? numLoops + 1 : numLoops;
+			_trackInfo[index]->play(_mixer, &_cd.handle, numLoops, _cd.start, _cd.duration);
 		} else {
 			g_system->playCD(track, numLoops, startFrame, duration);
 			_cd.playing = false;
@@ -114,19 +120,13 @@
 
 void AudioCDManager::updateCD() {
 	if (_cd.playing) {
-		// If the sound handle is 0, then playback stopped.
+		// Check whether the audio track stopped playback
 		if (!_mixer->isSoundHandleActive(_cd.handle)) {
-			// If playback just stopped, check if the current track is supposed
-			// to be repeated, and if that's the case, play it again. Else, stop
-			// the CD explicitly.
-			if (_cd.numLoops == -1 || --_cd.numLoops > 0) {
-				int index = getCachedTrack(_cd.track);
-				assert(index >= 0);
-				_trackInfo[index]->play(_mixer, &_cd.handle, _cd.start, _cd.duration);
-			} else {
-				_mixer->stopHandle(_cd.handle);
-				_cd.playing = false;
-			}
+			// FIXME: We do not update the numLoops parameter here (and in fact,
+			// currently can't do that). Luckily, only one engine ever checks
+			// this part of the AudioCD status, namely the SCUMM engine; and it
+			// only checks
+			_cd.playing = false;
 		}
 	} else {
 		g_system->updateCD();

Modified: scummvm/trunk/sound/audiocd.h
===================================================================
--- scummvm/trunk/sound/audiocd.h	2007-02-24 23:19:17 UTC (rev 25835)
+++ scummvm/trunk/sound/audiocd.h	2007-02-24 23:19:53 UTC (rev 25836)
@@ -36,7 +36,7 @@
 public:
 	virtual ~DigitalTrackInfo() {}
 
-	virtual void play(Mixer *mixer, SoundHandle *handle, int startFrame, int duration) = 0;
+	virtual void play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration) = 0;
 //	virtual void stop();
 };
 

Modified: scummvm/trunk/sound/flac.cpp
===================================================================
--- scummvm/trunk/sound/flac.cpp	2007-02-24 23:19:17 UTC (rev 25835)
+++ scummvm/trunk/sound/flac.cpp	2007-02-24 23:19:53 UTC (rev 25836)
@@ -780,7 +780,7 @@
 public:
 	FlacTrackInfo(const char *filename);
 	bool error() { return _errorFlag; }
-	void play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration);
+	void play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration);
 };
 
 FlacTrackInfo::FlacTrackInfo(const char *filename) :
@@ -804,7 +804,7 @@
 	delete tempStream;
 }
 
-void FlacTrackInfo::play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration) {
+void FlacTrackInfo::play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration) {
 	assert(!_errorFlag);
 
 	if (error()) {
@@ -824,7 +824,7 @@
 	uint end = duration ? ((startFrame + duration) * 1000 / 75) : 0;
 
 	// ... create an AudioStream ...
-	FlacInputStream *input = new FlacInputStream(file, true, start, end);
+	FlacInputStream *input = new FlacInputStream(file, true, start, end, numLoops);
 	if (!input->isStreamDecoderReady()) {
 		delete input;
 		return;

Modified: scummvm/trunk/sound/mp3.cpp
===================================================================
--- scummvm/trunk/sound/mp3.cpp	2007-02-24 23:19:17 UTC (rev 25835)
+++ scummvm/trunk/sound/mp3.cpp	2007-02-24 23:19:53 UTC (rev 25836)
@@ -346,7 +346,7 @@
 public:
 	MP3TrackInfo(const char *filename);
 	bool error() { return _errorFlag; }
-	void play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration);
+	void play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration);
 };
 
 MP3TrackInfo::MP3TrackInfo(const char *filename) :
@@ -371,7 +371,7 @@
 	delete tempStream;
 }
 
-void MP3TrackInfo::play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration) {
+void MP3TrackInfo::play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration) {
 	assert(!_errorFlag);
 
 	mad_timer_t start;
@@ -396,7 +396,7 @@
 	}
 
 	// ... create an AudioStream ...
-	MP3InputStream *input = new MP3InputStream(file, true, start, end);
+	MP3InputStream *input = new MP3InputStream(file, true, start, end, numLoops);
 	
 	// ... and play it
 	mixer->playInputStream(Audio::Mixer::kMusicSoundType, handle, input);

Modified: scummvm/trunk/sound/vorbis.cpp
===================================================================
--- scummvm/trunk/sound/vorbis.cpp	2007-02-24 23:19:17 UTC (rev 25835)
+++ scummvm/trunk/sound/vorbis.cpp	2007-02-24 23:19:53 UTC (rev 25836)
@@ -306,7 +306,7 @@
 public:
 	VorbisTrackInfo(const char *filename);
 	bool error() { return _errorFlag; }
-	void play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration);
+	void play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration);
 };
 
 VorbisTrackInfo::VorbisTrackInfo(const char *filename) :
@@ -332,7 +332,7 @@
 	delete tempStream;
 }
 
-void VorbisTrackInfo::play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration) {
+void VorbisTrackInfo::play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration) {
 	assert(!_errorFlag);
 
 	// Open the file
@@ -349,7 +349,7 @@
 	uint end = duration ? ((startFrame + duration) * 40 / 3) : 0;
 
 	// ... create an AudioStream ...
-	VorbisInputStream *input = new VorbisInputStream(file, true, start, end);
+	VorbisInputStream *input = new VorbisInputStream(file, true, start, end, numLoops);
 	
 	// ... and play it
 	mixer->playInputStream(Audio::Mixer::kMusicSoundType, handle, input);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list