Fixes for the advanced timer API.
This commit is contained in:
@@ -117,6 +117,13 @@ timer_is_enabled(pc_timer_t *timer)
|
||||
return !!(timer->flags & TIMER_ENABLED);
|
||||
}
|
||||
|
||||
/*True if timer currently enabled*/
|
||||
static __inline int
|
||||
timer_is_on(pc_timer_t *timer)
|
||||
{
|
||||
return ((timer->flags & TIMER_ENABLED) && (timer->period > 0.0));
|
||||
}
|
||||
|
||||
/*Return integer timestamp of timer*/
|
||||
static __inline uint32_t
|
||||
timer_get_ts_int(pc_timer_t *timer)
|
||||
@@ -204,12 +211,13 @@ timer_process_inline(void)
|
||||
timer_head->prev = NULL;
|
||||
|
||||
timer->next = timer->prev = NULL;
|
||||
timer->flags &= ~TIMER_ENABLED;
|
||||
|
||||
if (timer->flags & TIMER_SPLIT)
|
||||
timer_advance_ex(timer, 0); /* We're splitting a > 1 s period into multiple <= 1 s periods. */
|
||||
else if (timer->callback != NULL) /* Make sure it's no NULL, so that we can have a NULL callback when no operation is needed. */
|
||||
timer->callback(timer->priv);
|
||||
|
||||
timer->flags &= ~TIMER_ENABLED;
|
||||
}
|
||||
|
||||
timer_target = timer_head->ts.ts32.integer;
|
||||
|
@@ -118,12 +118,13 @@ timer_process(void)
|
||||
timer_head->prev = NULL;
|
||||
|
||||
timer->next = timer->prev = NULL;
|
||||
timer->flags &= ~TIMER_ENABLED;
|
||||
|
||||
if (timer->flags & TIMER_SPLIT)
|
||||
timer_advance_ex(timer, 0); /* We're splitting a > 1 s period into multiple <= 1 s periods. */
|
||||
else if (timer->callback != NULL) /* Make sure it's no NULL, so that we can have a NULL callback when no operation is needed. */
|
||||
timer->callback(timer->priv);
|
||||
|
||||
timer->flags &= ~TIMER_ENABLED;
|
||||
}
|
||||
|
||||
timer_target = timer_head->ts.ts32.integer;
|
||||
@@ -232,7 +233,7 @@ timer_on_auto(pc_timer_t *timer, double period)
|
||||
return;
|
||||
|
||||
if (period > 0.0)
|
||||
timer_on(timer, period, (timer->period == 0.0));
|
||||
timer_on(timer, period, !(timer->flags & TIMER_ENABLED) && (timer->period == 0.0));
|
||||
else
|
||||
timer_stop(timer);
|
||||
}
|
||||
|
Reference in New Issue
Block a user