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

svn-id: r50054
This commit is contained in:
Martin Kiewitz 2010-06-19 17:43:13 +00:00
parent 26e4e0e345
commit ab4e02422c
2 changed files with 19 additions and 11 deletions

View File

@ -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();
}
}
}

View File

@ -195,6 +195,7 @@ public:
Common::Mutex _mutex;
int16 tryToOwnChannel(MusicEntry *caller, int16 bestChannel);
void freeChannels(MusicEntry *caller);
protected:
void sortPlayList();