Timer Class Reference

ALSA Timer management. More...

#include <alsatimer.h>

Inheritance diagram for Timer:

Inheritance graph
[legend]

List of all members.

Classes

class  TimerInputThread
 This class manages timer events input from ALSA.

Signals

void timerExpired (int ticks, int msecs)
 This signal is emitted when the timer has expired, if there is not an event hander installed.

Public Member Functions

 Timer (int cls, int scls, int card, int dev, int sdev, int openMode, QObject *parent=0)
 Constructor.
 Timer (const QString &deviceName, int openMode, QObject *parent=0)
 Constructor.
 Timer (const QString &deviceName, int openMode, snd_config_t *config, QObject *parent=0)
 Constructor.
 Timer (TimerId &id, int openMode, QObject *parent=0)
 Constructor Open flags can be a combination of the following constants:.
virtual ~Timer ()
 Destructor.
snd_timer_t * getHandle ()
 Gets the ALSA timer object.
TimerInfogetTimerInfo ()
 Gets the timer info object.
TimerStatusgetTimerStatus ()
 Gets the timer status.
void setTimerParams (const TimerParams &params)
 Sets the timer parameters.
void start ()
 Start rolling the timer.
void stop ()
 Stop rolling the timer.
void continueRunning ()
 Continue rolling the timer.
void addAsyncTimerHandler (snd_async_callback_t callback, void *private_data)
 Adds an asynchronous timer handler function.
int getPollDescriptorsCount ()
 Gets the count of poll descriptors.
void pollDescriptors (struct pollfd *pfds, unsigned int space)
 Gets poll descriptors.
void pollDescriptorsRevents (struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
 Gets returned events from poll descriptors.
ssize_t read (void *buffer, size_t size)
 Read bytes from the timer handle.
snd_timer_t * getTimerHandle ()
 Gets the ALSA timer handle.
void setHandler (TimerEventHandler *h)
 Sets an event handler providing a method to be called when a timer expires.
void startEvents ()
 Starts the events dispatching thread.
void stopEvents ()
 Stops the events dispatching thread.

Static Public Member Functions

static TimerId bestGlobalTimerId ()
 Check and return the best available global TimerId in the system, meaning the timer with higher frequency (or lesser period, resolution).
static TimerbestGlobalTimer (int openMode, QObject *parent=0)
 Check and return the best available global Timer in the system, meaning the timer with higher frequency (or lesser period, resolution).

Protected Member Functions

void doEvents ()
 Internal function to deliver the timer events using one of the two available methods:.


Detailed Description

ALSA Timer management.

This class represents an ALSA timer object.

Examples:

sysinfo.cpp.

Definition at line 267 of file alsatimer.h.


Constructor & Destructor Documentation

Timer ( int  cls,
int  scls,
int  card,
int  dev,
int  sdev,
int  openMode,
QObject parent = 0 
)

Constructor.

Open flags can be a combination of the following constants:

  • SND_TIMER_OPEN_NONBLOCK: non-blocking behavior
  • SND_TIMER_OPEN_TREAD: enhanced read, use time-stamps and event notification
Parameters:
cls Class
scls Subclass
card Card
dev Device
sdev Subdevice
openMode Open mode flags bitmap
parent Optional parent object

Definition at line 1111 of file alsatimer.cpp.

References CHECK_ERROR.

Referenced by Timer::bestGlobalTimer().

Timer ( const QString &  deviceName,
int  openMode,
QObject parent = 0 
)

Constructor.

Open flags can be a combination of the following constants:

  • SND_TIMER_OPEN_NONBLOCK: non-blocking behavior
  • SND_TIMER_OPEN_TREAD: enhanced read, use time-stamps and event notification
Parameters:
deviceName Name of the device
openMode Open mode flags bitmap
parent Optional parent object

Definition at line 1032 of file alsatimer.cpp.

References CHECK_ERROR.

Timer ( const QString &  deviceName,
int  openMode,
snd_config_t *  conf,
QObject parent = 0 
)

Constructor.

Open flags can be a combination of the following constants:

  • SND_TIMER_OPEN_NONBLOCK: non-blocking behavior
  • SND_TIMER_OPEN_TREAD: enhanced read, use time-stamps and event notification
Parameters:
deviceName Name of the device
openMode Open mode flags bitmap
conf ALSA configuration object pointer
parent Optional parent object

Definition at line 1055 of file alsatimer.cpp.

References CHECK_ERROR.

Timer ( TimerId id,
int  openMode,
QObject parent = 0 
)

Constructor Open flags can be a combination of the following constants:.

  • SND_TIMER_OPEN_NONBLOCK: non-blocking behavior
  • SND_TIMER_OPEN_TREAD: enhanced read, use time-stamps and event notification
Parameters:
id TimerId object reference
openMode Open mode flags bitmap
parent Optional parent object

Definition at line 1079 of file alsatimer.cpp.

References CHECK_ERROR.

~Timer (  )  [virtual]

Destructor.

Definition at line 1132 of file alsatimer.cpp.

References CHECK_WARNING, and Timer::stopEvents().


Member Function Documentation

void addAsyncTimerHandler ( snd_async_callback_t  callback,
void *  private_data 
)

Adds an asynchronous timer handler function.

Parameters:
callback Function handler
private_data Any data that will be passed to the callback

Definition at line 1146 of file alsatimer.cpp.

References CHECK_WARNING.

Timer * bestGlobalTimer ( int  openMode,
QObject parent = 0 
) [static]

Check and return the best available global Timer in the system, meaning the timer with higher frequency (or lesser period, resolution).

Parameters:
openMode Open mode flags
parent Optional parent object
Returns:
A new Timer instance pointer

Definition at line 1387 of file alsatimer.cpp.

References Timer::bestGlobalTimerId(), and Timer::Timer().

TimerId bestGlobalTimerId (  )  [static]

Check and return the best available global TimerId in the system, meaning the timer with higher frequency (or lesser period, resolution).

Returns:
A TimerId object

Definition at line 1324 of file alsatimer.cpp.

Referenced by Timer::bestGlobalTimer().

void continueRunning (  ) 

Continue rolling the timer.

Definition at line 1248 of file alsatimer.cpp.

References CHECK_WARNING.

void doEvents (  )  [protected]

Internal function to deliver the timer events using one of the two available methods:.

Definition at line 1274 of file alsatimer.cpp.

References TimerEventHandler::handleTimerEvent(), Timer::read(), and Timer::timerExpired().

snd_timer_t* getHandle (  )  [inline]

Gets the ALSA timer object.

Returns:
ALSA timer object pointer.

Definition at line 309 of file alsatimer.h.

int getPollDescriptorsCount (  ) 

Gets the count of poll descriptors.

Returns:
Count of poll descriptors

Definition at line 1166 of file alsatimer.cpp.

snd_timer_t * getTimerHandle (  ) 

Gets the ALSA timer handle.

Returns:
ALSA timer handle

Definition at line 1156 of file alsatimer.cpp.

TimerInfo & getTimerInfo (  ) 

Gets the timer info object.

Returns:
TimerInfo object reference
Examples:
sysinfo.cpp.

Definition at line 1199 of file alsatimer.cpp.

TimerStatus & getTimerStatus (  ) 

Gets the timer status.

Returns:
TimerStatus object reference

Definition at line 1220 of file alsatimer.cpp.

References CHECK_WARNING.

Referenced by Timer::startEvents().

void pollDescriptors ( struct pollfd *  pfds,
unsigned int  space 
)

Gets poll descriptors.

Parameters:
pfds Pointer to a pollfd array
space Number of pollfd elements available

Definition at line 1177 of file alsatimer.cpp.

References CHECK_WARNING.

void pollDescriptorsRevents ( struct pollfd *  pfds,
unsigned int  nfds,
unsigned short *  revents 
)

Gets returned events from poll descriptors.

Parameters:
pfds Pointer to a pollfd array
nfds Number of pollfd elements available
revents Returned events

Definition at line 1189 of file alsatimer.cpp.

References CHECK_WARNING.

ssize_t read ( void *  buffer,
size_t  size 
)

Read bytes from the timer handle.

Parameters:
buffer Buffer to store the input bytes
size Input buffer size in bytes
Returns:
Bytes read from the timer

Definition at line 1260 of file alsatimer.cpp.

Referenced by Timer::doEvents().

void setHandler ( TimerEventHandler h  )  [inline]

Sets an event handler providing a method to be called when a timer expires.

Parameters:
h A TimerEventHandler instance.

Definition at line 328 of file alsatimer.h.

void setTimerParams ( const TimerParams params  ) 

Sets the timer parameters.

Parameters:
params TimerParams object reference

Definition at line 1210 of file alsatimer.cpp.

References CHECK_WARNING.

void start (  ) 

Start rolling the timer.

Definition at line 1230 of file alsatimer.cpp.

References CHECK_WARNING.

void startEvents (  ) 

Starts the events dispatching thread.

Definition at line 1291 of file alsatimer.cpp.

References Timer::getTimerStatus(), and TimerStatus::getTimestamp().

void stop (  ) 

Stop rolling the timer.

Definition at line 1239 of file alsatimer.cpp.

References CHECK_WARNING.

void stopEvents (  ) 

Stops the events dispatching thread.

Definition at line 1303 of file alsatimer.cpp.

Referenced by Timer::~Timer().

void timerExpired ( int  ticks,
int  msecs 
) [signal]

This signal is emitted when the timer has expired, if there is not an event hander installed.

Parameters:
ticks The time in ticks.
msecs The time in milliseconds.

Referenced by Timer::doEvents().


The documentation for this class was generated from the following files:

Generated on Wed Sep 8 10:12:52 2010 for drumstick by  doxygen 1.5.9