mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-03 09:23:37 +00:00
NULL: Ensure that the timer callback is called regularly
This commit is contained in:
parent
068b3371bd
commit
30c00656e1
@ -116,14 +116,16 @@ void OSystem_NULL::initBackend() {
|
||||
|
||||
((Audio::MixerImpl *)_mixer)->setReady(false);
|
||||
|
||||
// Note that both the mixer and the timer manager are useless
|
||||
// this way; they need to be hooked into the system somehow to
|
||||
// be functional. Of course, can't do that in a NULL backend :).
|
||||
// Note that the mixer is useless this way; it needs to be hooked
|
||||
// into the system somehow to be functional. Of course, can't do
|
||||
// that in a NULL backend :).
|
||||
|
||||
ModularBackend::initBackend();
|
||||
}
|
||||
|
||||
bool OSystem_NULL::pollEvent(Common::Event &event) {
|
||||
((DefaultTimerManager *)getTimerManager())->checkTimers();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,7 @@ void insertPrioQueue(TimerSlot *head, TimerSlot *newSlot) {
|
||||
|
||||
|
||||
DefaultTimerManager::DefaultTimerManager() :
|
||||
_timerCallbackNext(0),
|
||||
_head(0) {
|
||||
|
||||
_head = new TimerSlot();
|
||||
@ -114,6 +115,16 @@ void DefaultTimerManager::handler() {
|
||||
}
|
||||
}
|
||||
|
||||
void DefaultTimerManager::checkTimers(uint32 interval) {
|
||||
uint32 curTime = g_system->getMillis();
|
||||
|
||||
// Timer checking & firing
|
||||
if (curTime >= _timerCallbackNext) {
|
||||
handler();
|
||||
_timerCallbackNext = curTime + interval;
|
||||
}
|
||||
}
|
||||
|
||||
bool DefaultTimerManager::installTimerProc(TimerProc callback, int32 interval, void *refCon, const Common::String &id) {
|
||||
assert(interval > 0);
|
||||
Common::StackLock lock(_mutex);
|
||||
|
@ -38,6 +38,8 @@ private:
|
||||
TimerSlot *_head;
|
||||
TimerSlotMap _callbacks;
|
||||
|
||||
uint32 _timerCallbackNext;
|
||||
|
||||
public:
|
||||
DefaultTimerManager();
|
||||
virtual ~DefaultTimerManager();
|
||||
@ -48,6 +50,12 @@ public:
|
||||
* Timer callback, to be invoked at regular time intervals by the backend.
|
||||
*/
|
||||
void handler();
|
||||
|
||||
/*
|
||||
* Ensure that the callback is called at regular time intervals.
|
||||
* Should be called from pollEvents() on backends without threads.
|
||||
*/
|
||||
void checkTimers(uint32 interval = 10);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user