From 96fd18a13bbe4def704e1f9b15100f3dc48aaf64 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 20 Apr 2008 14:25:37 +0000 Subject: Implemented sound priority handling. svn-id: r31597 --- engines/kyra/sound_digital.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'engines/kyra/sound_digital.cpp') 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; -- cgit v1.2.3