[Scummvm-cvs-logs] CVS: residual/imuse limits.h,NONE,1.1 imuse.h,1.16,1.17 imuse_music.cpp,1.12,1.13 imuse_script.cpp,1.12,1.13 imuse_sndmgr.h,1.7,1.8 imuse_tables.cpp,1.9,1.10 imuse_track.cpp,1.12,1.13

Erich Edgar Hoover compholio at users.sourceforge.net
Sun Jul 17 16:41:47 CEST 2005


Update of /cvsroot/scummvm/residual/imuse
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19641/imuse

Modified Files:
	imuse.h imuse_music.cpp imuse_script.cpp imuse_sndmgr.h 
	imuse_tables.cpp imuse_track.cpp 
Added Files:
	limits.h 
Log Message:
Font patch from Andrea Corna - improved keyframe support - SMUSH looping support - improved IMUSE stability - additional error checking

--- NEW FILE: limits.h ---
// Residual - Virtual machine to run LucasArts' 3D adventure games
// Copyright (C) 2003-2005 The ScummVM-Residual Team (www.scummvm.org)
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

#ifndef IMUSE_LIMITS_H
#define IMUSE_LIMITS_H

//#define MAX_IMUSE_TRACKS 8
#define MAX_IMUSE_TRACKS 20
#define MAX_IMUSE_FADETRACKS 8

#endif

Index: imuse.h
===================================================================
RCS file: /cvsroot/scummvm/residual/imuse/imuse.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- imuse.h	16 Jan 2005 00:27:19 -0000	1.16
+++ imuse.h	17 Jul 2005 23:40:21 -0000	1.17
@@ -29,8 +29,7 @@
 #include "imuse/imuse_sndmgr.h"
 #include "imuse/imuse_mcmp_mgr.h"
 
-#define MAX_IMUSE_TRACKS 8
-#define MAX_IMUSE_FADETRACKS 8
+#include "imuse/limits.h"
 
 struct ImuseTable {
 	byte opcode;
@@ -134,6 +133,7 @@
 	int getGroupSfxVolume() { return _volSfx; }
 	int getGroupMusicVolume() { return _volMusic; }
 
+	Track *findTrack(const char *soundName);
 	void setPriority(const char *soundName, int priority);
 	void setVolume(const char *soundName, int volume);
 	int getVolume(const char *soundName);
@@ -151,7 +151,7 @@
 	void flushTracks();
 	bool isVoicePlaying();
 	char *getCurMusicSoundName();
-	bool getSoundStatus(const char *soundName) const;
+	bool getSoundStatus(const char *soundName);
 	int32 getPosIn60HzTicks(const char *soundName);
 };
 

Index: imuse_music.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/imuse/imuse_music.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- imuse_music.cpp	14 Jan 2005 09:25:42 -0000	1.12
+++ imuse_music.cpp	17 Jul 2005 23:40:21 -0000	1.13
@@ -105,12 +105,14 @@
 		} else {
 			char *soundName = getCurMusicSoundName();
 			int pan;
+			
 			if (table->pan == 0)
 				pan = 64;
 			else
 				pan = table->pan;
-			if ((table->opcode == 3) && (!sequence) && (strcmp(soundName, table->filename) == 0) &&
-					(table->atribPos != 0) && (table->atribPos == _stateMusicTable[_curMusicState].atribPos)) {
+			if (soundName != NULL && (table->opcode == 3) && (!sequence)
+			 && (strcmp(soundName, table->filename) == 0) && (table->atribPos != 0)
+			 && table->atribPos == _stateMusicTable[_curMusicState].atribPos) {
 				setFadeVolume(soundName, table->volume, table->fadeOut60TicksDelay);
 				setFadePan(soundName, pan, table->fadeOut60TicksDelay);
 				setHookId(soundName, hookId);

Index: imuse_script.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/imuse/imuse_script.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- imuse_script.cpp	21 Jan 2005 20:34:42 -0000	1.12
+++ imuse_script.cpp	17 Jul 2005 23:40:21 -0000	1.13
@@ -27,6 +27,8 @@
 #include "imuse/imuse_sndmgr.h"
 
 void Imuse::flushTracks() {
+	// flushTracks should not lock the stack since all the functions
+	// that call it already do (stopAllSounds, startSound)
 	for (int l = 0; l < MAX_IMUSE_TRACKS + MAX_IMUSE_FADETRACKS; l++) {
 		Track *track = _track[l];
 		if (track->used && track->readyToRemove) {
@@ -41,6 +43,7 @@
 					_sound->closeSound(track->soundHandle);
 					track->soundHandle = NULL;
 					track->used = false;
+					strcpy(track->soundName, "");
 				}
 			}
 		}
@@ -49,6 +52,8 @@
 
 void Imuse::refreshScripts() {
 	bool found = false;
+	
+	StackLock lock(_mutex);
 	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
 		Track *track = _track[l];
 		if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
@@ -74,18 +79,25 @@
 }
 
 int32 Imuse::getPosIn60HzTicks(const char *soundName) {
-	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
-		Track *track = _track[l];
-		if (track->handle.isActive() && (strcmp(track->soundName, soundName) == 0)) {
-			int32 pos = (5 * (track->dataOffset + track->regionOffset)) / (track->iteration / 12);
-			return pos;
-		}
+	Track *getTrack = NULL;
+	
+	getTrack = findTrack(soundName);
+	// Warn the user if the track was not found
+	if (getTrack == NULL) {
+		if (debugLevel == DEBUG_IMUSE || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+			warning("Music track '%s' could not be found to get ticks!", soundName);
+		return false;
 	}
 
+	if (getTrack->handle.isActive()) {
+		int32 pos = (5 * (getTrack->dataOffset + getTrack->regionOffset)) / (getTrack->iteration / 12);
+		return pos;
+	}
 	return -1;
 }
 
 bool Imuse::isVoicePlaying() {
+	StackLock lock(_mutex);
 	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
 		Track *track = _track[l];
 		if (track->volGroupId == IMUSE_VOLGRP_VOICE) {
@@ -98,30 +110,45 @@
 	return false;
 }
 
-bool Imuse::getSoundStatus(const char *soundName) const {
-	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
-		Track *track = _track[l];
-		if (strcmp(track->soundName, soundName) == 0) {
-			if (track->handle.isActive()) {
-				return true;
-			}
-		}
+bool Imuse::getSoundStatus(const char *soundName) {
+	Track *statusTrack = NULL;
+	
+	// If there's no name then don't try to get the status!
+	if (strlen(soundName) == 0)
+		return false;
+	
+	statusTrack = findTrack(soundName);
+	// Warn the user if the track was not found
+	if (statusTrack == NULL) {
+		// This debug warning should be "light" since this function gets called
+		// on occassion to see if a sound has stopped yet
+		if (debugLevel == DEBUG_IMUSE || debugLevel == DEBUG_NORMAL || debugLevel == DEBUG_ALL)
+			printf("Music track '%s' could not be found to get status, assume inactive.\n", soundName);
+		return false;
 	}
-
-	return false;
+	return statusTrack->handle.isActive();
 }
 
 void Imuse::stopSound(const char *soundName) {
-	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
-		Track *track = _track[l];
-		if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
-			track->toBeRemoved = true;
-		}
+	Track *removeTrack = NULL;
+	
+	removeTrack = findTrack(soundName);
+	// Warn the user if the track was not found
+	if (removeTrack == NULL) {
+		if (debugLevel == DEBUG_IMUSE || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+			warning("Music track '%s' could not be found to stop!", soundName);
+		return;
 	}
+	removeTrack->toBeRemoved = true;
 }
 
 void Imuse::stopAllSounds() {
-	for(;;) {
+	int i;
+	StackLock lock(_mutex);
+	// Make 5 attempts to close out all the sounds before failing
+	// At this time it is inappropriate to say we are stable enough
+	// to just let this run forever
+	for(i = 5; i > 0; i--) {
 		bool foundNotRemoved = false;
 		for (int l = 0; l < MAX_IMUSE_TRACKS + MAX_IMUSE_FADETRACKS; l++) {
 			Track *track = _track[l];
@@ -135,6 +162,10 @@
 		flushTracks();
 		SDL_Delay(50);
 	}
+	if (i == 0) {
+		if (debugLevel == DEBUG_IMUSE || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+			warning("Imuse::stopAllSounds() did not stop everything!");
+	}
 }
 
 void Imuse::pause(bool p) {

Index: imuse_sndmgr.h
===================================================================
RCS file: /cvsroot/scummvm/residual/imuse/imuse_sndmgr.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- imuse_sndmgr.h	1 Jan 2005 21:07:52 -0000	1.7
+++ imuse_sndmgr.h	17 Jul 2005 23:40:21 -0000	1.8
@@ -25,6 +25,7 @@
 
 #include "mixer/mixer.h"
 #include "mixer/audiostream.h"
+#include "imuse/limits.h"
 
 class McmpMgr;
 class Block;
@@ -32,11 +33,18 @@
 class ImuseSndMgr {
 public:
 
-#define MAX_IMUSE_SOUNDS 16
+// MAX_IMUSE_SOUNDS should not be hardcoded, it should represent
+// the maximum number of different tracks, see limits.h
+#define MAX_IMUSE_SOUNDS MAX_IMUSE_TRACKS+MAX_IMUSE_FADETRACKS
 
-#define IMUSE_VOLGRP_VOICE 1
-#define IMUSE_VOLGRP_SFX 2
-#define IMUSE_VOLGRP_MUSIC 3
+// The numbering below fixes talking to Domino in his office
+// and it also allows Manny to get the info for Mercedes
+// Colomar, without this the game hangs at these points!
+#define IMUSE_VOLGRP_BGND   0
+#define IMUSE_VOLGRP_ACTION 1
+#define IMUSE_VOLGRP_SFX    2
+#define IMUSE_VOLGRP_MUSIC  3
+#define IMUSE_VOLGRP_VOICE  4
 
 private:
 	struct Region {

Index: imuse_tables.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/imuse/imuse_tables.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- imuse_tables.cpp	1 Jan 2005 12:27:57 -0000	1.9
+++ imuse_tables.cpp	17 Jul 2005 23:40:21 -0000	1.10
@@ -65,7 +65,7 @@
 	{2, 1083,   0, 0, 60, 127,   0, "1083 - Beaver Room.IMC"},
 	{2, 1084,   0, 0, 60,  80,   0, "1084 - Foggy Cactus.IMC"},
 	{2, 1085,   0, 0, 60, 105,   0, "1085 - Rubamat Exterior.IMC"},
-	{2, 1086,   0, 4, 60,  80,  30, "1086 - Blue Hector.IMC"},
+	{2, 1086,   0, 4, 60,  80,  30, "1087 - Blue Hector.IMC"},
 	{2, 1100,   0, 0, 60, 127,   0, "1109 - Cafe Exterior.IMC"},
 	{3, 1101,  45, 5, 24,  60,   0, "1101 - Cafe Office.IMC"},
 	{3, 1102,  45, 0, 24, 127,   0, "1102 - Cafe Intercom.IMC"},
@@ -105,8 +105,8 @@
 	{2, 1147,   0, 0, 60, 127,   0, "1147 - LOL Security Int.IMC"},
 	{2, 1148,   0, 0, 60, 127,   0, "1148 - Carla's Life.IMC"},
 	{2, 1149,   0, 0, 24, 127,   0, "1149 - Bomb.IMC"},
-	{3, 1150,  83, 0, 60, 105,   0, "1150 - Track Stairs.IMC"},
-	{3, 1151,  83, 0, 60, 105,   0, "1151 - Track Stairs.IMC"},
+	{3, 1150,  83, 0, 60, 105,   0, "1152 - Track Stairs.IMC"},
+	{3, 1151,  83, 0, 60, 105,   0, "1152 - Track Stairs.IMC"},
 	{3, 1152,  83, 0, 60, 105,   0, "1152 - Track Stairs.IMC"},
 	{2, 1153,   0, 0, 24, 127,   0, "1153 - Track Base.IMC"},
 	{2, 1154,   0, 0, 60, 127,   0, "1154 - Kitty Hall.IMC"},

Index: imuse_track.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/imuse/imuse_track.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- imuse_track.cpp	16 Jan 2005 00:27:19 -0000	1.12
+++ imuse_track.cpp	17 Jul 2005 23:40:21 -0000	1.13
@@ -28,50 +28,70 @@
 int Imuse::allocSlot(int priority) {
 	int l, lowest_priority = 127;
 	int trackId = -1;
-
+	
+	// allocSlot called by startSound so no locking is necessary
 	for (l = 0; l < MAX_IMUSE_TRACKS; l++) {
 		if (!_track[l]->used) {
-			trackId = l;
-			break;
+			return l; // Found an unused track
 		}
 	}
 
-	if (trackId == -1) {
-		warning("Imuse::startSound(): All slots are full");
-		for (l = 0; l < MAX_IMUSE_TRACKS; l++) {
-			Track *track = _track[l];
-			if (track->used && !track->toBeRemoved && lowest_priority > track->priority) {
-				lowest_priority = track->priority;
-				trackId = l;
-			}
-		}
-		if (lowest_priority <= priority) {
-			assert(trackId != -1);
-			_track[trackId]->toBeRemoved = true;
-			warning("Imuse::startSound(): Removed sound %s from track %d", _track[trackId]->soundName, trackId);
-		} else {
-			warning("Imuse::startSound(): Priority sound too low");
-			return -1;
+	warning("Imuse::startSound(): All slots are full");
+	for (l = 0; l < MAX_IMUSE_TRACKS; l++) {
+		Track *track = _track[l];
+		if (track->used && !track->toBeRemoved && lowest_priority > track->priority) {
+			lowest_priority = track->priority;
+			trackId = l;
 		}
 	}
+	if (lowest_priority <= priority) {
+		assert(trackId != -1);
+		_track[trackId]->toBeRemoved = true;
+		warning("Imuse::startSound(): Removed sound %s from track %d", _track[trackId]->soundName, trackId);
+	} else {
+		warning("Imuse::startSound(): Priority sound too low");
+		return -1;
+	}
 
 	return trackId;
 }
 
 bool Imuse::startSound(const char *soundName, int volGroupId, int hookId, int volume, int pan, int priority) {
-	int l = allocSlot(priority);
+	Track *track = NULL;
+	int i, l = -1;
+	
+	StackLock lock(_mutex);
+	// If the track is already playing then there is absolutely no
+	// reason to start it again, the existing track should be modified
+	// instead of starting a new copy of the track
+	for (i = 0; i < MAX_IMUSE_TRACKS + MAX_IMUSE_FADETRACKS; i++) {
+		// Filenames are case insensitive, see findTrack
+		if (!strcasecmp(_track[i]->soundName, soundName)) {
+			if (debugLevel == DEBUG_IMUSE || debugLevel == DEBUG_NORMAL || debugLevel == DEBUG_ALL)
+				printf("Imuse::startSound(): Track '%s' already playing.\n", soundName);
+			return true;
+		}
+	}
+	l = allocSlot(priority);
 	if (l == -1) {
-		warning("Imuse::startSound() Can't start sound - no free slots");
+		warning("Imuse::startSound(): Can't start sound - no free slots");
 		return false;
 	}
-
-	Track *track = _track[l];
-	while (track->used) {
+	track = _track[l];
+	i = 5;
+	// At this time it is inappropriate to assume that this will always
+	// succeed, so set a limit of 5 tries on running flushTracks
+	while (track->used && i > 0) {
 		// The designated track is not yet available. So, we call flushTracks()
 		// to get it processed (and thus made ready for us). Since the actual
 		// processing is done by another thread, we also call parseEvents to
 		// give it some time (and to avoid busy waiting/looping).
 		flushTracks();
+		i--;
+	}
+	if (i == 0) {
+		if (debugLevel == DEBUG_IMUSE || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+			warning("Imuse::startSound(): flushTracks was unnable to free up a track!");
 	}
 
 	track->pan = pan * 1000;
@@ -142,59 +162,82 @@
 	return true;
 }
 
-void Imuse::setPriority(const char *soundName, int priority) {
-	assert ((priority >= 0) && (priority <= 127));
-
+Imuse::Track *Imuse::findTrack(const char *soundName) {
+	StackLock lock(_mutex);
 	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
 		Track *track = _track[l];
-		if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
-			track->priority = priority;
+		
+		// Since the audio (at least for Eva's keystrokes) can be referenced
+		// two ways: keyboard.IMU and keyboard.imu, make a case insensitive
+		// search for the track to make sure we can find it
+		if (strcasecmp(track->soundName, soundName) == 0) {
+			return track;
 		}
 	}
+	return NULL;
+}
+
+void Imuse::setPriority(const char *soundName, int priority) {
+	Track *changeTrack = NULL;
+	assert ((priority >= 0) && (priority <= 127));
+	
+	changeTrack = findTrack(soundName);
+	// Check to make sure we found the track
+	if (changeTrack == NULL) {
+		warning("Unable to find track '%s' to change priority!", soundName);
+		return;
+	}
+	changeTrack->priority = priority;
 }
 
 void Imuse::setVolume(const char *soundName, int volume) {
-	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
-		Track *track = _track[l];
-		if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
-			track->vol = volume * 1000;
-		}
+	Track *changeTrack;
+	
+	changeTrack = findTrack(soundName);
+	if (changeTrack == NULL) {
+		warning("Unable to find track '%s' to change volume!", soundName);
+		return;
 	}
+	changeTrack->vol = volume * 1000;
 }
 
 void Imuse::setPan(const char *soundName, int pan) {
-	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
-		Track *track = _track[l];
-		if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
-			track->pan = pan;
-		}
+	Track *changeTrack;
+	
+	changeTrack = findTrack(soundName);
+	if (changeTrack == NULL) {
+		warning("Unable to find track '%s' to change volume!", soundName);
+		return;
 	}
+	changeTrack->pan = pan;
 }
 
 int Imuse::getVolume(const char *soundName) {
-	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
-		Track *track = _track[l];
-		if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
-			return track->vol / 1000;
-		}
+	Track *getTrack;
+	
+	getTrack = findTrack(soundName);
+	if (getTrack == NULL) {
+		warning("Unable to find track '%s' to get volume!", soundName);
+		return 0;
 	}
-
-	return 0;
+	return getTrack->vol / 1000;
 }
 
 void Imuse::setHookId(const char *soundName, int hookId) {
-	StackLock lock(_mutex);
-
-	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
-		Track *track = _track[l];
-		if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
-			track->curHookId = hookId;
-		}
+	Track *changeTrack;
+	
+	changeTrack = findTrack(soundName);
+	if (changeTrack == NULL) {
+		warning("Unable to find track '%s' to change hook id!", soundName);
+		return;
 	}
+	changeTrack->curHookId = hookId;
 }
 
 int Imuse::getCountPlayedTracks(const char *soundName) {
 	int count = 0;
+	
+	StackLock lock(_mutex);
 	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
 		Track *track = _track[l];
 		if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
@@ -206,59 +249,61 @@
 }
 
 void Imuse::selectVolumeGroup(const char *soundName, int volGroupId) {
+	Track *changeTrack;
 	assert((volGroupId >= 1) && (volGroupId <= 4));
 
 	if (volGroupId == 4)
 		volGroupId = 3;
 
-	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
-		Track *track = _track[l];
-		if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
-			track->volGroupId = volGroupId;
-		}
+	changeTrack = findTrack(soundName);
+	if (changeTrack == NULL) {
+		warning("Unable to find track '%s' to change volume group id!", soundName);
+		return;
 	}
+	changeTrack->volGroupId = volGroupId;
 }
 
 void Imuse::setFadeVolume(const char *soundName, int destVolume, int duration) {
-	StackLock lock(_mutex);
+	Track *changeTrack;
 
-	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
-		Track *track = _track[l];
-		if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
-			track->volFadeDelay = duration;
-			track->volFadeDest = destVolume * 1000;
-			track->volFadeStep = (track->volFadeDest - track->vol) * 60 * (1000 / _callbackFps) / (1000 * duration);
-			track->volFadeUsed = true;
-		}
+	changeTrack = findTrack(soundName);
+	if (changeTrack == NULL) {
+		warning("Unable to find track '%s' to change fade volume!", soundName);
+		return;
 	}
+	changeTrack->volFadeDelay = duration;
+	changeTrack->volFadeDest = destVolume * 1000;
+	changeTrack->volFadeStep = (changeTrack->volFadeDest - changeTrack->vol) * 60 * (1000 / _callbackFps) / (1000 * duration);
+	changeTrack->volFadeUsed = true;
 }
 
 void Imuse::setFadePan(const char *soundName, int destPan, int duration) {
-	StackLock lock(_mutex);
+	Track *changeTrack;
 
-	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
-		Track *track = _track[l];
-		if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
-			track->panFadeDelay = duration;
-			track->panFadeDest = destPan * 1000;
-			track->panFadeStep = (track->panFadeDest - track->pan) * 60 * (1000 / _callbackFps) / (1000 * duration);
-			track->panFadeUsed = true;
-		}
+	changeTrack = findTrack(soundName);
+	if (changeTrack == NULL) {
+		warning("Unable to find track '%s' to change fade pan!", soundName);
+		return;
 	}
+	changeTrack->panFadeDelay = duration;
+	changeTrack->panFadeDest = destPan * 1000;
+	changeTrack->panFadeStep = (changeTrack->panFadeDest - changeTrack->pan) * 60 * (1000 / _callbackFps) / (1000 * duration);
+	changeTrack->panFadeUsed = true;
 }
 
 char *Imuse::getCurMusicSoundName() {
+	StackLock lock(_mutex);
 	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
 		Track *track = _track[l];
 		if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
 			return track->soundName;
 		}
 	}
-
-	return "";
+	return NULL;
 }
 
 void Imuse::fadeOutMusic(int duration) {
+	StackLock lock(_mutex);
 	for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
 		Track *track = _track[l];
 		if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {





More information about the Scummvm-git-logs mailing list