aboutsummaryrefslogtreecommitdiff
path: root/backends/timer/default/default-timer.cpp
diff options
context:
space:
mode:
authorMax Horn2006-10-22 15:42:29 +0000
committerMax Horn2006-10-22 15:42:29 +0000
commit07f7761479eba5defdcfe0bd300bc438d9245551 (patch)
tree1d5d2ca4852369e9e5502b015926ab3e2ec4429f /backends/timer/default/default-timer.cpp
parentdf24f1ef4ed2b8d0e6c5df6e1bfbbcb2fc86d2a8 (diff)
downloadscummvm-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/default-timer.cpp')
-rw-r--r--backends/timer/default/default-timer.cpp43
1 files changed, 8 insertions, 35 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++) {