From 920dac2f9d271889ffdc6c05313c89a6077ec2d2 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 5 Jan 2010 20:14:28 +0000 Subject: Remove unsafe getTotalPlayTime from AudioStream. svn-id: r47037 --- engines/kyra/lol.cpp | 2 +- engines/kyra/lol.h | 3 ++- engines/kyra/sound.cpp | 8 ++++---- engines/kyra/sound.h | 2 +- engines/kyra/sound_digital.cpp | 1 - engines/kyra/sound_lol.cpp | 10 +++++----- 6 files changed, 13 insertions(+), 13 deletions(-) (limited to 'engines/kyra') 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::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 _speechList; + typedef Common::List 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 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::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::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::iterator i = _speechList.begin(); i != _speechList.end(); ++i) + for (SpeechList::iterator i = _speechList.begin(); i != _speechList.end(); ++i) delete *i; _speechList.clear(); -- cgit v1.2.3