drumstick 2.9.0
C++ MIDI libraries using Qt objects, idioms, and style.

ALSA Timer management. More...

#include <alsatimer.h>

Inheritance diagram for Timer:

Signals

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

Public Member Functions

 Timer (int cls, int scls, int card, int dev, int sdev, int openMode, QObject *parent=nullptr)
 Constructor. More...
 
 Timer (const QString &deviceName, int openMode, QObject *parent=nullptr)
 Constructor. More...
 
 Timer (const QString &deviceName, int openMode, snd_config_t *config, QObject *parent=nullptr)
 Constructor. More...
 
 Timer (TimerId &id, int openMode, QObject *parent=nullptr)
 Constructor Open flags can be a combination of the following constants: More...
 
virtual ~Timer ()
 Destructor.
 
snd_timer_t * getHandle ()
 Gets the ALSA timer object. More...
 
TimerInfogetTimerInfo ()
 Gets the timer info object. More...
 
TimerStatusgetTimerStatus ()
 Gets the timer status. More...
 
void setTimerParams (const TimerParams &params)
 Sets the timer parameters. More...
 
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. More...
 
int getPollDescriptorsCount ()
 Gets the count of poll descriptors. More...
 
void pollDescriptors (struct pollfd *pfds, unsigned int space)
 Gets poll descriptors. More...
 
void pollDescriptorsRevents (struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
 Gets returned events from poll descriptors. More...
 
ssize_t read (void *buffer, size_t size)
 Read bytes from the timer handle. More...
 
snd_timer_t * getTimerHandle ()
 Gets the ALSA timer handle. More...
 
void setHandler (TimerEventHandler *h)
 Sets an event handler providing a method to be called when a timer expires. More...
 
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). More...
 
static TimerbestGlobalTimer (int openMode, QObject *parent=nullptr)
 Check and return the best available global Timer in the system, meaning the timer with higher frequency (or lesser period, resolution). More...
 

Protected Member Functions

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

Detailed Description

ALSA Timer management.

This class represents an ALSA timer object.

Examples
sysinfo.cpp.

Definition at line 283 of file alsatimer.h.

Constructor & Destructor Documentation

◆ Timer() [1/4]

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

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
clsClass
sclsSubclass
cardCard
devDevice
sdevSubdevice
openModeOpen mode flags bitmap
parentOptional parent object

Definition at line 1121 of file alsatimer.cpp.

References DRUMSTICK_ALSA_CHECK_ERROR.

◆ Timer() [2/4]

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

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
deviceNameName of the device
openModeOpen mode flags bitmap
parentOptional parent object

Definition at line 1042 of file alsatimer.cpp.

References DRUMSTICK_ALSA_CHECK_ERROR.

◆ Timer() [3/4]

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

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
deviceNameName of the device
openModeOpen mode flags bitmap
confALSA configuration object pointer
parentOptional parent object

Definition at line 1065 of file alsatimer.cpp.

References DRUMSTICK_ALSA_CHECK_ERROR.

◆ Timer() [4/4]

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

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
idTimerId object reference
openModeOpen mode flags bitmap
parentOptional parent object

Definition at line 1089 of file alsatimer.cpp.

References DRUMSTICK_ALSA_CHECK_ERROR.

Member Function Documentation

◆ addAsyncTimerHandler()

void addAsyncTimerHandler ( snd_async_callback_t  callback,
void *  private_data 
)

Adds an asynchronous timer handler function.

Parameters
callbackFunction handler
private_dataAny data that will be passed to the callback

Definition at line 1156 of file alsatimer.cpp.

References DRUMSTICK_ALSA_CHECK_WARNING.

◆ bestGlobalTimer()

Timer * bestGlobalTimer ( int  openMode,
QObject parent = nullptr 
)
static

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

Parameters
openModeOpen mode flags
parentOptional parent object
Returns
A new Timer instance pointer

Definition at line 1398 of file alsatimer.cpp.

References Timer::bestGlobalTimerId().

◆ bestGlobalTimerId()

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
Since
0.3.0

Definition at line 1335 of file alsatimer.cpp.

Referenced by Timer::bestGlobalTimer().

◆ doEvents()

void doEvents ( )
protected

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

Definition at line 1284 of file alsatimer.cpp.

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

◆ getHandle()

snd_timer_t * getHandle ( )
inline

Gets the ALSA timer object.

Returns
ALSA timer object pointer.

Definition at line 325 of file alsatimer.h.

◆ getPollDescriptorsCount()

int getPollDescriptorsCount ( )

Gets the count of poll descriptors.

Returns
Count of poll descriptors

Definition at line 1176 of file alsatimer.cpp.

◆ getTimerHandle()

snd_timer_t * getTimerHandle ( )

Gets the ALSA timer handle.

Returns
ALSA timer handle

Definition at line 1166 of file alsatimer.cpp.

◆ getTimerInfo()

TimerInfo & getTimerInfo ( )

Gets the timer info object.

Returns
TimerInfo object reference
Examples
sysinfo.cpp.

Definition at line 1209 of file alsatimer.cpp.

◆ getTimerStatus()

TimerStatus & getTimerStatus ( )

Gets the timer status.

Returns
TimerStatus object reference

Definition at line 1230 of file alsatimer.cpp.

References DRUMSTICK_ALSA_CHECK_WARNING.

Referenced by Timer::startEvents().

◆ pollDescriptors()

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

Gets poll descriptors.

Parameters
pfdsPointer to a pollfd array
spaceNumber of pollfd elements available

Definition at line 1187 of file alsatimer.cpp.

References DRUMSTICK_ALSA_CHECK_WARNING.

◆ pollDescriptorsRevents()

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

Gets returned events from poll descriptors.

Parameters
pfdsPointer to a pollfd array
nfdsNumber of pollfd elements available
reventsReturned events

Definition at line 1199 of file alsatimer.cpp.

References DRUMSTICK_ALSA_CHECK_WARNING.

◆ read()

ssize_t read ( void *  buffer,
size_t  size 
)

Read bytes from the timer handle.

Parameters
bufferBuffer to store the input bytes
sizeInput buffer size in bytes
Returns
Bytes read from the timer

Definition at line 1270 of file alsatimer.cpp.

Referenced by Timer::doEvents().

◆ setHandler()

void setHandler ( TimerEventHandler h)
inline

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

Parameters
hA TimerEventHandler instance.

Definition at line 344 of file alsatimer.h.

◆ setTimerParams()

void setTimerParams ( const TimerParams params)

Sets the timer parameters.

Parameters
paramsTimerParams object reference

Definition at line 1220 of file alsatimer.cpp.

References DRUMSTICK_ALSA_CHECK_WARNING.

◆ timerExpired

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
ticksThe time in ticks.
msecsThe time in milliseconds.

Referenced by Timer::doEvents().


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