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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Wed May 19 23:10:43 CEST 2010


Revision: 49109
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49109&view=rev
Author:   m_kiewitz
Date:     2010-05-19 21:10:43 +0000 (Wed, 19 May 2010)

Log Message:
-----------
SCI: sound code now queues up music in sci0, wip-code: not reacting on priority yet - fixes iceman room 14

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

Modified: scummvm/trunk/engines/sci/sound/music.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/music.cpp	2010-05-19 19:41:10 UTC (rev 49108)
+++ scummvm/trunk/engines/sci/sound/music.cpp	2010-05-19 21:10:43 UTC (rev 49109)
@@ -241,17 +241,34 @@
 void SciMusic::soundPlay(MusicEntry *pSnd) {
 	_mutex.lock();
 
-	uint sz = _playList.size(), i;
+	uint playListCount = _playList.size();
+	uint playListNo = playListCount;
+	bool alreadyPlaying = false;
+
 	// searching if sound is already in _playList
-	for (i = 0; i < sz && _playList[i] != pSnd; i++)
-		;
-	if (i == sz) {// not found
+	for (uint i = 0; i < playListCount; i++) {
+		if (_playList[i] == pSnd)
+			playListNo = i;
+		if (_playList[i]->status == kSoundPlaying)
+			alreadyPlaying = true;
+	}
+	if (playListNo == playListCount) { // not found
 		_playList.push_back(pSnd);
 		sortPlayList();
 	}
 
 	_mutex.unlock();	// unlock to perform mixer-related calls
 
+	if ((_soundVersion <= SCI_VERSION_0_LATE) && (alreadyPlaying)) {
+		// if any music is already playing, SCI0 queues music and plays it after the current music has finished
+		//  done by SoundCommandParser::updateSci0Cues()
+		// Example of such case: iceman room 14
+		// FIXME: this code is supposed to also take a look at priority and pause currently playing sound accordingly
+		pSnd->isQueued = true;
+		pSnd->status = kSoundPaused;
+		return;
+	}
+
 	if (pSnd->pStreamAud && !_pMixer->isSoundHandleActive(pSnd->hCurrentAud)) {
 		if (pSnd->loop > 1) {
 			pSnd->pLoopStream = new Audio::LoopingAudioStream(pSnd->pStreamAud,
@@ -444,6 +461,8 @@
 	soundRes = 0;
 	resourceId = 0;
 
+	isQueued = false;
+
 	dataInc = 0;
 	ticker = 0;
 	signal = 0;

Modified: scummvm/trunk/engines/sci/sound/music.h
===================================================================
--- scummvm/trunk/engines/sci/sound/music.h	2010-05-19 19:41:10 UTC (rev 49108)
+++ scummvm/trunk/engines/sci/sound/music.h	2010-05-19 21:10:43 UTC (rev 49109)
@@ -71,6 +71,8 @@
 	SoundResource *soundRes;
 	uint16 resourceId;
 
+	bool isQueued; // for SCI0 only!
+
 	uint16 dataInc;
 	uint16 ticker;
 	uint16 signal;

Modified: scummvm/trunk/engines/sci/sound/soundcmd.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/soundcmd.cpp	2010-05-19 19:41:10 UTC (rev 49108)
+++ scummvm/trunk/engines/sci/sound/soundcmd.cpp	2010-05-19 21:10:43 UTC (rev 49109)
@@ -1049,17 +1049,32 @@
 #ifndef USE_OLD_MUSIC_FUNCTIONS
 
 void SoundCommandParser::updateSci0Cues() {
-	Common::StackLock(_music->_mutex);
+	bool noOnePlaying = true;
+	MusicEntry *pWaitingForPlay = NULL;
 
+	_music->_mutex.lock();
+
 	const MusicList::iterator end = _music->getPlayListEnd();
 	for (MusicList::iterator i = _music->getPlayListStart(); i != end; ++i) {
 		// Is the sound stopped, and the sound object updated too? If yes, skip
 		// this sound, as SCI0 only allows one active song
+		if  (((*i)->isQueued) && (!pWaitingForPlay)) {
+			pWaitingForPlay = (*i);
+			continue;
+		}
 		if ((*i)->signal == 0 && (*i)->status != kSoundPlaying)
 			continue;
 
 		cmdUpdateCues((*i)->soundObj, 0);
+		noOnePlaying = false;
 	}
+	_music->_mutex.unlock();
+
+	if (noOnePlaying && pWaitingForPlay) {
+		// If there is a queued entry, play it now ffs: SciMusic::soundPlay()
+		pWaitingForPlay->isQueued = false;
+		_music->soundPlay(pWaitingForPlay);
+	}
 }
 
 #endif


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