diff options
author | Filippos Karapetis | 2009-12-26 13:20:07 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-12-26 13:20:07 +0000 |
commit | d39ac80f4a8667c20f09c765bcdb9701a828dc28 (patch) | |
tree | e5db9d1f64429fef291738528ac47a834470517b /engines/sci/sfx | |
parent | c6a8d0e97399dc01f1d4263d752adcb73d7a95d2 (diff) | |
download | scummvm-rg350-d39ac80f4a8667c20f09c765bcdb9701a828dc28.tar.gz scummvm-rg350-d39ac80f4a8667c20f09c765bcdb9701a828dc28.tar.bz2 scummvm-rg350-d39ac80f4a8667c20f09c765bcdb9701a828dc28.zip |
Hopefully fixed the freezes/deadlocks in the new music code (e.g. in LSL5 and Castle of Dr. Brain)
svn-id: r46579
Diffstat (limited to 'engines/sci/sfx')
-rw-r--r-- | engines/sci/sfx/music.cpp | 15 | ||||
-rw-r--r-- | engines/sci/sfx/music.h | 11 |
2 files changed, 12 insertions, 14 deletions
diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp index ebe1d6616e..7559359325 100644 --- a/engines/sci/sfx/music.cpp +++ b/engines/sci/sfx/music.cpp @@ -43,6 +43,10 @@ static int f_compare(const void *arg1, const void *arg2) { SciMusic::SciMusic(SciVersion soundVersion) : _soundVersion(soundVersion) { + + // Reserve some space in the playlist, to avoid expensive insertion + // operations + _playList.reserve(10); } SciMusic::~SciMusic() { @@ -370,6 +374,8 @@ void SciMusic::onTimer() { } //--------------------------------------------- void SciMusic::doFade(MusicEntry *pSnd) { + // This is called from inside onTimer, where the mutex is already locked + if (pSnd->fadeTicker) pSnd->fadeTicker--; else { @@ -401,10 +407,13 @@ void SciMusic::soundPlay(MusicEntry *pSnd) { _pMixer->playInputStream(Audio::Mixer::kSFXSoundType, &pSnd->hCurrentAud, pSnd->pStreamAud, -1, pSnd->volume, 0, false); } else if (pSnd->pMidiParser) { + _mutex.lock(); pSnd->pMidiParser->setVolume(pSnd->volume); if (pSnd->status == kSndStatusStopped) pSnd->pMidiParser->jumpToTick(0); + _mutex.unlock(); } + pSnd->status = kSndStatusPlaying; } //--------------------------------------------- @@ -434,9 +443,8 @@ void SciMusic::soundSetPriority(MusicEntry *pSnd, byte prio) { //--------------------------------------------- void SciMusic::soundKill(MusicEntry *pSnd) { - _mutex.lock(); - pSnd->status = kSndStatusStopped; + if (pSnd->pMidiParser) { pSnd->pMidiParser->unloadMusic(); delete pSnd->pMidiParser; @@ -447,6 +455,8 @@ void SciMusic::soundKill(MusicEntry *pSnd) { pSnd->pStreamAud = NULL; } + _mutex.lock(); + uint sz = _playList.size(), i; // Remove sound from playlist for (i = 0; i < sz; i++) { @@ -459,7 +469,6 @@ void SciMusic::soundKill(MusicEntry *pSnd) { } _mutex.unlock(); - } //--------------------------------------------- void SciMusic::soundPause(MusicEntry *pSnd) { diff --git a/engines/sci/sfx/music.h b/engines/sci/sfx/music.h index f7066743f4..ca6d12613d 100644 --- a/engines/sci/sfx/music.h +++ b/engines/sci/sfx/music.h @@ -135,11 +135,6 @@ public: } MusicEntry *getSlot(int slot) { return _playList[slot]; } - void setSlot(uint32 slot, MusicEntry *slotEntry) { - _mutex.lock(); - _playList[slot] = slotEntry; - _mutex.unlock(); - } void pushBackSlot(MusicEntry *slotEntry) { _mutex.lock(); @@ -149,12 +144,6 @@ public: uint32 listSize() { return _playList.size(); } - void resizeList(uint32 newSize) { - _mutex.lock(); - _playList.resize(newSize); - _mutex.unlock(); - } - uint16 _savelen; protected: |