20#ifndef DRUMSTICK_ALSATIMER_H
21#define DRUMSTICK_ALSATIMER_H
26#include <QReadWriteLock>
68 long getTicks() __attribute__((deprecated));
71 snd_timer_info_t *m_Info;
81 friend class TimerQuery;
82 friend class TimerGlobalInfo;
83 friend class QueueTimer;
88 TimerId(
const snd_timer_id_t *other);
89 TimerId(
int cls,
int scls,
int card,
int dev,
int sdev);
107 snd_timer_id_t *m_Info;
122 friend class TimerQuery;
145 snd_timer_ginfo_t* m_Info;
157 TimerQuery(
const QString& deviceName,
int openMode);
158 TimerQuery(
const QString& deviceName,
int openMode, snd_config_t* conf);
166 void setGlobalParams(snd_timer_gparams_t* params);
167 void getGlobalParams(snd_timer_gparams_t* params);
168 void getGlobalStatus(snd_timer_gstatus_t* status);
175 snd_timer_query_t *m_Info;
212 snd_timer_params_t* m_Info;
240 snd_timer_status_t* m_Info;
275 class TimerInputThread :
public QThread
279 TimerInputThread(
Timer* t,
int timeout)
285 virtual ~TimerInputThread() {}
293 QReadWriteLock m_mutex;
297 Timer(
int cls,
int scls,
int card,
int dev,
int sdev,
int openMode,
QObject* parent = 0);
298 Timer(
const QString& deviceName,
int openMode,
QObject* parent = 0);
299 Timer(
const QString& deviceName,
int openMode, snd_config_t* config,
QObject* parent = 0);
316 void continueRunning();
318 void addAsyncTimerHandler(snd_async_callback_t callback,
void *private_data);
319 int getPollDescriptorsCount();
320 void pollDescriptors(
struct pollfd *pfds,
unsigned int space);
321 void pollDescriptorsRevents(
struct pollfd *pfds,
unsigned int nfds,
unsigned short *revents);
322 ssize_t read(
void *buffer,
size_t size);
323 snd_timer_t* getTimerHandle();
347 snd_async_handler_t *m_asyncHandler;
349 QPointer<TimerInputThread> m_thread;
352 QString m_deviceName;
353 snd_htimestamp_t m_last_time;
QList< TimerId > TimerIdList
List of timer identifiers.
The QObject class is the base class of all Qt objects.
The QThread class provides platform-independent threads.
ALSA Timer events handler.
virtual void handleTimerEvent(int ticks, int msecs)=0
Timer event handler.
virtual ~TimerEventHandler()
Destructor.
Global timer information container.
unsigned int getFlags()
Gets the flags.
TimerGlobalInfo()
Default constructor.
unsigned int getClients()
Gets current timer clients.
int getSizeOfInfo() const
Gets the size of the ALSA timer global info object.
TimerGlobalInfo & operator=(const TimerGlobalInfo &other)
Assignment operator.
QString getId()
Gets the timer ID string.
unsigned long getMinResolution()
Gets timer minimal resolution in ns.
void setTimerId(const TimerId &tid)
Sets the timer identifier.
TimerGlobalInfo * clone()
Copy the current object.
TimerId & getTimerId()
Gets the timer identifier.
unsigned long getMaxResolution()
Gets timer maximal resolution in ns.
QString getName()
Gets the timer name.
int getCard()
Gets the card number.
unsigned long getResolution()
Gets the timer resolution in ns.
ALSA Timer identifier container.
int getDevice()
Gets the device number.
int getSlaveClass()
Gets the slave class.
int getSizeOfInfo() const
Gets the size of the ALSA timer ID object.
void setSubdevice(int subdevice)
Sets the subdevice number.
TimerId * clone()
Copy the object.
void setCard(int card)
Sets the card number.
int getClass()
Gets the class identifier.
TimerId & operator=(const TimerId &other)
Assignment operator.
int getSubdevice()
Gets the subdevice number.
void setClass(int devclass)
Set the class identifier.
void setSlaveClass(int devsclass)
Sets the Slave class.
int getCard()
Gets the card number.
void setDevice(int device)
Sets the device number.
ALSA Timer information container.
long getTicks() __attribute__((deprecated))
Gets the maximum timer ticks.
int getSizeOfInfo() const
Gets the size of the ALSA timer info object.
bool isSlave()
Check if the timer is slave (depends on another device)
QString getId()
Gets the string identifier.
long getResolution()
Gets the timer resolution (timer period in nanoseconds)
QString getName()
Gets the timer name.
TimerInfo & operator=(const TimerInfo &other)
Assignment operator.
int getCard()
Gets the card number.
long getFrequency()
Gets the timer frequency in Hz.
TimerInfo * clone()
Copy the current object.
ALSA Timer parameters container.
void setFilter(unsigned int filter)
Sets the event filter.
void setEarlyEvent(bool early_event)
Sets the timer early event.
int getSizeOfInfo() const
Gets the size of the ALSA timer parameters object.
TimerParams & operator=(const TimerParams &other)
Assignment operator.
void setAutoStart(bool auto_start)
Sets the automatic start flag.
bool getExclusive()
Gets the timer's exclusive flag.
long getQueueSize()
Gets the queue size.
TimerParams()
Default constructor.
bool getEarlyEvent()
Gets the timer early event.
void setExclusive(bool exclusive)
Sets the exclusive flag.
bool getAutoStart()
Gets the automatic start flag.
void setTicks(long ticks)
Sets the timer ticks.
long getTicks()
Gets the timer ticks.
TimerParams * clone()
Copy the current object.
unsigned int getFilter()
Gets the event filter.
void setQueueSize(long queue_size)
Sets the queue size (32-1024)
ALSA Timer inquiry helper.
TimerIdList getTimers() const
Gets the list of available timers.
TimerQuery(const QString &deviceName, int openMode)
Constructor.
ALSA Timer status container.
long getLost()
Gets the master tick lost count.
TimerStatus()
Default constructor.
int getSizeOfInfo() const
Gets the size of the ALSA timer status object.
long getOverrun()
Gets the overrun count.
long getResolution()
Gets the resolution in us.
TimerStatus & operator=(const TimerStatus &other)
Assignment operator.
TimerStatus * clone()
Copy the current object.
snd_htimestamp_t getTimestamp()
Gets the high resolution time-stamp.
long getQueue()
Gets the count of used queue elements.
static TimerId bestGlobalTimerId()
Check and return the best available global TimerId in the system, meaning the timer with higher frequ...
static Timer * bestGlobalTimer(int openMode, QObject *parent=0)
Check and return the best available global Timer in the system, meaning the timer with higher frequen...
void timerExpired(int ticks, int msecs)
This signal is emitted when the timer has expired, if there is not an event hander installed.
void setHandler(TimerEventHandler *h)
Sets an event handler providing a method to be called when a timer expires.
void stop()
Stop rolling the timer.
Timer(int cls, int scls, int card, int dev, int sdev, int openMode, QObject *parent=0)
Constructor.
snd_timer_t * getHandle()
Gets the ALSA timer object.