ALSA project - the C library reference
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Timer interface

Timer interface is designed to use internal timers in sound hardware, but it can be driven with any timer.

General overview

The timer implementation uses ring buffer to store information about timing events. In this buffer is recorded count of ticks and current tick resolution in nanoseconds.

Opening

Timer devices can be opened in two ways. When SND_TIMER_OPEN_NONBLOCK flag is used, then the open functions return immediately with -EBUSY error code when resources are occupied with another application. When SND_TIMER_OPEN_NONBLOCK is not used (by default) the open functions block the application requesting device until resources are not free.

Events

Events are read via snd_timer_read() function.

Examples

The full featured examples with cross-links:

Simple timer test program
example code
This example shows opening a timer device and reading of timer events.