diff options
author | Strangerke | 2013-01-13 11:01:26 +0100 |
---|---|---|
committer | Strangerke | 2013-01-13 11:01:26 +0100 |
commit | a743857b87bd6e7cec47c231943d3e8cef254ebf (patch) | |
tree | 2c7dd14479d4a1a5240d7b490895d1ae95db1177 | |
parent | a75055a92300069a18ec0818feee729c77088264 (diff) | |
download | scummvm-rg350-a743857b87bd6e7cec47c231943d3e8cef254ebf.tar.gz scummvm-rg350-a743857b87bd6e7cec47c231943d3e8cef254ebf.tar.bz2 scummvm-rg350-a743857b87bd6e7cec47c231943d3e8cef254ebf.zip |
HOPKINS: (Courtesy of Eriktorbjorn) slight optimisation of the sound code
-rw-r--r-- | engines/hopkins/sound.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 9fb45fa9fe..4da7bdac15 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -73,6 +73,7 @@ public: _cueSheet.clear(); _cueStream = NULL; _cue = 0; + _loadedCue = -1; for (;;) { char buf[3]; @@ -134,8 +135,14 @@ public: protected: bool loadCue(int nr) { + if (_loadedCue == _cueSheet[nr]) { + _cueStream->rewind(); + return true; + } + delete _cueStream; _cueStream = NULL; + _loadedCue = _cueSheet[nr]; Common::String filename = Common::String::format("%s_%02d", _name.c_str(), _cueSheet[nr]); Common::File *file = new Common::File(); @@ -151,6 +158,7 @@ protected: } warning("TwaAudioStream::loadCue: Missing cue %d (%s)", nr, filename.c_str()); + _loadedCue = -1; delete file; return false; } @@ -158,8 +166,9 @@ protected: private: Common::String _name; Common::Array<int> _cueSheet; - Audio::AudioStream *_cueStream; + Audio::RewindableAudioStream *_cueStream; uint _cue; + int _loadedCue; }; Audio::AudioStream *makeTwaStream(Common::String name, Common::SeekableReadStream *stream) { |