diff options
author | Filippos Karapetis | 2009-12-28 20:10:15 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-12-28 20:10:15 +0000 |
commit | 5cb5fe22ea2fc77473ba9d8714d66a712b061e1e (patch) | |
tree | 224bd26187863f3cefbec1891eed5e16e90d89a9 /engines/sci/sfx/music.cpp | |
parent | 871d5c534d4669a075023f51bc06417418bd080e (diff) | |
download | scummvm-rg350-5cb5fe22ea2fc77473ba9d8714d66a712b061e1e.tar.gz scummvm-rg350-5cb5fe22ea2fc77473ba9d8714d66a712b061e1e.tar.bz2 scummvm-rg350-5cb5fe22ea2fc77473ba9d8714d66a712b061e1e.zip |
SCI/new sound code:
- Made the SciMusic class private, and added wrapper functions for invoking specific methods of SciMusic from outside the SoundCommandParser class
- Many SCI games keep creating and destroying sound effects constantly (i.e. many times per second). Therefore, another scheme has been devised, which replaces the mutex that was in place. Whenever a sound command is run which operates on a specific object in the play list, we disallow onTimer() from kicking in. This isn't ideal, but it does stop random deadlocks because of locked mutexes without any noticeable side effects
svn-id: r46681
Diffstat (limited to 'engines/sci/sfx/music.cpp')
-rw-r--r-- | engines/sci/sfx/music.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp index fe22cf356a..e0f9111088 100644 --- a/engines/sci/sfx/music.cpp +++ b/engines/sci/sfx/music.cpp @@ -42,7 +42,7 @@ static int f_compare(const void *arg1, const void *arg2) { } SciMusic::SciMusic(SciVersion soundVersion) - : _soundVersion(soundVersion), _soundOn(true) { + : _soundVersion(soundVersion), _soundOn(true), _inCriticalSection(false) { // Reserve some space in the playlist, to avoid expensive insertion // operations @@ -125,8 +125,6 @@ bool SciMusic::saveState(Common::OutSaveFile *pFile) { //---------------------------------------- void SciMusic::clearPlayList() { - Common::StackLock lock(_mutex); - _pMixer->stopAll(); while (!_playList.empty()) { @@ -136,8 +134,6 @@ void SciMusic::clearPlayList() { } //---------------------------------------- void SciMusic::stopAll() { - Common::StackLock lock(_mutex); - SegManager *segMan = ((SciEngine *)g_engine)->getEngineState()->_segMan; // HACK for (uint32 i = 0; i < _playList.size(); i++) { @@ -352,6 +348,9 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) { void SciMusic::onTimer() { Common::StackLock lock(_mutex); + if (_inCriticalSection) + return; + uint sz = _playList.size(); for (uint i = 0; i < sz; i++) { if (_playList[i]->status != kSndStatusPlaying) @@ -399,8 +398,6 @@ void SciMusic::doFade(MusicEntry *pSnd) { //--------------------------------------------- void SciMusic::soundPlay(MusicEntry *pSnd) { - Common::StackLock lock(_mutex); - uint sz = _playList.size(), i; // searching if sound is already in _playList for (i = 0; i < sz && _playList[i] != pSnd; i++) @@ -438,8 +435,6 @@ void SciMusic::soundSetVolume(MusicEntry *pSnd, byte volume) { } //--------------------------------------------- void SciMusic::soundSetPriority(MusicEntry *pSnd, byte prio) { - Common::StackLock lock(_mutex); - pSnd->prio = prio; sortPlayList(); } @@ -457,8 +452,6 @@ void SciMusic::soundKill(MusicEntry *pSnd) { pSnd->pStreamAud = NULL; } - Common::StackLock lock(_mutex); - uint sz = _playList.size(), i; // Remove sound from playlist for (i = 0; i < sz; i++) { @@ -493,7 +486,7 @@ void SciMusic::soundSetMasterVolume(uint16 vol) { _pMixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, vol); } -void SciMusic::printSongLib(Console *con) { +void SciMusic::printPlayList(Console *con) { Common::StackLock lock(_mutex); const char *musicStatus[] = { "Stopped", "Initialized", "Paused", "Playing" }; @@ -504,9 +497,7 @@ void SciMusic::printSongLib(Console *con) { } } -void SciMusic::reconstructSounds(int savegame_version) { - Common::StackLock lock(_mutex); - +void SciMusic::reconstructPlayList(int savegame_version) { SegManager *segMan = ((SciEngine *)g_engine)->getEngineState()->_segMan; // HACK ResourceManager *resMan = ((SciEngine *)g_engine)->getEngineState()->resMan; // HACK |