[Scummvm-cvs-logs] CVS: scummvm/bs2/driver d_sound.cpp,1.42,1.43

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Fri Sep 5 08:57:09 CEST 2003


Update of /cvsroot/scummvm/scummvm/bs2/driver
In directory sc8-pr-cvs1:/tmp/cvs-serv31874/driver

Modified Files:
	d_sound.cpp 
Log Message:
Cleanup.


Index: d_sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/driver/d_sound.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- d_sound.cpp	5 Sep 2003 15:37:51 -0000	1.42
+++ d_sound.cpp	5 Sep 2003 15:56:43 -0000	1.43
@@ -307,13 +307,7 @@
 //	a slow timer from rdwin.c
 //	--------------------------------------------------------------------------
 void Sword2Sound::FxServer(void) {
-	// FIXME: This function is called from a separate thread, and
-	// manipulates data structures that are used by several other
-	// functions throughout the file.
-	//
-	// I guess that means we need to add locking and stuff.
-	//
-	// Maybe that explains why BS2 still crashes every now and then.
+	StackLock lock(_mutex);
 
 	if (!soundOn)
 		return;
@@ -323,9 +317,15 @@
 			UpdateCompSampleStreaming();
 	}
 
+	if (!musStreaming[0] && !musStreaming[1] && fpMus.isOpen())
+		fpMus.close();
+
 	// FIXME: Doing this sort of things from a separate thread seems like
-	// just asking for trouble. But removing it outright will cause
-	// regressions which need to be investigated.
+	// just asking for trouble. But removing it outright causes regressions
+	// which need to be investigated.
+	//
+	// I've fixed one such regression, and as far as I can tell it's
+	// working now.
 
 #if 0
 	int i;
@@ -1060,7 +1060,6 @@
 	musEnd[primaryStream] = fpMus.readUint32LE();
 
 	if (!musEnd[primaryStream] || !musFilePos[primaryStream]) {
-		fpMus.close();
 		return RDERR_INVALIDID;
 	}
 
@@ -1070,7 +1069,6 @@
 	// Create a temporary buffer
 	data8 = (uint8*) malloc(bufferSizeMusic / 2);
 	if (!data8) {
-		fpMus.close();
 		return RDERR_OUTOFMEMORY;
 	}
 
@@ -1079,7 +1077,6 @@
 
 	// Read the compressed data in to the buffer
 	if ((int32) fpMus.read(data8, bufferSizeMusic / 2) != bufferSizeMusic / 2) {
-		fpMus.close();
 		free(data8);
 		return RDERR_INVALIDID;
 	}
@@ -1153,8 +1150,6 @@
 }
 
 void Sword2Sound::UpdateCompSampleStreaming(void) {
-	StackLock lock(_mutex);
-
 	uint32 	i,j;
 	int32 	v0, v1;
 	int32	len;
@@ -1301,10 +1296,6 @@
 				StreamCompMusicFromLock(musFilename[i], musId[i], musLooping[i]);
 		}
 	}
-
-	if (!musStreaming[0] && !musStreaming[1] && fpMus.isOpen())
-		fpMus.close();
-
 	DipMusic();
 }
 





More information about the Scummvm-git-logs mailing list