[Scummvm-cvs-logs] SF.net SVN: scummvm:[50054] scummvm/trunk/engines/sci/sound

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Sat Jun 19 19:43:13 CEST 2010


Revision: 50054
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50054&view=rev
Author:   m_kiewitz
Date:     2010-06-19 17:43:13 +0000 (Sat, 19 Jun 2010)

Log Message:
-----------
SCI: free channels for channel remapping on stop and pause, instead of dispose - fixes qfg3 demo going out of channels

Modified Paths:
--------------
    scummvm/trunk/engines/sci/sound/music.cpp
    scummvm/trunk/engines/sci/sound/music.h

Modified: scummvm/trunk/engines/sci/sound/music.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/music.cpp	2010-06-19 17:12:17 UTC (rev 50053)
+++ scummvm/trunk/engines/sci/sound/music.cpp	2010-06-19 17:43:13 UTC (rev 50054)
@@ -250,6 +250,14 @@
 	error("no free channels");
 }
 
+void SciMusic::freeChannels(MusicEntry *caller) {
+	// Remove used channels
+	for (int i = 0; i < 15; i++) {
+		if (_usedChannel[i] == caller)
+			_usedChannel[i] = 0;
+	}
+}
+
 void SciMusic::onTimer() {
 	const MusicList::iterator end = _playList.end();
 	for (MusicList::iterator i = _playList.begin(); i != end; ++i)
@@ -334,10 +342,12 @@
 	if (pSnd->pStreamAud)
 		_pMixer->stopHandle(pSnd->hCurrentAud);
 
-	_mutex.lock();
-	if (pSnd->pMidiParser)
+	if (pSnd->pMidiParser) {
+		_mutex.lock();
 		pSnd->pMidiParser->stop();
-	_mutex.unlock();
+		freeChannels(pSnd);
+		_mutex.unlock();
+	}
 }
 
 void SciMusic::soundSetVolume(MusicEntry *pSnd, byte volume) {
@@ -379,11 +389,6 @@
 
 	_mutex.lock();
 	uint sz = _playList.size(), i;
-	// Remove used channels
-	for (i = 0; i < 15; i++) {
-		if (_usedChannel[i] == pSnd)
-			_usedChannel[i] = 0;
-	}
 	// Remove sound from playlist
 	for (i = 0; i < sz; i++) {
 		if (_playList[i] == pSnd) {
@@ -404,10 +409,12 @@
 	if (pSnd->pStreamAud) {
 		_pMixer->pauseHandle(pSnd->hCurrentAud, true);
 	} else {
-		_mutex.lock();
-		if (pSnd->pMidiParser)
+		if (pSnd->pMidiParser) {
+			_mutex.lock();
 			pSnd->pMidiParser->pause();
-		_mutex.unlock();
+			freeChannels(pSnd);
+			_mutex.unlock();
+		}
 	}
 }
 

Modified: scummvm/trunk/engines/sci/sound/music.h
===================================================================
--- scummvm/trunk/engines/sci/sound/music.h	2010-06-19 17:12:17 UTC (rev 50053)
+++ scummvm/trunk/engines/sci/sound/music.h	2010-06-19 17:43:13 UTC (rev 50054)
@@ -195,6 +195,7 @@
 	Common::Mutex _mutex;
 
 	int16 tryToOwnChannel(MusicEntry *caller, int16 bestChannel);
+	void freeChannels(MusicEntry *caller);
 
 protected:
 	void sortPlayList();


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