kolibrios-fun/contrib/media/fplay/winlib/timer.h
Sergey Semyonov (Serge) 65ae2ea810 Fplay: missing files and functions
git-svn-id: svn://kolibrios.org@4446 a494cfbc-eb01-0410-851d-a64ba20cac60
2014-01-13 14:57:59 +00:00

47 lines
1.0 KiB
C

static uint32_t update_timers(uint32_t realtime)
{
ostimer_t *timer;
uint32_t exp_time = -1;
timer = (ostimer_t*)timers.next;
while( &timer->link != &timers)
{
ostimer_t *tmp;
tmp = timer;
timer = (ostimer_t*)timer->link.next;
if( tmp->exp_time < realtime)
{
list_remove(&tmp->link);
send_message(tmp->ctrl, MSG_TIMER, tmp->tmr_arg, tmp);
}
};
timer = (ostimer_t*)timers.next;
while( &timer->link != &timers)
{
if( exp_time > timer->exp_time)
exp_time = timer->exp_time;
timer = (ostimer_t*)timer->link.next;
}
return exp_time;
};
int set_timer(ctrl_t *ctrl, ostimer_t *timer, uint32_t delay)
{
if( ctrl && timer &&delay)
{
timer->ctrl = ctrl;
timer->exp_time = realtime + delay;
if( exp_time > timer->exp_time)
exp_time = timer->exp_time;
list_append(&timer->link, &timers);
};
return 0;
}