aboutsummaryrefslogtreecommitdiff
path: root/engines/composer
diff options
context:
space:
mode:
authorAlyssa Milburn2011-07-18 21:09:18 +0200
committerAlyssa Milburn2011-07-18 21:09:18 +0200
commit9cb4bd2a3851daf2dc145a30e41e6b2fa99427c1 (patch)
tree437a6ac1d81e07ce0be57334d1f37450897e7136 /engines/composer
parentcab48d51f5da681e5c3a5a0c8ccdaf5d878b1420 (diff)
downloadscummvm-rg350-9cb4bd2a3851daf2dc145a30e41e6b2fa99427c1.tar.gz
scummvm-rg350-9cb4bd2a3851daf2dc145a30e41e6b2fa99427c1.tar.bz2
scummvm-rg350-9cb4bd2a3851daf2dc145a30e41e6b2fa99427c1.zip
COMPOSER: Obey sound priorities.
Diffstat (limited to 'engines/composer')
-rw-r--r--engines/composer/composer.cpp27
-rw-r--r--engines/composer/composer.h3
2 files changed, 22 insertions, 8 deletions
diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp
index 8e9d2863a1..a9232c7c35 100644
--- a/engines/composer/composer.cpp
+++ b/engines/composer/composer.cpp
@@ -392,10 +392,14 @@ void ComposerEngine::stopAnimation(Animation *anim, bool localOnly, bool pipesOn
if (localOnly) {
if (pipesOnly)
continue;
- // TODO: stop audio if needed
- if (entry.op != kAnimOpDrawSprite)
- continue;
- removeSprite(entry.prevValue, anim->_id);
+ if (entry.op == kAnimOpDrawSprite) {
+ removeSprite(entry.prevValue, anim->_id);
+ } else if (entry.op == kAnimOpPlayWave) {
+ if (_currSoundPriority >= entry.priority) {
+ _mixer->stopAll();
+ _audioStream = NULL;
+ }
+ }
} else {
if (entry.op != kAnimOpPlayAnim)
continue;
@@ -417,7 +421,15 @@ void ComposerEngine::stopAnimation(Animation *anim, bool localOnly, bool pipesOn
}
}
-void ComposerEngine::playWaveForAnim(uint16 id, bool bufferingOnly) {
+void ComposerEngine::playWaveForAnim(uint16 id, uint16 priority, bool bufferingOnly) {
+ if (_audioStream && _audioStream->numQueuedStreams() != 0) {
+ if (_currSoundPriority < priority)
+ return;
+ if (_currSoundPriority > priority) {
+ _mixer->stopAll();
+ _audioStream = NULL;
+ }
+ }
Common::SeekableReadStream *stream = NULL;
if (!bufferingOnly && hasResource(ID_WAVE, id)) {
stream = getResource(ID_WAVE, id);
@@ -439,6 +451,7 @@ void ComposerEngine::playWaveForAnim(uint16 id, bool bufferingOnly) {
if (!_audioStream)
_audioStream = Audio::makeQueuingAudioStream(22050, false);
_audioStream->queueBuffer(buffer, stream->size(), DisposeAfterUse::YES, Audio::FLAG_UNSIGNED);
+ _currSoundPriority = priority;
delete stream;
if (!_mixer->isSoundHandleActive(_soundHandle))
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, _audioStream);
@@ -514,7 +527,7 @@ void ComposerEngine::processAnimFrame() {
entry.counter--;
if ((entry.op == kAnimOpPlayWave) && entry.prevValue) {
debug(4, "anim: continue play wave %d", entry.prevValue);
- playWaveForAnim(entry.prevValue, true);
+ playWaveForAnim(entry.prevValue, entry.priority, true);
}
} else {
anim->seekToCurrPos();
@@ -537,7 +550,7 @@ void ComposerEngine::processAnimFrame() {
break;
case kAnimOpPlayWave:
debug(4, "anim: play wave %d", data);
- playWaveForAnim(data, false);
+ playWaveForAnim(data, entry.priority, false);
break;
case kAnimOpPlayAnim:
debug(4, "anim: play anim %d", data);
diff --git a/engines/composer/composer.h b/engines/composer/composer.h
index 6e9e6afce1..6fa10d9c9a 100644
--- a/engines/composer/composer.h
+++ b/engines/composer/composer.h
@@ -198,6 +198,7 @@ private:
Audio::SoundHandle _soundHandle;
Audio::QueuingAudioStream *_audioStream;
+ uint16 _currSoundPriority;
bool _needsUpdate;
Graphics::Surface _surface;
@@ -247,7 +248,7 @@ private:
void playAnimation(uint16 animId, int16 param1, int16 param2, int16 param3);
void stopAnimation(Animation *anim, bool localOnly = false, bool pipesOnly = false);
- void playWaveForAnim(uint16 id, bool bufferingOnly);
+ void playWaveForAnim(uint16 id, uint16 priority, bool bufferingOnly);
void processAnimFrame();
bool spriteVisible(uint16 id, uint16 animId);