Renamed class Timer to TimerManager (the old name was somewhat incorrect/confusing)

svn-id: r23278
This commit is contained in:
Max Horn 2006-06-24 09:34:49 +00:00
parent ff15667544
commit 75628fe9d7
10 changed files with 26 additions and 27 deletions

View file

@ -32,14 +32,14 @@ namespace Audio {
}
namespace Common {
class SaveFileManager;
class Timer;
class TimerManager;
}
class Engine {
public:
OSystem *_system;
Audio::Mixer *_mixer;
Common::Timer * _timer;
Common::TimerManager * _timer;
protected:
const Common::String _targetName; // target name for saves

View file

@ -317,7 +317,7 @@ extern "C" int scummvm_main(int argc, char *argv[]) {
system.initBackend();
// Create the timer services
Common::g_timer = new Common::Timer(&system);
Common::g_timer = new Common::TimerManager(&system);
// Set initial window caption
system.setWindowCaption(gScummVMFullVersion);

View file

@ -29,9 +29,9 @@
namespace Common {
Timer *g_timer = NULL;
TimerManager *g_timer = NULL;
Timer::Timer(OSystem *system) :
TimerManager::TimerManager(OSystem *system) :
_system(system),
_timerHandler(0),
_lastTime(0) {
@ -51,10 +51,10 @@ Timer::Timer(OSystem *system) :
}
Timer::~Timer() {
TimerManager::~TimerManager() {
// 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 occurs.
// the handler is not in use anymore; else race condtions could occur.
_system->setTimerCallback(0, 0);
{
@ -67,13 +67,13 @@ Timer::~Timer() {
}
}
int Timer::timer_handler(int t) {
int TimerManager::timer_handler(int t) {
if (g_timer)
return g_timer->handler(t);
return 0;
}
int Timer::handler(int t) {
int TimerManager::handler(int t) {
StackLock lock(_mutex);
uint32 interval, l;
@ -97,7 +97,7 @@ int Timer::handler(int t) {
return t;
}
bool Timer::installTimerProc(TimerProc procedure, int32 interval, void *refCon) {
bool TimerManager::installTimerProc(TimerProc procedure, int32 interval, void *refCon) {
assert(interval > 0);
StackLock lock(_mutex);
@ -115,7 +115,7 @@ bool Timer::installTimerProc(TimerProc procedure, int32 interval, void *refCon)
return false;
}
void Timer::removeTimerProc(TimerProc procedure) {
void TimerManager::removeTimerProc(TimerProc procedure) {
StackLock lock(_mutex);
for (int l = 0; l < MAX_TIMERS; l++) {

View file

@ -36,7 +36,7 @@ class OSystem;
namespace Common {
class Timer {
class TimerManager {
public:
typedef void (*TimerProc)(void *refCon);
@ -55,8 +55,8 @@ private:
} _timerSlots[MAX_TIMERS];
public:
Timer(OSystem *system);
~Timer();
TimerManager(OSystem *system);
~TimerManager();
/**
* Install a new timer callback. It will from now be called every interval microseconds.
@ -82,7 +82,7 @@ protected:
int handler(int t);
};
extern Timer *g_timer;
extern TimerManager *g_timer;
} // End of namespace Common

View file

@ -269,9 +269,8 @@ int agi_get_keypress_low() {
return k;
}
static uint32 agi_timer_function_low(uint32 i) {
static void agi_timer_function_low(void *refCon) {
tick_timer++;
return i;
}
static void init_pri_table() {
@ -526,7 +525,7 @@ void AgiEngine::initialize() {
init_video();
tick_timer = 0;
Common::g_timer->installTimerProc((Common::Timer::TimerProc) agi_timer_function_low, 10 * 1000, NULL);
Common::g_timer->installTimerProc(agi_timer_function_low, 10 * 1000, NULL);
game.ver = -1; /* Don't display the conf file warning */

View file

@ -190,7 +190,7 @@ public:
virtual void metaEvent(byte type, byte *data, uint16 length) { }
// Timing functions - MidiDriver now operates timers
virtual void setTimerCallback(void *timer_param, Common::Timer::TimerProc timer_proc) = 0;
virtual void setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc) = 0;
/** The time in microseconds between invocations of the timer callback. */
virtual uint32 getBaseTempo(void) = 0;

View file

@ -131,7 +131,7 @@ MidiChannel *MidiDriver_MPU401::allocateChannel() {
return NULL;
}
void MidiDriver_MPU401::setTimerCallback(void *timer_param, Common::Timer::TimerProc timer_proc) {
void MidiDriver_MPU401::setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc) {
if (!_timer_proc || !timer_proc) {
if (_timer_proc)
Common::g_timer->removeTimerProc(_timer_proc);

View file

@ -71,14 +71,14 @@ public:
class MidiDriver_MPU401 : public MidiDriver {
private:
MidiChannel_MPU401 _midi_channels[16];
Common::Timer::TimerProc _timer_proc;
Common::TimerManager::TimerProc _timer_proc;
uint16 _channel_mask;
public:
MidiDriver_MPU401();
virtual void close();
void setTimerCallback(void *timer_param, Common::Timer::TimerProc timer_proc);
void setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc);
uint32 getBaseTempo(void) { return 10000; }
uint32 property(int prop, uint32 param);

View file

@ -32,7 +32,7 @@ protected:
Audio::Mixer *_mixer;
private:
Common::Timer::TimerProc _timerProc;
Common::TimerManager::TimerProc _timerProc;
void *_timerParam;
int _nextTick;
@ -70,7 +70,7 @@ public:
return 0;
}
void setTimerCallback(void *timer_param, Common::Timer::TimerProc timer_proc) {
void setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc) {
_timerProc = timer_proc;
_timerParam = timer_param;
}

View file

@ -391,7 +391,7 @@ class MidiDriver_ThreadedMT32 : public MidiDriver_MT32 {
private:
OSystem::Mutex _eventMutex;
MidiEvent_MT32 *_events;
Timer::TimerProc _timer_proc;
TimerManager::TimerProc _timer_proc;
void pushMidiEvent(MidiEvent_MT32 *event);
MidiEvent_MT32 *popMidiEvent();
@ -405,7 +405,7 @@ public:
void onTimer();
void close();
void setTimerCallback(void *timer_param, Timer::TimerProc timer_proc);
void setTimerCallback(void *timer_param, TimerManager::TimerProc timer_proc);
};
@ -421,7 +421,7 @@ void MidiDriver_ThreadedMT32::close() {
}
}
void MidiDriver_ThreadedMT32::setTimerCallback(void *timer_param, Timer::TimerProc timer_proc) {
void MidiDriver_ThreadedMT32::setTimerCallback(void *timer_param, TimerManager::TimerProc timer_proc) {
if (!_timer_proc || !timer_proc) {
if (_timer_proc)
g_timer->removeTimerProc(_timer_proc);