diff options
Diffstat (limited to 'engines/kyra/sound_digital.cpp')
-rw-r--r-- | engines/kyra/sound_digital.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/engines/kyra/sound_digital.cpp b/engines/kyra/sound_digital.cpp index ca9f8ff58a..0f671ba38f 100644 --- a/engines/kyra/sound_digital.cpp +++ b/engines/kyra/sound_digital.cpp @@ -328,7 +328,7 @@ SoundDigital::~SoundDigital() { stopSound(i); } -int SoundDigital::playSound(Common::SeekableReadStream *stream, kSoundTypes type, int volume, bool loop, int channel) { +int SoundDigital::playSound(Common::SeekableReadStream *stream, uint8 priority, kSoundTypes type, int volume, bool loop, int channel) { Sound *use = 0; if (channel != -1 && channel < ARRAYSIZE(_sounds)) { stopSound(channel); @@ -343,12 +343,23 @@ int SoundDigital::playSound(Common::SeekableReadStream *stream, kSoundTypes type } if (!use) { - warning("no free sound channel"); - delete stream; - return -1; + for (channel = 0; channel < ARRAYSIZE(_sounds); ++channel) { + if (_sounds[channel].priority <= priority) { + stopSound(channel); + use = &_sounds[channel]; + break; + } + } + + if (!use) { + warning("no free sound channel"); + delete stream; + return -1; + } } } + use->priority = priority; use->stream = new AUDStream(stream, loop); if (use->stream->endOfData()) { delete use->stream; |