diff options
author | Martin Kiewitz | 2010-06-19 17:43:13 +0000 |
---|---|---|
committer | Martin Kiewitz | 2010-06-19 17:43:13 +0000 |
commit | ab4e02422cda7ba436c667bf4a3758a4588f170a (patch) | |
tree | 8a4fdc6d0168151bac8e80526580d0555c05fc62 | |
parent | 26e4e0e345bbfb5b84a53a023b9b78207f859cc7 (diff) | |
download | scummvm-rg350-ab4e02422cda7ba436c667bf4a3758a4588f170a.tar.gz scummvm-rg350-ab4e02422cda7ba436c667bf4a3758a4588f170a.tar.bz2 scummvm-rg350-ab4e02422cda7ba436c667bf4a3758a4588f170a.zip |
SCI: free channels for channel remapping on stop and pause, instead of dispose - fixes qfg3 demo going out of channels
svn-id: r50054
-rw-r--r-- | engines/sci/sound/music.cpp | 29 | ||||
-rw-r--r-- | engines/sci/sound/music.h | 1 |
2 files changed, 19 insertions, 11 deletions
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index f6a4d5beb4..96257b1f9d 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -250,6 +250,14 @@ int16 SciMusic::tryToOwnChannel(MusicEntry *caller, int16 bestChannel) { 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 @@ void SciMusic::soundStop(MusicEntry *pSnd) { 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 @@ void SciMusic::soundKill(MusicEntry *pSnd) { _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 @@ void SciMusic::soundPause(MusicEntry *pSnd) { 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(); + } } } diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h index 8e68d3df92..cd6dcbc317 100644 --- a/engines/sci/sound/music.h +++ b/engines/sci/sound/music.h @@ -195,6 +195,7 @@ public: Common::Mutex _mutex; int16 tryToOwnChannel(MusicEntry *caller, int16 bestChannel); + void freeChannels(MusicEntry *caller); protected: void sortPlayList(); |