19#ifndef DRUMSTICK_ALSATIMER_H
20#define DRUMSTICK_ALSATIMER_H
23 #include <alsa/asoundlib.h>
29#include <QReadWriteLock>
60 explicit TimerInfo(
const snd_timer_info_t* other);
64 int getSizeOfInfo()
const;
74 Q_DECL_DEPRECATED
long getTicks();
77 snd_timer_info_t *m_Info;
94 explicit TimerId(
const snd_timer_id_t *other);
95 TimerId(
int cls,
int scls,
int card,
int dev,
int sdev);
99 int getSizeOfInfo()
const;
101 void setClass(
int devclass);
103 void setSlaveClass(
int devsclass);
105 void setCard(
int card);
107 void setDevice(
int device);
109 void setSubdevice(
int subdevice);
113 snd_timer_id_t *m_Info;
137 int getSizeOfInfo()
const;
139 void setTimerId(
const TimerId& tid);
141 unsigned int getFlags();
145 unsigned long getResolution();
146 unsigned long getMinResolution();
147 unsigned long getMaxResolution();
148 unsigned int getClients();
151 snd_timer_ginfo_t* m_Info;
163 TimerQuery(
const QString& deviceName,
int openMode);
164 TimerQuery(
const QString& deviceName,
int openMode, snd_config_t* conf);
172 void setGlobalParams(snd_timer_gparams_t* params);
173 void getGlobalParams(snd_timer_gparams_t* params);
174 void getGlobalStatus(snd_timer_gstatus_t* status);
181 snd_timer_query_t *m_Info;
198 explicit TimerParams(
const snd_timer_params_t* other);
202 int getSizeOfInfo()
const;
204 void setAutoStart(
bool auto_start);
206 void setExclusive(
bool exclusive);
208 void setEarlyEvent(
bool early_event);
209 bool getEarlyEvent();
210 void setTicks(
long ticks);
212 void setQueueSize(
long queue_size);
214 void setFilter(
unsigned int filter);
215 unsigned int getFilter();
218 snd_timer_params_t* m_Info;
233 explicit TimerStatus(
const snd_timer_status_t* other);
237 int getSizeOfInfo()
const;
239 snd_htimestamp_t getTimestamp();
240 long getResolution();
246 snd_timer_status_t* m_Info;
281 class TimerInputThread :
public QThread
285 TimerInputThread(
Timer* t,
int timeout)
291 virtual ~TimerInputThread() =
default;
299 QReadWriteLock m_mutex;
303 Timer(
int cls,
int scls,
int card,
int dev,
int sdev,
int openMode,
QObject* parent =
nullptr);
304 Timer(
const QString& deviceName,
int openMode,
QObject* parent =
nullptr);
305 Timer(
const QString& deviceName,
int openMode, snd_config_t* config,
QObject* parent =
nullptr);
309 static TimerId bestGlobalTimerId();
310 static Timer* bestGlobalTimer(
int openMode,
QObject* parent =
nullptr);
322 void continueRunning();
324 void addAsyncTimerHandler(snd_async_callback_t callback,
void *private_data);
325 int getPollDescriptorsCount();
326 void pollDescriptors(
struct pollfd *pfds,
unsigned int space);
327 void pollDescriptorsRevents(
struct pollfd *pfds,
unsigned int nfds,
unsigned short *revents);
328 ssize_t read(
void *buffer,
size_t size);
329 snd_timer_t* getTimerHandle();
353 snd_async_handler_t *m_asyncHandler;
355 QPointer<TimerInputThread> m_thread;
358 QString m_deviceName;
359 snd_htimestamp_t m_last_time;
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()=default
Destructor.
Global timer information container.
ALSA Timer identifier container.
ALSA Timer information container.
ALSA Timer parameters container.
ALSA Timer inquiry helper.
TimerIdList getTimers() const
Gets the list of available timers.
ALSA Timer status container.
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.
snd_timer_t * getHandle()
Gets the ALSA timer object.
QList< TimerId > TimerIdList
List of timer identifiers.
Drumstick visibility macros.