diff options
| -rw-r--r-- | engines/kyra/lol.cpp | 2 | ||||
| -rw-r--r-- | engines/kyra/lol.h | 3 | ||||
| -rw-r--r-- | engines/kyra/sound.cpp | 8 | ||||
| -rw-r--r-- | engines/kyra/sound.h | 2 | ||||
| -rw-r--r-- | engines/kyra/sound_digital.cpp | 1 | ||||
| -rw-r--r-- | engines/kyra/sound_lol.cpp | 10 | ||||
| -rw-r--r-- | engines/queen/sound.cpp | 3 | ||||
| -rw-r--r-- | sound/audiostream.cpp | 11 | ||||
| -rw-r--r-- | sound/audiostream.h | 14 | ||||
| -rw-r--r-- | sound/flac.cpp | 12 | ||||
| -rw-r--r-- | sound/mp3.cpp | 7 | ||||
| -rw-r--r-- | sound/vorbis.cpp | 11 | 
12 files changed, 17 insertions, 67 deletions
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index a441874134..299963b330 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -405,7 +405,7 @@ LoLEngine::~LoLEngine() {  		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(); diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h index fa66f996bc..7a49085f6c 100644 --- a/engines/kyra/lol.h +++ b/engines/kyra/lol.h @@ -489,7 +489,8 @@ private:  	uint16 _envSfxQueuedBlocks[10];  	int _nextSpeechId;  	int _nextSpeaker; -	Common::List<Audio::AudioStream*> _speechList; +	typedef Common::List<Audio::SeekableAudioStream *> SpeechList; +	SpeechList _speechList;  	int _curTlkFile; diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index e5ae400de3..34c9b3d223 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -74,21 +74,21 @@ bool Sound::isVoicePresent(const char *file) {  }  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); diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index 57b51e594c..5d54a1603b 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -186,7 +186,7 @@ public:  	 */  	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); diff --git a/engines/kyra/sound_digital.cpp b/engines/kyra/sound_digital.cpp index aaae5eaece..a1ba472b37 100644 --- a/engines/kyra/sound_digital.cpp +++ b/engines/kyra/sound_digital.cpp @@ -44,7 +44,6 @@ public:  	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); diff --git a/engines/kyra/sound_lol.cpp b/engines/kyra/sound_lol.cpp index 328a0e02d0..ad090609d1 100644 --- a/engines/kyra/sound_lol.cpp +++ b/engines/kyra/sound_lol.cpp @@ -58,7 +58,7 @@ bool LoLEngine::snd_playCharacterSpeech(int id, int8 speaker, int) {  	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 @@ bool LoLEngine::snd_playCharacterSpeech(int id, int8 speaker, int) {  	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 @@ void LoLEngine::snd_stopSpeech(bool setFlag) {  	_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(); diff --git a/engines/queen/sound.cpp b/engines/queen/sound.cpp index a1061259c3..b7dd9c66c9 100644 --- a/engines/queen/sound.cpp +++ b/engines/queen/sound.cpp @@ -94,9 +94,6 @@ public:  	int getRate() const {  		return _rate;  	} -	int32 getTotalPlayTime() { -		return _stream->getTotalPlayTime(); -	}  };  class SilentSound : public PCSound { diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index 4ecfbedada..d92c3b793c 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -168,12 +168,6 @@ public:  	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 @@ public:  	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()); } diff --git a/sound/audiostream.h b/sound/audiostream.h index a3992ca94f..42bf93871b 100644 --- a/sound/audiostream.h +++ b/sound/audiostream.h @@ -117,20 +117,6 @@ public:  	 * @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; }  };  /** diff --git a/sound/flac.cpp b/sound/flac.cpp index b99f8bb484..0310754374 100644 --- a/sound/flac.cpp +++ b/sound/flac.cpp @@ -143,12 +143,6 @@ public:  		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 @@ FlacInputStream::FlacInputStream(Common::SeekableReadStream *inStream, bool disp  			_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 @@ FlacInputStream::FlacInputStream(Common::SeekableReadStream *inStream, bool disp  					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 @@ FlacInputStream::FlacInputStream(Common::SeekableReadStream *inStream, bool disp  					_totalPlayTime = (seconds * 1000 + milliseconds);  				} else { -					_totalPlayTime = kUnknownPlayTime; +					_totalPlayTime = 0;  				}  				return; // no error occured diff --git a/sound/mp3.cpp b/sound/mp3.cpp index 332fe20d59..faebf347e1 100644 --- a/sound/mp3.cpp +++ b/sound/mp3.cpp @@ -93,11 +93,6 @@ public:  	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 @@ MP3InputStream::MP3InputStream(Common::SeekableReadStream *inStream, bool dispos  	_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. diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp index a130ecc5ec..629c36b3db 100644 --- a/sound/vorbis.cpp +++ b/sound/vorbis.cpp @@ -127,17 +127,6 @@ public:  	}  	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 {  | 
