[Scummvm-cvs-logs] SF.net SVN: scummvm: [31597] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun Apr 20 16:25:38 CEST 2008


Revision: 31597
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31597&view=rev
Author:   lordhoto
Date:     2008-04-20 07:25:37 -0700 (Sun, 20 Apr 2008)

Log Message:
-----------
Implemented sound priority handling.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra_v3.cpp
    scummvm/trunk/engines/kyra/sound.h
    scummvm/trunk/engines/kyra/sound_digital.cpp

Modified: scummvm/trunk/engines/kyra/kyra_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v3.cpp	2008-04-20 13:44:44 UTC (rev 31596)
+++ scummvm/trunk/engines/kyra/kyra_v3.cpp	2008-04-20 14:25:37 UTC (rev 31597)
@@ -333,7 +333,7 @@
 
 	Common::SeekableReadStream *stream = _res->getFileStream(_menuAudioFile);
 	if (stream)
-		_musicSoundChannel = _soundDigital->playSound(stream, SoundDigital::kSoundTypeMusic);
+		_musicSoundChannel = _soundDigital->playSound(stream, 0xFF, SoundDigital::kSoundTypeMusic);
 }
 
 void KyraEngine_v3::playMusicTrack(int track, int force) {
@@ -356,7 +356,7 @@
 
 		Common::SeekableReadStream *stream = _res->getFileStream(_soundList[track]);
 		if (stream)
-			_musicSoundChannel = _soundDigital->playSound(stream, SoundDigital::kSoundTypeMusic);
+			_musicSoundChannel = _soundDigital->playSound(stream, 0xFF, SoundDigital::kSoundTypeMusic);
 	}
 
 	_curMusicTrack = track;
@@ -413,10 +413,11 @@
 	if (_sfxFileMap[item*2+0] != 0xFF) {
 		char filename[16];
 		snprintf(filename, 16, "%s.AUD", _sfxFileList[_sfxFileMap[item*2+0]]);
+		uint8 priority = _sfxFileMap[item*2+1];
 
 		Common::SeekableReadStream *stream = _res->getFileStream(filename);
 		if (stream)
-			_soundDigital->playSound(stream, SoundDigital::kSoundTypeSfx, volume);
+			_soundDigital->playSound(stream, priority, SoundDigital::kSoundTypeSfx, volume);
 	}
 }
 
@@ -431,8 +432,9 @@
 	snprintf(filename, 16, "%u.AUD", (uint)file);
 
 	Common::SeekableReadStream *stream = _res->getFileStream(filename);
-	if (stream)
-		_voiceSoundChannel = _soundDigital->playSound(stream, SoundDigital::kSoundTypeSpeech, 255);
+	if (stream) {
+		_voiceSoundChannel = _soundDigital->playSound(stream, 0xFE, SoundDigital::kSoundTypeSpeech, 255);
+	}
 }
 
 bool KyraEngine_v3::snd_voiceIsPlaying() {

Modified: scummvm/trunk/engines/kyra/sound.h
===================================================================
--- scummvm/trunk/engines/kyra/sound.h	2008-04-20 13:44:44 UTC (rev 31596)
+++ scummvm/trunk/engines/kyra/sound.h	2008-04-20 14:25:37 UTC (rev 31597)
@@ -515,6 +515,7 @@
 	 *
 	 * @param stream		Data stream used for playback
 	 *                      It will be deleted when playback is finished
+	 * @param priority		priority of the sound
 	 * @param type			type
 	 * @param volume		channel volume
 	 * @param loop			true if the sound should loop (endlessly)
@@ -522,7 +523,7 @@
 	 *
 	 * @return channel playing the sound
 	 */
-	int playSound(Common::SeekableReadStream *stream, kSoundTypes type, int volume = 255, bool loop = false, int channel = -1);
+	int playSound(Common::SeekableReadStream *stream, uint8 priority, kSoundTypes type, int volume = 255, bool loop = false, int channel = -1);
 
 	/**
 	 * Checks if a given channel is playing a sound.
@@ -559,6 +560,7 @@
 
 	struct Sound {
 		Audio::SoundHandle handle;
+		uint8 priority;
 		AUDStream *stream;
 	} _sounds[4];
 };

Modified: scummvm/trunk/engines/kyra/sound_digital.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_digital.cpp	2008-04-20 13:44:44 UTC (rev 31596)
+++ scummvm/trunk/engines/kyra/sound_digital.cpp	2008-04-20 14:25:37 UTC (rev 31597)
@@ -328,7 +328,7 @@
 		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 @@
 		}
 
 		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;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list