VLC  2.1.0-git
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Functions
timer.c File Reference
Include dependency graph for timer.c:

Data Structures

struct  vlc_timer

Functions

static void * vlc_timer_thread (void *data)
int vlc_timer_create (vlc_timer_t *id, void(*func)(void *), void *data)
 Initializes an asynchronous timer.
void vlc_timer_destroy (vlc_timer_t timer)
 Destroys an initialized timer.
void vlc_timer_schedule (vlc_timer_t timer, bool absolute, mtime_t value, mtime_t interval)
 Arm or disarm an initialized timer.
unsigned vlc_timer_getoverrun (vlc_timer_t timer)
 Fetch and reset the overrun counter for a timer.

Function Documentation

int vlc_timer_create ( vlc_timer_t id,
void(*)(void *)  func,
void *  data 
)

Initializes an asynchronous timer.

Warning
Asynchronous timers are processed from an unspecified thread. Multiple occurences of a single interval timer are serialized; they cannot run concurrently.
Parameters
idpointer to timer to be initialized
funcfunction that the timer will call
dataparameter for the timer function
Returns
0 on success, a system error code otherwise.

References atomic_init, vlc_timer::data, vlc_timer::func, vlc_timer::interval, vlc_timer::lock, vlc_timer::overruns, vlc_timer::reschedule, vlc_timer::thread, unlikely, vlc_timer::value, vlc_clone(), vlc_cond_destroy(), vlc_cond_init(), vlc_mutex_destroy(), vlc_mutex_init(), VLC_THREAD_PRIORITY_INPUT, and vlc_timer_thread().

void vlc_timer_destroy ( vlc_timer_t  timer)

Destroys an initialized timer.

If needed, the timer is first disarmed. This function is undefined if the specified timer is not initialized.

Warning
This function must be called before the timer data can be freed and before the timer callback function can be unloaded.
Parameters
timertimer to destroy

References vlc_timer::lock, vlc_timer::reschedule, vlc_timer::thread, vlc_cancel(), vlc_cond_destroy(), vlc_join(), and vlc_mutex_destroy().

unsigned vlc_timer_getoverrun ( vlc_timer_t  timer)

Fetch and reset the overrun counter for a timer.

Parameters
timerinitialized timer
Returns
the timer overrun counter, i.e. the number of times that the timer should have run but did not since the last actual run. If all is well, this is zero.

References vlc_timer::overruns.

void vlc_timer_schedule ( vlc_timer_t  timer,
bool  absolute,
mtime_t  value,
mtime_t  interval 
)

Arm or disarm an initialized timer.

This functions overrides any previous call to itself.

Note
A timer can fire later than requested due to system scheduling limitations. An interval timer can fail to trigger sometimes, either because the system is busy or suspended, or because a previous iteration of the timer is still running. See also vlc_timer_getoverrun().
Parameters
timerinitialized timer
absolutethe timer value origin is the same as mdate() if true, the timer value is relative to now if false.
valuezero to disarm the timer, otherwise the initial time to wait before firing the timer.
intervalzero to fire the timer just once, otherwise the timer repetition interval.

References vlc_timer::interval, vlc_timer::lock, mdate(), vlc_timer::reschedule, vlc_timer::value, vlc_cond_signal(), vlc_mutex_lock(), and vlc_mutex_unlock().

static void* vlc_timer_thread ( void *  data)
static