aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/sound/audio32.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/engines/sci/sound/audio32.cpp b/engines/sci/sound/audio32.cpp
index 4af474b918..43c21939fa 100644
--- a/engines/sci/sound/audio32.cpp
+++ b/engines/sci/sound/audio32.cpp
@@ -183,6 +183,9 @@ int Audio32::writeAudioInternal(Audio::AudioStream *const sourceStream, Audio::R
do {
if (loop && sourceStream->endOfStream()) {
Audio::RewindableAudioStream *rewindableStream = dynamic_cast<Audio::RewindableAudioStream *>(sourceStream);
+ if (rewindableStream == nullptr) {
+ error("[Audio32::writeAudioInternal]: Unable to cast stream");
+ }
rewindableStream->rewind();
}
@@ -453,7 +456,11 @@ void Audio32::freeUnusedChannels() {
const AudioChannel &channel = getChannel(channelIndex);
if (!channel.robot && channel.stream->endOfStream()) {
if (channel.loop) {
- dynamic_cast<Audio::SeekableAudioStream *>(channel.stream)->rewind();
+ Audio::SeekableAudioStream *stream = dynamic_cast<Audio::SeekableAudioStream *>(channel.stream);
+ if (stream == nullptr) {
+ error("[Audio32::freeUnusedChannels]: Unable to cast stream for resource %s", channel.id.toString().c_str());
+ }
+ stream->rewind();
} else {
stop(channelIndex--);
}
@@ -658,6 +665,9 @@ uint16 Audio32::play(int16 channelIndex, const ResourceId resourceId, const bool
if (channelIndex != kNoExistingChannel) {
AudioChannel &channel = getChannel(channelIndex);
Audio::SeekableAudioStream *stream = dynamic_cast<Audio::SeekableAudioStream *>(channel.stream);
+ if (stream == nullptr) {
+ error("[Audio32::play]: Unable to cast stream for resource %s", resourceId.toString().c_str());
+ }
if (channel.pausedAtTick) {
resume(channelIndex);
@@ -764,7 +774,12 @@ uint16 Audio32::play(int16 channelIndex, const ResourceId resourceId, const bool
// use audio streams, and allocate and fill the monitoring buffer
// when reading audio data from the stream.
- channel.duration = /* round up */ 1 + (dynamic_cast<Audio::SeekableAudioStream *>(channel.stream)->getLength().msecs() * 60 / 1000);
+ Audio::SeekableAudioStream *stream = dynamic_cast<Audio::SeekableAudioStream *>(channel.stream);
+ if (stream == nullptr) {
+ error("[Audio32::play]: Unable to cast stream for resource %s", resourceId.toString().c_str());
+ }
+
+ channel.duration = /* round up */ 1 + (stream->getLength().msecs() * 60 / 1000);
const uint32 now = g_sci->getTickCount();
channel.pausedAtTick = autoPlay ? 0 : now;