[Scummvm-cvs-logs] SF.net SVN: scummvm: [30483] scummvm/trunk/engines/scumm/imuse_digi

aquadran at users.sourceforge.net aquadran at users.sourceforge.net
Mon Jan 14 18:26:49 CET 2008


Revision: 30483
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30483&view=rev
Author:   aquadran
Date:     2008-01-14 09:26:49 -0800 (Mon, 14 Jan 2008)

Log Message:
-----------
implement special case for playing music with beginning offset where other one stopped

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/imuse_digi/dimuse.h
    scummvm/trunk/engines/scumm/imuse_digi/dimuse_music.cpp
    scummvm/trunk/engines/scumm/imuse_digi/dimuse_script.cpp
    scummvm/trunk/engines/scumm/imuse_digi/dimuse_track.cpp

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse.h
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse.h	2008-01-14 17:03:14 UTC (rev 30482)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse.h	2008-01-14 17:26:49 UTC (rev 30483)
@@ -141,7 +141,7 @@
 	void callback();
 	void switchToNextRegion(Track *track);
 	int allocSlot(int priority);
-	void startSound(int soundId, const char *soundName, int soundType, int volGroupId, Audio::AudioStream *input, int hookId, int volume, int priority);
+	void startSound(int soundId, const char *soundName, int soundType, int volGroupId, Audio::AudioStream *input, int hookId, int volume, int priority, Track *otherTrack);
 	void selectVolumeGroup(int soundId, int volGroupId);
 
 	int32 getPosInMs(int soundId);
@@ -149,6 +149,7 @@
 
 	int getSoundIdByName(const char *soundName);
 	void fadeOutMusic(int fadeDelay);
+	void fadeOutMusicAndStartNew(int fadeDelay, const char *filename, int soundId);
 	void setHookIdForMusic(int hookId);
 	Track *cloneToFadeOutTrack(Track *track, int fadeDelay);
 
@@ -177,6 +178,7 @@
 	void startVoice(int soundId, const char *soundName);
 	void startMusic(int soundId, int volume);
 	void startMusic(const char *soundName, int soundId, int hookId, int volume);
+	void startMusicWithOtherPos(const char *soundName, int soundId, int hookId, int volume, Track *otherTrack);
 	void startSfx(int soundId, int priority);
 	void startSound(int sound)
 		{ error("IMuseDigital::startSound(int) should be never called"); }

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_music.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_music.cpp	2008-01-14 17:03:14 UTC (rev 30482)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_music.cpp	2008-01-14 17:26:49 UTC (rev 30483)
@@ -167,8 +167,10 @@
 		}
 	}
 
-	if (!songName)
+	if (!songName) {
 		fadeOutMusic(120);
+		return;
+	}
 
 	switch (table->transitionType) {
 	case 0:
@@ -184,8 +186,7 @@
 			_stopingSequence = true;
 		if ((!sequence) && (table->attribPos != 0) &&
 				(table->attribPos == _digStateMusicTable[_curMusicState].attribPos)) {
-			fadeOutMusic(108);
-			startMusic(table->filename, table->soundId, 0, 127);
+			fadeOutMusicAndStartNew(108, table->filename, table->soundId);
 		} else {
 			fadeOutMusic(108);
 			startMusic(table->filename, table->soundId, hookId, 127);
@@ -291,8 +292,10 @@
 		}
 	}
 
-	if (!songName)
+	if (!songName) {
 		fadeOutMusic(120);
+		return;
+	}
 
 	switch (table->transitionType) {
 	case 0:
@@ -323,8 +326,7 @@
 			_stopingSequence = true;
 		if ((!sequence) && (table->attribPos != 0) &&
 				(table->attribPos == _comiStateMusicTable[_curMusicState].attribPos)) {
-			fadeOutMusic(table->fadeOutDelay);
-			startMusic(table->filename, table->soundId, 0, 127);
+			fadeOutMusicAndStartNew(table->fadeOutDelay, table->filename, table->soundId);
 		} else if (table->transitionType == 12) {
 			fadeOutMusic(table->fadeOutDelay);
 			startMusic(table->filename, table->soundId, table->hookId, 127);

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_script.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_script.cpp	2008-01-14 17:03:14 UTC (rev 30482)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_script.cpp	2008-01-14 17:26:49 UTC (rev 30483)
@@ -226,27 +226,32 @@
 
 void IMuseDigital::startVoice(int soundId, Audio::AudioStream *input) {
 	debug(5, "startVoiceStream(%d)", soundId);
-	startSound(soundId, "", 0, IMUSE_VOLGRP_VOICE, input, 0, 127, 127);
+	startSound(soundId, "", 0, IMUSE_VOLGRP_VOICE, input, 0, 127, 127, NULL);
 }
 
 void IMuseDigital::startVoice(int soundId, const char *soundName) {
 	debug(5, "startVoiceBundle(%s)", soundName);
-	startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOLGRP_VOICE, NULL, 0, 127, 127);
+	startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOLGRP_VOICE, NULL, 0, 127, 127, NULL);
 }
 
 void IMuseDigital::startMusic(int soundId, int volume) {
 	debug(5, "startMusicResource(%d)", soundId);
-	startSound(soundId, "", IMUSE_RESOURCE, IMUSE_VOLGRP_MUSIC, NULL, 0, volume, 126);
+	startSound(soundId, "", IMUSE_RESOURCE, IMUSE_VOLGRP_MUSIC, NULL, 0, volume, 126, NULL);
 }
 
 void IMuseDigital::startMusic(const char *soundName, int soundId, int hookId, int volume) {
 	debug(5, "startMusicBundle(%s)", soundName);
-	startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOLGRP_MUSIC, NULL, hookId, volume, 126);
+	startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOLGRP_MUSIC, NULL, hookId, volume, 126, NULL);
 }
 
+void IMuseDigital::startMusicWithOtherPos(const char *soundName, int soundId, int hookId, int volume, Track *otherTrack) {
+	debug(5, "startMusicWithOtherPos(%s)", soundName);
+	startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOLGRP_MUSIC, NULL, hookId, volume, 126, otherTrack);
+}
+
 void IMuseDigital::startSfx(int soundId, int priority) {
 	debug(5, "startSfx(%d)", soundId);
-	startSound(soundId, "", IMUSE_RESOURCE, IMUSE_VOLGRP_SFX, NULL, 0, 127, priority);
+	startSound(soundId, "", IMUSE_RESOURCE, IMUSE_VOLGRP_SFX, NULL, 0, 127, priority, NULL);
 }
 
 void IMuseDigital::getLipSync(int soundId, int syncId, int32 msPos, int32 &width, int32 &height) {

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_track.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_track.cpp	2008-01-14 17:03:14 UTC (rev 30482)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_track.cpp	2008-01-14 17:26:49 UTC (rev 30483)
@@ -80,7 +80,7 @@
 	return trackId;
 }
 
-void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, int volGroupId, Audio::AudioStream *input, int hookId, int volume, int priority) {
+void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, int volGroupId, Audio::AudioStream *input, int hookId, int volume, int priority, Track *otherTrack) {
 	Common::StackLock lock(_mutex, "IMuseDigital::startSound()");
 	debug(5, "IMuseDigital::startSound(%d)", soundId);
 
@@ -153,6 +153,13 @@
 			track->mixerFlags |= kFlagLittleEndian;
 #endif
 
+		if (otherTrack && otherTrack->used && !otherTrack->toBeRemoved) {
+			track->curRegion = otherTrack->curRegion;
+			track->regionOffset = otherTrack->regionOffset;
+			track->dataOffset = otherTrack->dataOffset;
+			track->dataMod12Bit = otherTrack->dataMod12Bit;
+		}
+
 		track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->mixerFlags));
 		_mixer->playInputStream(track->getType(), &track->mixChanHandle, track->stream, -1, track->getVol(), track->getPan());
 	}
@@ -267,6 +274,20 @@
 	}
 }
 
+void IMuseDigital::fadeOutMusicAndStartNew(int fadeDelay, const char *filename, int soundId) {
+	Common::StackLock lock(_mutex, "IMuseDigital::fadeOutMusicAndStartNew()");
+	debug(5, "IMuseDigital::fadeOutMusicAndStartNew");
+
+	for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
+		Track *track = _track[l];
+		if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
+			startMusicWithOtherPos(filename, soundId, 0, 127, track);
+			cloneToFadeOutTrack(track, fadeDelay);
+			flushTrack(track);
+		}
+	}
+}
+
 void IMuseDigital::fadeOutMusic(int fadeDelay) {
 	Common::StackLock lock(_mutex, "IMuseDigital::fadeOutMusic()");
 	debug(5, "IMuseDigital::fadeOutMusic");
@@ -276,6 +297,7 @@
 		if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
 			cloneToFadeOutTrack(track, fadeDelay);
 			flushTrack(track);
+			break;
 		}
 	}
 }


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