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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Jan 5 21:14:28 CET 2010


Revision: 47037
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47037&view=rev
Author:   lordhoto
Date:     2010-01-05 20:14:28 +0000 (Tue, 05 Jan 2010)

Log Message:
-----------
Remove unsafe getTotalPlayTime from AudioStream.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/lol.cpp
    scummvm/trunk/engines/kyra/lol.h
    scummvm/trunk/engines/kyra/sound.cpp
    scummvm/trunk/engines/kyra/sound.h
    scummvm/trunk/engines/kyra/sound_digital.cpp
    scummvm/trunk/engines/kyra/sound_lol.cpp
    scummvm/trunk/engines/queen/sound.cpp
    scummvm/trunk/sound/audiostream.cpp
    scummvm/trunk/sound/audiostream.h
    scummvm/trunk/sound/flac.cpp
    scummvm/trunk/sound/mp3.cpp
    scummvm/trunk/sound/vorbis.cpp

Modified: scummvm/trunk/engines/kyra/lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/lol.cpp	2010-01-05 20:13:31 UTC (rev 47036)
+++ scummvm/trunk/engines/kyra/lol.cpp	2010-01-05 20:14:28 UTC (rev 47037)
@@ -405,7 +405,7 @@
 		delete *i;
 	_spellProcs.clear();
 
-	for (Common::List<Audio::AudioStream *>::iterator i = _speechList.begin(); i != _speechList.end(); ++i)
+	for (SpeechList::iterator i = _speechList.begin(); i != _speechList.end(); ++i)
 		delete *i;
 	_speechList.clear();
 

Modified: scummvm/trunk/engines/kyra/lol.h
===================================================================
--- scummvm/trunk/engines/kyra/lol.h	2010-01-05 20:13:31 UTC (rev 47036)
+++ scummvm/trunk/engines/kyra/lol.h	2010-01-05 20:14:28 UTC (rev 47037)
@@ -489,7 +489,8 @@
 	uint16 _envSfxQueuedBlocks[10];
 	int _nextSpeechId;
 	int _nextSpeaker;
-	Common::List<Audio::AudioStream*> _speechList;
+	typedef Common::List<Audio::SeekableAudioStream *> SpeechList;
+	SpeechList _speechList;
 
 	int _curTlkFile;
 

Modified: scummvm/trunk/engines/kyra/sound.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound.cpp	2010-01-05 20:13:31 UTC (rev 47036)
+++ scummvm/trunk/engines/kyra/sound.cpp	2010-01-05 20:14:28 UTC (rev 47037)
@@ -74,21 +74,21 @@
 }
 
 int32 Sound::voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume, bool isSfx) {
-	Audio::AudioStream *audioStream = getVoiceStream(file);
+	Audio::SeekableAudioStream *audioStream = getVoiceStream(file);
 
 	if (!audioStream) {
 		return 0;
 	}
 
-	int playTime = audioStream->getTotalPlayTime();
+	int playTime = audioStream->getLength().msecs();
 	playVoiceStream(audioStream, handle, volume, isSfx);
 	return playTime;
 }
 
-Audio::AudioStream *Sound::getVoiceStream(const char *file) {
+Audio::SeekableAudioStream *Sound::getVoiceStream(const char *file) {
 	char filenamebuffer[25];
 
-	Audio::AudioStream *audioStream = 0;
+	Audio::SeekableAudioStream *audioStream = 0;
 	for (int i = 0; _supportedCodecs[i].fileext; ++i) {
 		strcpy(filenamebuffer, file);
 		strcat(filenamebuffer, _supportedCodecs[i].fileext);

Modified: scummvm/trunk/engines/kyra/sound.h
===================================================================
--- scummvm/trunk/engines/kyra/sound.h	2010-01-05 20:13:31 UTC (rev 47036)
+++ scummvm/trunk/engines/kyra/sound.h	2010-01-05 20:14:28 UTC (rev 47037)
@@ -186,7 +186,7 @@
 	 */
 	virtual int32 voicePlay(const char *file, Audio::SoundHandle *handle = 0, uint8 volume = 255, bool isSfx = false);
 
-	Audio::AudioStream *getVoiceStream(const char *file);
+	Audio::SeekableAudioStream *getVoiceStream(const char *file);
 
 	bool playVoiceStream(Audio::AudioStream *stream, Audio::SoundHandle *handle = 0, uint8 volume = 255, bool isSfx = false);
 

Modified: scummvm/trunk/engines/kyra/sound_digital.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_digital.cpp	2010-01-05 20:13:31 UTC (rev 47036)
+++ scummvm/trunk/engines/kyra/sound_digital.cpp	2010-01-05 20:14:28 UTC (rev 47037)
@@ -44,7 +44,6 @@
 	bool isStereo() const { return _impl->isStereo(); }
 	bool endOfData() const { return _impl->endOfData() | _endOfData; }
 	int getRate() const { return _rate; }
-	int32 getTotalPlayTime() const { return _impl->getTotalPlayTime(); }
 
 	void setRate(int newRate) { _rate = newRate; }
 	void beginFadeOut(uint32 millis);

Modified: scummvm/trunk/engines/kyra/sound_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_lol.cpp	2010-01-05 20:13:31 UTC (rev 47036)
+++ scummvm/trunk/engines/kyra/sound_lol.cpp	2010-01-05 20:14:28 UTC (rev 47037)
@@ -58,7 +58,7 @@
 	char file3[13];
 	file3[0] = 0;
 
-	Common::List<Audio::AudioStream *> newSpeechList;
+	SpeechList newSpeechList;
 
 	snprintf(pattern2, sizeof(pattern2), "%02d", id & 0x4000 ? 0 : _curTlkFile);
 
@@ -95,18 +95,18 @@
 	while (_sound->allVoiceChannelsPlaying())
 		delay(_tickLength);
 
-	for (Common::List<Audio::AudioStream *>::iterator i = _speechList.begin(); i != _speechList.end(); ++i)
+	for (SpeechList::iterator i = _speechList.begin(); i != _speechList.end(); ++i)
 		delete *i;
 	_speechList.clear();
 	_speechList = newSpeechList;
 
 	_activeVoiceFileTotalTime = 0;
-	for (Common::List<Audio::AudioStream *>::iterator i = _speechList.begin(); i != _speechList.end(); ++i) {
+	for (SpeechList::iterator i = _speechList.begin(); i != _speechList.end(); ++i) {
 		// Just in case any file loading failed: Remove the bad streams here.
 		if (!*i)
 			i = _speechList.erase(i);
 		else
-			_activeVoiceFileTotalTime += (*i)->getTotalPlayTime();
+			_activeVoiceFileTotalTime += (*i)->getLength().msecs();
 	}
 
 	_sound->playVoiceStream(*_speechList.begin(), &_speechHandle);
@@ -151,7 +151,7 @@
 	_activeVoiceFileTotalTime = 0;
 	_nextSpeechId = _nextSpeaker = -1;
 
-	for (Common::List<Audio::AudioStream *>::iterator i = _speechList.begin(); i != _speechList.end(); ++i)
+	for (SpeechList::iterator i = _speechList.begin(); i != _speechList.end(); ++i)
 		delete *i;
 	_speechList.clear();
 

Modified: scummvm/trunk/engines/queen/sound.cpp
===================================================================
--- scummvm/trunk/engines/queen/sound.cpp	2010-01-05 20:13:31 UTC (rev 47036)
+++ scummvm/trunk/engines/queen/sound.cpp	2010-01-05 20:14:28 UTC (rev 47037)
@@ -94,9 +94,6 @@
 	int getRate() const {
 		return _rate;
 	}
-	int32 getTotalPlayTime() {
-		return _stream->getTotalPlayTime();
-	}
 };
 
 class SilentSound : public PCSound {

Modified: scummvm/trunk/sound/audiostream.cpp
===================================================================
--- scummvm/trunk/sound/audiostream.cpp	2010-01-05 20:13:31 UTC (rev 47036)
+++ scummvm/trunk/sound/audiostream.cpp	2010-01-05 20:14:28 UTC (rev 47037)
@@ -168,12 +168,6 @@
 	bool endOfData() const			{ return _ptr >= _end; }
 
 	int getRate() const				{ return _rate; }
-	int32 getTotalPlayTime() const	{
-		if (!_numLoops)
-			return kUnknownPlayTime;
-		return _playtime * _numLoops;
-	}
-
 	bool seek(const Timestamp &where);
 	// TODO: We can definitly increase the precision here, since we know the exact sample count
 	Timestamp getLength() const { return Timestamp(_playtime, getRate()); }
@@ -331,11 +325,6 @@
 	bool endOfData() const			{ return (_currentBlock == _audioBlockCount - 1) && (_diskLeft == 0) && (_bufferLeft == 0); }
 
 	int getRate() const			{ return _rate; }
-	int32 getTotalPlayTime() const	{
-		if (!_numLoops)
-			return kUnknownPlayTime;
-		return _playtime * _numLoops;
-	}
 	// TODO: We can definitly increase the precision here, since we know the exact sample count
 	Timestamp getLength() const { return Timestamp(_playtime, getRate()); }
 

Modified: scummvm/trunk/sound/audiostream.h
===================================================================
--- scummvm/trunk/sound/audiostream.h	2010-01-05 20:13:31 UTC (rev 47036)
+++ scummvm/trunk/sound/audiostream.h	2010-01-05 20:14:28 UTC (rev 47037)
@@ -117,20 +117,6 @@
 	 * @param numLoops number of loops to play, 0 - infinite
 	 */
 	virtual uint getNumPlayedLoops() { return 0; }
-
-	enum {
-		kUnknownPlayTime = -1
-	};
-
-	/**
-	 * Returns total playtime of the AudioStream object.
-	 * Note that this does not require to return any playtime, if the
-	 * playtime of the AudioStream is unknown it returns 'kUnknownPlayTime'.
-	 * @see kUnknownPlayTime
-	 *
-	 * @return	playtime in milliseconds
-	 */
-	virtual int32 getTotalPlayTime() const { return kUnknownPlayTime; }
 };
 
 /**

Modified: scummvm/trunk/sound/flac.cpp
===================================================================
--- scummvm/trunk/sound/flac.cpp	2010-01-05 20:13:31 UTC (rev 47036)
+++ scummvm/trunk/sound/flac.cpp	2010-01-05 20:14:28 UTC (rev 47037)
@@ -143,12 +143,6 @@
 		return _streaminfo.channels == 0 || (_lastSampleWritten && _sampleCache.bufFill == 0);
 	}
 
-	int32 getTotalPlayTime() const {
-		if (!_numLoops)
-			return kUnknownPlayTime;
-		return _totalPlayTime * _numLoops;
-	}
-
 	bool seek(const Timestamp &where);
 	// TODO: We can definitly increase the precision here, since FLAC allows us to catch the sample count
 	Timestamp getLength() const { return Timestamp(_totalPlayTime, getRate()); }
@@ -256,7 +250,7 @@
 			_lastSample = (FLAC__uint64)(endTime * (_streaminfo.sample_rate / 1000.0));
 
 			if (_firstSample == 0 || seekAbsolute(_firstSample)) {
-				int32 samples = kUnknownPlayTime;
+				int32 samples = -1;
 
 				if (!_lastSample) {
 					if (_streaminfo.total_samples)
@@ -265,7 +259,7 @@
 					samples = _lastSample - _firstSample - 1;
 				}
 
-				if (samples != kUnknownPlayTime && samples >= 0 && numLoops) {
+				if (samples != -1 && samples >= 0 && numLoops) {
 					const int32 rate = _streaminfo.sample_rate;
 
 					int32 seconds = samples / rate;
@@ -273,7 +267,7 @@
 
 					_totalPlayTime = (seconds * 1000 + milliseconds);
 				} else {
-					_totalPlayTime = kUnknownPlayTime;
+					_totalPlayTime = 0;
 				}
 
 				return; // no error occured

Modified: scummvm/trunk/sound/mp3.cpp
===================================================================
--- scummvm/trunk/sound/mp3.cpp	2010-01-05 20:13:31 UTC (rev 47036)
+++ scummvm/trunk/sound/mp3.cpp	2010-01-05 20:14:28 UTC (rev 47037)
@@ -93,11 +93,6 @@
 	bool endOfData() const		{ return _state == MP3_STATE_EOS; }
 	bool isStereo() const		{ return MAD_NCHANNELS(&_frame.header) == 2; }
 	int getRate() const			{ return _frame.header.samplerate; }
-	int32 getTotalPlayTime() const {
-		if (!_numLoops)
-			return kUnknownPlayTime;
-		return _totalPlayTime * _numLoops;
-	}
 
 	bool seek(const Timestamp &where);
 	// TODO: Maybe we can have a more precise implementation of this
@@ -167,7 +162,7 @@
 	_totalPlayTime = mad_timer_count(length, MAD_UNITS_MILLISECONDS);
 
 	if (mad_timer_sign(length) < 0)
-		_totalPlayTime = kUnknownPlayTime;
+		_totalPlayTime = 0;
 
 	// Decode the first chunk of data. This is necessary so that _frame
 	// is setup and isStereo() and getRate() return correct results.

Modified: scummvm/trunk/sound/vorbis.cpp
===================================================================
--- scummvm/trunk/sound/vorbis.cpp	2010-01-05 20:13:31 UTC (rev 47036)
+++ scummvm/trunk/sound/vorbis.cpp	2010-01-05 20:14:28 UTC (rev 47037)
@@ -127,17 +127,6 @@
 	}
 	uint getNumPlayedLoops() { return _numPlayedLoops; }
 
-	int32 getTotalPlayTime() const {
-		if (!_numLoops)
-			return AudioStream::kUnknownPlayTime;
-
-#ifdef USE_TREMOR
-		return (_endTime - _startTime) * _numLoops;
-#else
-		return (int32)((_endTime - _startTime) * 1000.0) * _numLoops;
-#endif
-	}
-
 	bool seek(const Timestamp &where);
 	// TODO: Maybe we can have a more precise implementation of this
 	Timestamp getLength() const {


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