diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/bbvs/sound.h | 2 | ||||
-rw-r--r-- | engines/pegasus/sound.cpp | 10 | ||||
-rw-r--r-- | engines/saga/sndres.cpp | 15 | ||||
-rw-r--r-- | engines/sci/sound/audio.cpp | 8 | ||||
-rw-r--r-- | engines/sherlock/debugger.cpp | 2 |
5 files changed, 30 insertions, 7 deletions
diff --git a/engines/bbvs/sound.h b/engines/bbvs/sound.h index 4e44c2b962..4d3253c48e 100644 --- a/engines/bbvs/sound.h +++ b/engines/bbvs/sound.h @@ -38,7 +38,7 @@ public: void stop(); bool isPlaying(); protected: - Audio::SeekableAudioStream *_stream; + Audio::RewindableAudioStream *_stream; Audio::SoundHandle _handle; // Keep the filename for debugging purposes Common::String _filename; diff --git a/engines/pegasus/sound.cpp b/engines/pegasus/sound.cpp index 5b437b81d4..ddcb2be010 100644 --- a/engines/pegasus/sound.cpp +++ b/engines/pegasus/sound.cpp @@ -59,7 +59,15 @@ void Sound::initFromAIFFFile(const Common::String &fileName) { return; } - _stream = Audio::makeAIFFStream(file, DisposeAfterUse::YES); + Audio::RewindableAudioStream *stream = Audio::makeAIFFStream(file, DisposeAfterUse::YES); + + _stream = dynamic_cast<Audio::SeekableAudioStream *>(stream); + + if (!_stream) { + delete stream; + warning("AIFF stream '%s' is not seekable", fileName.c_str()); + return; + } } void Sound::initFromQuickTime(const Common::String &fileName) { diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp index 39578e96f0..b8d03c9c08 100644 --- a/engines/saga/sndres.cpp +++ b/engines/saga/sndres.cpp @@ -327,9 +327,18 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff result = true; } break; case kSoundAIFF: { - Audio::SeekableAudioStream *audStream = Audio::makeAIFFStream(READ_STREAM(soundResourceLength), DisposeAfterUse::YES); - buffer.stream = audStream; - buffer.streamLength = audStream->getLength(); + Audio::RewindableAudioStream *audStream = Audio::makeAIFFStream(READ_STREAM(soundResourceLength), DisposeAfterUse::YES); + Audio::SeekableAudioStream *seekStream = dynamic_cast<Audio::SeekableAudioStream *>(audStream); + + if (!seekStream) { + warning("AIFF file is not seekable"); + delete audStream; + result = false; + break; + } + + buffer.stream = seekStream; + buffer.streamLength = seekStream->getLength(); result = true; } break; case kSoundVOC: { diff --git a/engines/sci/sound/audio.cpp b/engines/sci/sound/audio.cpp index 757d622962..fb9a3f17b9 100644 --- a/engines/sci/sound/audio.cpp +++ b/engines/sci/sound/audio.cpp @@ -391,7 +391,13 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32 } else if (audioRes->size > 4 && READ_BE_UINT32(audioRes->data) == MKTAG('F','O','R','M')) { // AIFF detected Common::SeekableReadStream *waveStream = new Common::MemoryReadStream(audioRes->data, audioRes->size, DisposeAfterUse::NO); - audioSeekStream = Audio::makeAIFFStream(waveStream, DisposeAfterUse::YES); + Audio::RewindableAudioStream *rewindStream = Audio::makeAIFFStream(waveStream, DisposeAfterUse::YES); + audioSeekStream = dynamic_cast<Audio::SeekableAudioStream *>(rewindStream); + + if (!audioSeekStream) { + warning("AIFF file is not seekable"); + delete rewindStream; + } } else if (audioRes->size > 14 && READ_BE_UINT16(audioRes->data) == 1 && READ_BE_UINT16(audioRes->data + 2) == 1 && READ_BE_UINT16(audioRes->data + 4) == 5 && READ_BE_UINT32(audioRes->data + 10) == 0x00018051) { // Mac snd detected diff --git a/engines/sherlock/debugger.cpp b/engines/sherlock/debugger.cpp index a627d7c494..4d8ea6c447 100644 --- a/engines/sherlock/debugger.cpp +++ b/engines/sherlock/debugger.cpp @@ -106,7 +106,7 @@ bool Debugger::cmd3DO_PlayAudio(int argc, const char **argv) { Audio::SoundHandle testHandle; // Try to load the given file as AIFF/AIFC - testStream = Audio::makeAIFFAudioStream(file, DisposeAfterUse::YES); + testStream = Audio::makeAIFFStream(file, DisposeAfterUse::YES); if (testStream) { g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &testHandle, testStream); |