diff options
author | Max Horn | 2006-10-22 15:42:29 +0000 |
---|---|---|
committer | Max Horn | 2006-10-22 15:42:29 +0000 |
commit | 07f7761479eba5defdcfe0bd300bc438d9245551 (patch) | |
tree | 1d5d2ca4852369e9e5502b015926ab3e2ec4429f /backends/timer/default | |
parent | df24f1ef4ed2b8d0e6c5df6e1bfbbcb2fc86d2a8 (diff) | |
download | scummvm-rg350-07f7761479eba5defdcfe0bd300bc438d9245551.tar.gz scummvm-rg350-07f7761479eba5defdcfe0bd300bc438d9245551.tar.bz2 scummvm-rg350-07f7761479eba5defdcfe0bd300bc438d9245551.zip |
Backend modularization: Create timer manager, savefile manager and audio mixer in the backends for increased flexibility
svn-id: r24443
Diffstat (limited to 'backends/timer/default')
-rw-r--r-- | backends/timer/default/default-timer.cpp | 43 | ||||
-rw-r--r-- | backends/timer/default/default-timer.h | 6 |
2 files changed, 10 insertions, 39 deletions
diff --git a/backends/timer/default/default-timer.cpp b/backends/timer/default/default-timer.cpp index 907c715a07..245291c06c 100644 --- a/backends/timer/default/default-timer.cpp +++ b/backends/timer/default/default-timer.cpp @@ -25,61 +25,34 @@ #include "common/util.h" #include "common/system.h" -namespace Common { -// FIXME: Hack: This global variable shouldn't be declared here; in fact it -// probably shouldn't be declared at all but rather a different method to -// query the TimerManager object should be invented. -TimerManager *g_timer = NULL; -} - -DefaultTimerManager::DefaultTimerManager(OSystem *system) : - _system(system), +DefaultTimerManager::DefaultTimerManager() : _timerHandler(0), _lastTime(0) { - Common::g_timer = this; - for (int i = 0; i < MAX_TIMERS; i++) { _timerSlots[i].procedure = NULL; _timerSlots[i].interval = 0; _timerSlots[i].counter = 0; } - _thisTime = _system->getMillis(); - - // Set the timer last, after everything has been initialised - _system->setTimerCallback(&timer_handler, 10); - + _thisTime = g_system->getMillis(); } DefaultTimerManager::~DefaultTimerManager() { - // Remove the timer callback. - // Note: backends *must* gurantee that after this method call returns, - // the handler is not in use anymore; else race condtions could occur. - _system->setTimerCallback(0, 0); - - { - Common::StackLock lock(_mutex); - for (int i = 0; i < MAX_TIMERS; i++) { - _timerSlots[i].procedure = NULL; - _timerSlots[i].interval = 0; - _timerSlots[i].counter = 0; - } + Common::StackLock lock(_mutex); + for (int i = 0; i < MAX_TIMERS; i++) { + _timerSlots[i].procedure = NULL; + _timerSlots[i].interval = 0; + _timerSlots[i].counter = 0; } } -int DefaultTimerManager::timer_handler(int t) { - if (Common::g_timer) - return ((DefaultTimerManager *)Common::g_timer)->handler(t); - return 0; -} - int DefaultTimerManager::handler(int t) { Common::StackLock lock(_mutex); uint32 interval, l; _lastTime = _thisTime; - _thisTime = _system->getMillis(); + _thisTime = g_system->getMillis(); interval = 1000 * (_thisTime - _lastTime); for (l = 0; l < MAX_TIMERS; l++) { diff --git a/backends/timer/default/default-timer.h b/backends/timer/default/default-timer.h index 12779cc59c..8c16122b02 100644 --- a/backends/timer/default/default-timer.h +++ b/backends/timer/default/default-timer.h @@ -32,7 +32,6 @@ private: enum { MAX_TIMERS = 8 }; - OSystem *_system; Common::Mutex _mutex; void *_timerHandler; int32 _thisTime; @@ -46,13 +45,12 @@ private: } _timerSlots[MAX_TIMERS]; public: - DefaultTimerManager(OSystem *system); + DefaultTimerManager(); ~DefaultTimerManager(); bool installTimerProc(TimerProc proc, int32 interval, void *refCon); void removeTimerProc(TimerProc proc); -protected: - static int timer_handler(int t); + // Timer callback, to be invoked at regular time intervals by the backend. int handler(int t); }; |