19 #ifndef DRUMSTICK_ALSATIMER_H 20 #define DRUMSTICK_ALSATIMER_H 23 #include <alsa/asoundlib.h> 29 #include <QReadWriteLock> 40 #if defined(DRUMSTICK_STATIC) 41 #define DRUMSTICK_ALSA_EXPORT 43 #if defined(drumstick_alsa_EXPORTS) 44 #define DRUMSTICK_ALSA_EXPORT Q_DECL_EXPORT 46 #define DRUMSTICK_ALSA_EXPORT Q_DECL_IMPORT 52 class TimerGlobalInfo;
70 explicit TimerInfo(
const snd_timer_info_t* other);
74 int getSizeOfInfo()
const;
84 Q_DECL_DEPRECATED
long getTicks();
87 snd_timer_info_t *m_Info;
104 explicit TimerId(
const snd_timer_id_t *other);
105 TimerId(
int cls,
int scls,
int card,
int dev,
int sdev);
109 int getSizeOfInfo()
const;
111 void setClass(
int devclass);
113 void setSlaveClass(
int devsclass);
115 void setCard(
int card);
117 void setDevice(
int device);
119 void setSubdevice(
int subdevice);
123 snd_timer_id_t *m_Info;
147 int getSizeOfInfo()
const;
149 void setTimerId(
const TimerId& tid);
151 unsigned int getFlags();
155 unsigned long getResolution();
156 unsigned long getMinResolution();
157 unsigned long getMaxResolution();
158 unsigned int getClients();
161 snd_timer_ginfo_t* m_Info;
173 TimerQuery(
const QString& deviceName,
int openMode);
174 TimerQuery(
const QString& deviceName,
int openMode, snd_config_t* conf);
182 void setGlobalParams(snd_timer_gparams_t* params);
183 void getGlobalParams(snd_timer_gparams_t* params);
184 void getGlobalStatus(snd_timer_gstatus_t* status);
191 snd_timer_query_t *m_Info;
208 explicit TimerParams(
const snd_timer_params_t* other);
212 int getSizeOfInfo()
const;
214 void setAutoStart(
bool auto_start);
216 void setExclusive(
bool exclusive);
218 void setEarlyEvent(
bool early_event);
219 bool getEarlyEvent();
220 void setTicks(
long ticks);
222 void setQueueSize(
long queue_size);
224 void setFilter(
unsigned int filter);
225 unsigned int getFilter();
228 snd_timer_params_t* m_Info;
243 explicit TimerStatus(
const snd_timer_status_t* other);
247 int getSizeOfInfo()
const;
249 snd_htimestamp_t getTimestamp();
250 long getResolution();
256 snd_timer_status_t* m_Info;
275 virtual void handleTimerEvent(
int ticks,
int msecs) = 0;
291 class TimerInputThread :
public QThread 295 TimerInputThread(
Timer* t,
int timeout)
301 virtual ~TimerInputThread() =
default;
309 QReadWriteLock m_mutex;
313 Timer(
int cls,
int scls,
int card,
int dev,
int sdev,
int openMode,
QObject* parent =
nullptr);
314 Timer(
const QString& deviceName,
int openMode,
QObject* parent =
nullptr);
315 Timer(
const QString& deviceName,
int openMode, snd_config_t* config,
QObject* parent =
nullptr);
319 static TimerId bestGlobalTimerId();
320 static Timer* bestGlobalTimer(
int openMode,
QObject* parent =
nullptr);
332 void continueRunning();
334 void addAsyncTimerHandler(snd_async_callback_t callback,
void *private_data);
335 int getPollDescriptorsCount();
336 void pollDescriptors(
struct pollfd *pfds,
unsigned int space);
337 void pollDescriptorsRevents(
struct pollfd *pfds,
unsigned int nfds,
unsigned short *revents);
338 ssize_t read(
void *buffer,
size_t size);
339 snd_timer_t* getTimerHandle();
359 void timerExpired(
int ticks,
int msecs);
363 snd_async_handler_t *m_asyncHandler;
365 QPointer<TimerInputThread> m_thread;
368 QString m_deviceName;
369 snd_htimestamp_t m_last_time;
ALSA Timer parameters container.
QList< TimerId > TimerIdList
List of timer identifiers.
The QObject class is the base class of all Qt objects.
snd_timer_t * getHandle()
Gets the ALSA timer object.
TimerIdList getTimers() const
Gets the list of available timers.
ALSA Timer inquiry helper.
Global timer information container.
ALSA Timer identifier container.
ALSA Timer information container.
ALSA Timer events handler.
ALSA Timer status container.
The QThread class provides platform-independent threads.
void setHandler(TimerEventHandler *h)
Sets an event handler providing a method to be called when a timer expires.