diff options
author | Paul Gilbert | 2017-11-21 07:25:21 -0500 |
---|---|---|
committer | GitHub | 2017-11-21 07:25:21 -0500 |
commit | 6fe801e3cd5826195c2f8731e7e78bdf04074bfc (patch) | |
tree | 1e9d968a43b3936b4a2128d550249e74fc0b39b8 | |
parent | 4045b9a7b748da83b4ce1acaa1403becfa592505 (diff) | |
parent | 2e034c0550db4dd443f4cb5464513a87ce0f404b (diff) | |
download | scummvm-rg350-6fe801e3cd5826195c2f8731e7e78bdf04074bfc.tar.gz scummvm-rg350-6fe801e3cd5826195c2f8731e7e78bdf04074bfc.tar.bz2 scummvm-rg350-6fe801e3cd5826195c2f8731e7e78bdf04074bfc.zip |
Merge pull request #1065 from csnover/tsage-fixes
TSAGE: Various fixes
-rw-r--r-- | engines/tsage/core.cpp | 2 | ||||
-rw-r--r-- | engines/tsage/sound.cpp | 35 | ||||
-rw-r--r-- | engines/tsage/sound.h | 5 | ||||
-rw-r--r-- | engines/tsage/user_interface.cpp | 2 |
4 files changed, 16 insertions, 28 deletions
diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index a3ed3abb5b..247070d59c 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -93,7 +93,7 @@ InvObject::InvObject(int strip, int frame) { void InvObject::setCursor() { if (g_vm->getGameID() != GType_Ringworld) { // All other games - _cursorId = (CursorType)BF_GLOBALS._inventory->indexOf(this); + _cursorId = (CursorType)g_globals->_inventory->indexOf(this); g_globals->_events.setCursor(_cursorId); } else { // Ringworld cursor handling diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp index 0d3fb55dd3..044bd567d4 100644 --- a/engines/tsage/sound.cpp +++ b/engines/tsage/sound.cpp @@ -23,6 +23,7 @@ #include "audio/fmopl.h" #include "audio/decoders/raw.h" #include "common/config-manager.h" +#include "common/timer.h" #include "audio/audiostream.h" #include "tsage/core.h" #include "tsage/globals.h" @@ -70,7 +71,7 @@ SoundManager::~SoundManager() { } sfTerminate(); -// g_system->getTimerManager()->removeTimerProc(_sfUpdateCallback); + g_system->getTimerManager()->removeTimerProc(&sfSoundServer); } // Free any allocated voice type structures @@ -90,12 +91,7 @@ void SoundManager::postInit() { g_saver->addLoadNotifier(&SoundManager::loadNotifier); g_saver->addListener(this); - -// I originally separated the sound manager update method into a separate thread, since -// it handles updates for both music and Fx. However, since Adlib updates also get done in a -// thread, and doesn't get too far ahead, I've left it to the AdlibSoundDriver class to -// call the update method, rather than having it be called separately -// g_system->getTimerManager()->installTimerProc(_sfUpdateCallback, 1000000 / SOUND_FREQUENCY, NULL, "tsageSoundUpdate"); + g_system->getTimerManager()->installTimerProc(&sfSoundServer, 1000000 / CALLBACKS_PER_SECOND, NULL, "tsageSoundUpdate"); _sndmgrReady = true; } } @@ -147,10 +143,6 @@ void SoundManager::syncSounds() { } } -void SoundManager::update() { - sfSoundServer(); -} - Common::List<SoundDriverEntry> &SoundManager::buildDriverList(bool detectFlag) { assert(_sndmgrReady); _availableDrivers.clear(); @@ -382,7 +374,10 @@ void SoundManager::rethinkVoiceTypes() { sfRethinkVoiceTypes(); } -void SoundManager::sfSoundServer() { +void SoundManager::sfSoundServer(void *) { + Common::StackLock slock1(SoundManager::sfManager()._serverDisabledMutex); + Common::StackLock slock2(SoundManager::sfManager()._serverSuspendedMutex); + if (sfManager()._needToRethink) { sfRethinkVoiceTypes(); sfManager()._needToRethink = false; @@ -544,10 +539,6 @@ void SoundManager::sfUpdateVoiceStructs2() { } } -void SoundManager::sfUpdateCallback(void *ref) { - ((SoundManager *)ref)->update(); -} - /*--------------------------------------------------------------------------*/ void SoundManager::saveNotifier(bool postFlag) { @@ -1562,7 +1553,9 @@ void Sound::play(int soundNum) { } void Sound::stop() { - g_globals->_soundManager.removeFromPlayList(this); + if (g_globals) { + g_globals->_soundManager.removeFromPlayList(this); + } _unPrime(); } @@ -2879,13 +2872,13 @@ void AdlibSoundDriver::setPitch(int channel, int pitchBlend) { } void AdlibSoundDriver::write(byte reg, byte value) { + Common::StackLock lock(_queueMutex); _portContents[reg] = value; _queue.push(RegisterValue(reg, value)); } void AdlibSoundDriver::flush() { - Common::StackLock slock(SoundManager::sfManager()._serverDisabledMutex); - + Common::StackLock lock(_queueMutex); while (!_queue.empty()) { RegisterValue v = _queue.pop(); _opl->writeReg(v._regNum, v._value); @@ -3013,10 +3006,6 @@ void AdlibSoundDriver::setFrequency(int channel) { } void AdlibSoundDriver::onTimer() { - Common::StackLock slock1(SoundManager::sfManager()._serverDisabledMutex); - Common::StackLock slock2(SoundManager::sfManager()._serverSuspendedMutex); - - SoundManager::sfUpdateCallback(NULL); flush(); } diff --git a/engines/tsage/sound.h b/engines/tsage/sound.h index da56c8bfa5..6d6b480d58 100644 --- a/engines/tsage/sound.h +++ b/engines/tsage/sound.h @@ -196,7 +196,6 @@ public: virtual void listenerSynchronize(Serializer &s); virtual void postInit(); void syncSounds(); - void update(); static void saveNotifier(bool postFlag); void saveNotifierProc(bool postFlag); @@ -252,11 +251,10 @@ public: static void sfDoAddToPlayList(Sound *sound); static bool sfDoRemoveFromPlayList(Sound *sound); static void sfDoUpdateVolume(Sound *sound); - static void sfSoundServer(); + static void sfSoundServer(void *); static void sfProcessFading(); static void sfUpdateVoiceStructs(); static void sfUpdateVoiceStructs2(); - static void sfUpdateCallback(void *ref); }; class Sound: public EventHandler { @@ -460,6 +458,7 @@ private: byte _portContents[256]; const byte *_patchData; int _masterVolume; + Common::Mutex _queueMutex; Common::Queue<RegisterValue> _queue; bool _channelVoiced[ADLIB_CHANNEL_COUNT]; diff --git a/engines/tsage/user_interface.cpp b/engines/tsage/user_interface.cpp index fffc0dc16c..d5e40cba83 100644 --- a/engines/tsage/user_interface.cpp +++ b/engines/tsage/user_interface.cpp @@ -205,7 +205,7 @@ void UIInventoryScroll::process(Event &event) { toggle(true); // Wait for the mouse to be released - BF_GLOBALS._events.waitForPress(EVENT_BUTTON_UP); + g_globals->_events.waitForPress(EVENT_BUTTON_UP); // Restore unselected version toggle(false); |