ALSA project - the C library reference
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
timer.h
Go to the documentation of this file.
1 
11 /*
12  * This library is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License as
14  * published by the Free Software Foundation; either version 2.1 of
15  * the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  */
27 
28 #ifndef __ALSA_TIMER_H
29 #define __ALSA_TIMER_H
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
42 #define SND_TIMER_DLSYM_VERSION _dlsym_timer_001
43 
44 #define SND_TIMER_QUERY_DLSYM_VERSION _dlsym_timer_query_001
45 
47 typedef struct _snd_timer_id snd_timer_id_t;
49 typedef struct _snd_timer_ginfo snd_timer_ginfo_t;
51 typedef struct _snd_timer_gparams snd_timer_gparams_t;
53 typedef struct _snd_timer_gstatus snd_timer_gstatus_t;
55 typedef struct _snd_timer_info snd_timer_info_t;
57 typedef struct _snd_timer_params snd_timer_params_t;
59 typedef struct _snd_timer_status snd_timer_status_t;
61 typedef enum _snd_timer_class {
69 
71 typedef enum _snd_timer_slave_class {
78 
80 typedef enum _snd_timer_event {
81  SND_TIMER_EVENT_RESOLUTION = 0, /* val = resolution in ns */
82  SND_TIMER_EVENT_TICK, /* val = ticks */
83  SND_TIMER_EVENT_START, /* val = resolution in ns */
84  SND_TIMER_EVENT_STOP, /* val = 0 */
85  SND_TIMER_EVENT_CONTINUE, /* val = resolution in ns */
86  SND_TIMER_EVENT_PAUSE, /* val = 0 */
87  SND_TIMER_EVENT_EARLY, /* val = 0 */
88  SND_TIMER_EVENT_SUSPEND, /* val = 0 */
89  SND_TIMER_EVENT_RESUME, /* val = resolution in ns */
90  /* master timer events for slave timer instances */
91  SND_TIMER_EVENT_MSTART = SND_TIMER_EVENT_START + 10,
92  SND_TIMER_EVENT_MSTOP = SND_TIMER_EVENT_STOP + 10,
93  SND_TIMER_EVENT_MCONTINUE = SND_TIMER_EVENT_CONTINUE + 10,
94  SND_TIMER_EVENT_MPAUSE = SND_TIMER_EVENT_PAUSE + 10,
95  SND_TIMER_EVENT_MSUSPEND = SND_TIMER_EVENT_SUSPEND + 10,
96  SND_TIMER_EVENT_MRESUME = SND_TIMER_EVENT_RESUME + 10
98 
100 typedef struct _snd_timer_read {
101  unsigned int resolution;
102  unsigned int ticks;
104 
106 typedef struct _snd_timer_tread {
109  unsigned int val;
111 
113 #define SND_TIMER_GLOBAL_SYSTEM 0
114 
115 #define SND_TIMER_GLOBAL_RTC 1
116 
117 #define SND_TIMER_GLOBAL_HPET 2
118 
119 #define SND_TIMER_GLOBAL_HRTIMER 3
120 
122 #define SND_TIMER_OPEN_NONBLOCK (1<<0)
123 
124 #define SND_TIMER_OPEN_TREAD (1<<1)
125 
127 typedef enum _snd_timer_type {
135 
137 typedef struct _snd_timer_query snd_timer_query_t;
139 typedef struct _snd_timer snd_timer_t;
140 
141 
142 int snd_timer_query_open(snd_timer_query_t **handle, const char *name, int mode);
143 int snd_timer_query_open_lconf(snd_timer_query_t **handle, const char *name, int mode, snd_config_t *lconf);
149 
150 int snd_timer_open(snd_timer_t **handle, const char *name, int mode);
151 int snd_timer_open_lconf(snd_timer_t **handle, const char *name, int mode, snd_config_t *lconf);
152 int snd_timer_close(snd_timer_t *handle);
154  snd_async_callback_t callback, void *private_data);
157 int snd_timer_poll_descriptors(snd_timer_t *handle, struct pollfd *pfds, unsigned int space);
158 int snd_timer_poll_descriptors_revents(snd_timer_t *timer, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
159 int snd_timer_info(snd_timer_t *handle, snd_timer_info_t *timer);
160 int snd_timer_params(snd_timer_t *handle, snd_timer_params_t *params);
161 int snd_timer_status(snd_timer_t *handle, snd_timer_status_t *status);
162 int snd_timer_start(snd_timer_t *handle);
163 int snd_timer_stop(snd_timer_t *handle);
164 int snd_timer_continue(snd_timer_t *handle);
165 ssize_t snd_timer_read(snd_timer_t *handle, void *buffer, size_t size);
166 
167 size_t snd_timer_id_sizeof(void);
169 #define snd_timer_id_alloca(ptr) __snd_alloca(ptr, snd_timer_id)
172 void snd_timer_id_copy(snd_timer_id_t *dst, const snd_timer_id_t *src);
173 
174 void snd_timer_id_set_class(snd_timer_id_t *id, int dev_class);
176 void snd_timer_id_set_sclass(snd_timer_id_t *id, int dev_sclass);
178 void snd_timer_id_set_card(snd_timer_id_t *id, int card);
180 void snd_timer_id_set_device(snd_timer_id_t *id, int device);
182 void snd_timer_id_set_subdevice(snd_timer_id_t *id, int subdevice);
184 
185 size_t snd_timer_ginfo_sizeof(void);
187 #define snd_timer_ginfo_alloca(ptr) __snd_alloca(ptr, snd_timer_ginfo)
191 
202 
203 size_t snd_timer_info_sizeof(void);
205 #define snd_timer_info_alloca(ptr) __snd_alloca(ptr, snd_timer_info)
209 
212 const char *snd_timer_info_get_id(snd_timer_info_t * info);
213 const char *snd_timer_info_get_name(snd_timer_info_t * info);
215 
216 size_t snd_timer_params_sizeof(void);
218 #define snd_timer_params_alloca(ptr) __snd_alloca(ptr, snd_timer_params)
222 
223 int snd_timer_params_set_auto_start(snd_timer_params_t * params, int auto_start);
225 int snd_timer_params_set_exclusive(snd_timer_params_t * params, int exclusive);
227 int snd_timer_params_set_early_event(snd_timer_params_t * params, int early_event);
229 void snd_timer_params_set_ticks(snd_timer_params_t * params, long ticks);
231 void snd_timer_params_set_queue_size(snd_timer_params_t * params, long queue_size);
233 void snd_timer_params_set_filter(snd_timer_params_t * params, unsigned int filter);
234 unsigned int snd_timer_params_get_filter(snd_timer_params_t * params);
235 
236 size_t snd_timer_status_sizeof(void);
238 #define snd_timer_status_alloca(ptr) __snd_alloca(ptr, snd_timer_status)
242 
248 
249 /* deprecated functions, for compatibility */
251 
254 #ifdef __cplusplus
255 }
256 #endif
257 
258 #endif