annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/alsa/timer.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /**
jpayne@69 2 * \file include/timer.h
jpayne@69 3 * \brief Application interface library for the ALSA driver
jpayne@69 4 * \author Jaroslav Kysela <perex@perex.cz>
jpayne@69 5 * \author Abramo Bagnara <abramo@alsa-project.org>
jpayne@69 6 * \author Takashi Iwai <tiwai@suse.de>
jpayne@69 7 * \date 1998-2001
jpayne@69 8 *
jpayne@69 9 * Application interface library for the ALSA driver
jpayne@69 10 */
jpayne@69 11 /*
jpayne@69 12 * This library is free software; you can redistribute it and/or modify
jpayne@69 13 * it under the terms of the GNU Lesser General Public License as
jpayne@69 14 * published by the Free Software Foundation; either version 2.1 of
jpayne@69 15 * the License, or (at your option) any later version.
jpayne@69 16 *
jpayne@69 17 * This program is distributed in the hope that it will be useful,
jpayne@69 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jpayne@69 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
jpayne@69 20 * GNU Lesser General Public License for more details.
jpayne@69 21 *
jpayne@69 22 * You should have received a copy of the GNU Lesser General Public
jpayne@69 23 * License along with this library; if not, write to the Free Software
jpayne@69 24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
jpayne@69 25 *
jpayne@69 26 */
jpayne@69 27
jpayne@69 28 #ifndef __ALSA_TIMER_H
jpayne@69 29 #define __ALSA_TIMER_H
jpayne@69 30
jpayne@69 31 #ifdef __cplusplus
jpayne@69 32 extern "C" {
jpayne@69 33 #endif
jpayne@69 34
jpayne@69 35 /**
jpayne@69 36 * \defgroup Timer Timer Interface
jpayne@69 37 * Timer Interface. See \ref timer page for more details.
jpayne@69 38 * \{
jpayne@69 39 */
jpayne@69 40
jpayne@69 41 /** dlsym version for interface entry callback */
jpayne@69 42 #define SND_TIMER_DLSYM_VERSION _dlsym_timer_001
jpayne@69 43 /** dlsym version for interface entry callback */
jpayne@69 44 #define SND_TIMER_QUERY_DLSYM_VERSION _dlsym_timer_query_001
jpayne@69 45
jpayne@69 46 /** timer identification structure */
jpayne@69 47 typedef struct _snd_timer_id snd_timer_id_t;
jpayne@69 48 /** timer global info structure */
jpayne@69 49 typedef struct _snd_timer_ginfo snd_timer_ginfo_t;
jpayne@69 50 /** timer global params structure */
jpayne@69 51 typedef struct _snd_timer_gparams snd_timer_gparams_t;
jpayne@69 52 /** timer global status structure */
jpayne@69 53 typedef struct _snd_timer_gstatus snd_timer_gstatus_t;
jpayne@69 54 /** timer info structure */
jpayne@69 55 typedef struct _snd_timer_info snd_timer_info_t;
jpayne@69 56 /** timer params structure */
jpayne@69 57 typedef struct _snd_timer_params snd_timer_params_t;
jpayne@69 58 /** timer status structure */
jpayne@69 59 typedef struct _snd_timer_status snd_timer_status_t;
jpayne@69 60 /** timer master class */
jpayne@69 61 typedef enum _snd_timer_class {
jpayne@69 62 SND_TIMER_CLASS_NONE = -1, /**< invalid */
jpayne@69 63 SND_TIMER_CLASS_SLAVE = 0, /**< slave timer */
jpayne@69 64 SND_TIMER_CLASS_GLOBAL, /**< global timer */
jpayne@69 65 SND_TIMER_CLASS_CARD, /**< card timer */
jpayne@69 66 SND_TIMER_CLASS_PCM, /**< PCM timer */
jpayne@69 67 SND_TIMER_CLASS_LAST = SND_TIMER_CLASS_PCM /**< last timer */
jpayne@69 68 } snd_timer_class_t;
jpayne@69 69
jpayne@69 70 /** timer slave class */
jpayne@69 71 typedef enum _snd_timer_slave_class {
jpayne@69 72 SND_TIMER_SCLASS_NONE = 0, /**< none */
jpayne@69 73 SND_TIMER_SCLASS_APPLICATION, /**< for internal use */
jpayne@69 74 SND_TIMER_SCLASS_SEQUENCER, /**< sequencer timer */
jpayne@69 75 SND_TIMER_SCLASS_OSS_SEQUENCER, /**< OSS sequencer timer */
jpayne@69 76 SND_TIMER_SCLASS_LAST = SND_TIMER_SCLASS_OSS_SEQUENCER /**< last slave timer */
jpayne@69 77 } snd_timer_slave_class_t;
jpayne@69 78
jpayne@69 79 /** timer read event identification */
jpayne@69 80 typedef enum _snd_timer_event {
jpayne@69 81 SND_TIMER_EVENT_RESOLUTION = 0, /* val = resolution in ns */
jpayne@69 82 SND_TIMER_EVENT_TICK, /* val = ticks */
jpayne@69 83 SND_TIMER_EVENT_START, /* val = resolution in ns */
jpayne@69 84 SND_TIMER_EVENT_STOP, /* val = 0 */
jpayne@69 85 SND_TIMER_EVENT_CONTINUE, /* val = resolution in ns */
jpayne@69 86 SND_TIMER_EVENT_PAUSE, /* val = 0 */
jpayne@69 87 SND_TIMER_EVENT_EARLY, /* val = 0 */
jpayne@69 88 SND_TIMER_EVENT_SUSPEND, /* val = 0 */
jpayne@69 89 SND_TIMER_EVENT_RESUME, /* val = resolution in ns */
jpayne@69 90 /* master timer events for slave timer instances */
jpayne@69 91 SND_TIMER_EVENT_MSTART = SND_TIMER_EVENT_START + 10,
jpayne@69 92 SND_TIMER_EVENT_MSTOP = SND_TIMER_EVENT_STOP + 10,
jpayne@69 93 SND_TIMER_EVENT_MCONTINUE = SND_TIMER_EVENT_CONTINUE + 10,
jpayne@69 94 SND_TIMER_EVENT_MPAUSE = SND_TIMER_EVENT_PAUSE + 10,
jpayne@69 95 SND_TIMER_EVENT_MSUSPEND = SND_TIMER_EVENT_SUSPEND + 10,
jpayne@69 96 SND_TIMER_EVENT_MRESUME = SND_TIMER_EVENT_RESUME + 10
jpayne@69 97 } snd_timer_event_t;
jpayne@69 98
jpayne@69 99 /** timer read structure */
jpayne@69 100 typedef struct _snd_timer_read {
jpayne@69 101 unsigned int resolution; /**< tick resolution in nanoseconds */
jpayne@69 102 unsigned int ticks; /**< count of happened ticks */
jpayne@69 103 } snd_timer_read_t;
jpayne@69 104
jpayne@69 105 /** timer tstamp + event read structure */
jpayne@69 106 typedef struct _snd_timer_tread {
jpayne@69 107 snd_timer_event_t event; /**< Timer event */
jpayne@69 108 snd_htimestamp_t tstamp; /**< Time stamp of each event */
jpayne@69 109 unsigned int val; /**< Event value */
jpayne@69 110 } snd_timer_tread_t;
jpayne@69 111
jpayne@69 112 /** global timer - system */
jpayne@69 113 #define SND_TIMER_GLOBAL_SYSTEM 0
jpayne@69 114 /** global timer - RTC */
jpayne@69 115 #define SND_TIMER_GLOBAL_RTC 1 /* Obsoleted, due to enough legacy. */
jpayne@69 116 /** global timer - HPET */
jpayne@69 117 #define SND_TIMER_GLOBAL_HPET 2
jpayne@69 118 /** global timer - HRTIMER */
jpayne@69 119 #define SND_TIMER_GLOBAL_HRTIMER 3
jpayne@69 120
jpayne@69 121 /** timer open mode flag - non-blocking behaviour */
jpayne@69 122 #define SND_TIMER_OPEN_NONBLOCK (1<<0)
jpayne@69 123 /** use timestamps and event notification - enhanced read */
jpayne@69 124 #define SND_TIMER_OPEN_TREAD (1<<1)
jpayne@69 125
jpayne@69 126 /** timer handle type */
jpayne@69 127 typedef enum _snd_timer_type {
jpayne@69 128 /** Kernel level HwDep */
jpayne@69 129 SND_TIMER_TYPE_HW = 0,
jpayne@69 130 /** Shared memory client timer (not yet implemented) */
jpayne@69 131 SND_TIMER_TYPE_SHM,
jpayne@69 132 /** INET client timer (not yet implemented) */
jpayne@69 133 SND_TIMER_TYPE_INET
jpayne@69 134 } snd_timer_type_t;
jpayne@69 135
jpayne@69 136 /** timer query handle */
jpayne@69 137 typedef struct _snd_timer_query snd_timer_query_t;
jpayne@69 138 /** timer handle */
jpayne@69 139 typedef struct _snd_timer snd_timer_t;
jpayne@69 140
jpayne@69 141
jpayne@69 142 int snd_timer_query_open(snd_timer_query_t **handle, const char *name, int mode);
jpayne@69 143 int snd_timer_query_open_lconf(snd_timer_query_t **handle, const char *name, int mode, snd_config_t *lconf);
jpayne@69 144 int snd_timer_query_close(snd_timer_query_t *handle);
jpayne@69 145 int snd_timer_query_next_device(snd_timer_query_t *handle, snd_timer_id_t *tid);
jpayne@69 146 int snd_timer_query_info(snd_timer_query_t *handle, snd_timer_ginfo_t *info);
jpayne@69 147 int snd_timer_query_params(snd_timer_query_t *handle, snd_timer_gparams_t *params);
jpayne@69 148 int snd_timer_query_status(snd_timer_query_t *handle, snd_timer_gstatus_t *status);
jpayne@69 149
jpayne@69 150 int snd_timer_open(snd_timer_t **handle, const char *name, int mode);
jpayne@69 151 int snd_timer_open_lconf(snd_timer_t **handle, const char *name, int mode, snd_config_t *lconf);
jpayne@69 152 int snd_timer_close(snd_timer_t *handle);
jpayne@69 153 int snd_async_add_timer_handler(snd_async_handler_t **handler, snd_timer_t *timer,
jpayne@69 154 snd_async_callback_t callback, void *private_data);
jpayne@69 155 snd_timer_t *snd_async_handler_get_timer(snd_async_handler_t *handler);
jpayne@69 156 int snd_timer_poll_descriptors_count(snd_timer_t *handle);
jpayne@69 157 int snd_timer_poll_descriptors(snd_timer_t *handle, struct pollfd *pfds, unsigned int space);
jpayne@69 158 int snd_timer_poll_descriptors_revents(snd_timer_t *timer, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
jpayne@69 159 int snd_timer_info(snd_timer_t *handle, snd_timer_info_t *timer);
jpayne@69 160 int snd_timer_params(snd_timer_t *handle, snd_timer_params_t *params);
jpayne@69 161 int snd_timer_status(snd_timer_t *handle, snd_timer_status_t *status);
jpayne@69 162 int snd_timer_start(snd_timer_t *handle);
jpayne@69 163 int snd_timer_stop(snd_timer_t *handle);
jpayne@69 164 int snd_timer_continue(snd_timer_t *handle);
jpayne@69 165 ssize_t snd_timer_read(snd_timer_t *handle, void *buffer, size_t size);
jpayne@69 166
jpayne@69 167 size_t snd_timer_id_sizeof(void);
jpayne@69 168 /** allocate #snd_timer_id_t container on stack */
jpayne@69 169 #define snd_timer_id_alloca(ptr) __snd_alloca(ptr, snd_timer_id)
jpayne@69 170 int snd_timer_id_malloc(snd_timer_id_t **ptr);
jpayne@69 171 void snd_timer_id_free(snd_timer_id_t *obj);
jpayne@69 172 void snd_timer_id_copy(snd_timer_id_t *dst, const snd_timer_id_t *src);
jpayne@69 173
jpayne@69 174 void snd_timer_id_set_class(snd_timer_id_t *id, int dev_class);
jpayne@69 175 int snd_timer_id_get_class(snd_timer_id_t *id);
jpayne@69 176 void snd_timer_id_set_sclass(snd_timer_id_t *id, int dev_sclass);
jpayne@69 177 int snd_timer_id_get_sclass(snd_timer_id_t *id);
jpayne@69 178 void snd_timer_id_set_card(snd_timer_id_t *id, int card);
jpayne@69 179 int snd_timer_id_get_card(snd_timer_id_t *id);
jpayne@69 180 void snd_timer_id_set_device(snd_timer_id_t *id, int device);
jpayne@69 181 int snd_timer_id_get_device(snd_timer_id_t *id);
jpayne@69 182 void snd_timer_id_set_subdevice(snd_timer_id_t *id, int subdevice);
jpayne@69 183 int snd_timer_id_get_subdevice(snd_timer_id_t *id);
jpayne@69 184
jpayne@69 185 size_t snd_timer_ginfo_sizeof(void);
jpayne@69 186 /** allocate #snd_timer_ginfo_t container on stack */
jpayne@69 187 #define snd_timer_ginfo_alloca(ptr) __snd_alloca(ptr, snd_timer_ginfo)
jpayne@69 188 int snd_timer_ginfo_malloc(snd_timer_ginfo_t **ptr);
jpayne@69 189 void snd_timer_ginfo_free(snd_timer_ginfo_t *obj);
jpayne@69 190 void snd_timer_ginfo_copy(snd_timer_ginfo_t *dst, const snd_timer_ginfo_t *src);
jpayne@69 191
jpayne@69 192 int snd_timer_ginfo_set_tid(snd_timer_ginfo_t *obj, snd_timer_id_t *tid);
jpayne@69 193 snd_timer_id_t *snd_timer_ginfo_get_tid(snd_timer_ginfo_t *obj);
jpayne@69 194 unsigned int snd_timer_ginfo_get_flags(snd_timer_ginfo_t *obj);
jpayne@69 195 int snd_timer_ginfo_get_card(snd_timer_ginfo_t *obj);
jpayne@69 196 char *snd_timer_ginfo_get_id(snd_timer_ginfo_t *obj);
jpayne@69 197 char *snd_timer_ginfo_get_name(snd_timer_ginfo_t *obj);
jpayne@69 198 unsigned long snd_timer_ginfo_get_resolution(snd_timer_ginfo_t *obj);
jpayne@69 199 unsigned long snd_timer_ginfo_get_resolution_min(snd_timer_ginfo_t *obj);
jpayne@69 200 unsigned long snd_timer_ginfo_get_resolution_max(snd_timer_ginfo_t *obj);
jpayne@69 201 unsigned int snd_timer_ginfo_get_clients(snd_timer_ginfo_t *obj);
jpayne@69 202
jpayne@69 203 size_t snd_timer_info_sizeof(void);
jpayne@69 204 /** allocate #snd_timer_info_t container on stack */
jpayne@69 205 #define snd_timer_info_alloca(ptr) __snd_alloca(ptr, snd_timer_info)
jpayne@69 206 int snd_timer_info_malloc(snd_timer_info_t **ptr);
jpayne@69 207 void snd_timer_info_free(snd_timer_info_t *obj);
jpayne@69 208 void snd_timer_info_copy(snd_timer_info_t *dst, const snd_timer_info_t *src);
jpayne@69 209
jpayne@69 210 int snd_timer_info_is_slave(snd_timer_info_t * info);
jpayne@69 211 int snd_timer_info_get_card(snd_timer_info_t * info);
jpayne@69 212 const char *snd_timer_info_get_id(snd_timer_info_t * info);
jpayne@69 213 const char *snd_timer_info_get_name(snd_timer_info_t * info);
jpayne@69 214 long snd_timer_info_get_resolution(snd_timer_info_t * info);
jpayne@69 215
jpayne@69 216 size_t snd_timer_params_sizeof(void);
jpayne@69 217 /** allocate #snd_timer_params_t container on stack */
jpayne@69 218 #define snd_timer_params_alloca(ptr) __snd_alloca(ptr, snd_timer_params)
jpayne@69 219 int snd_timer_params_malloc(snd_timer_params_t **ptr);
jpayne@69 220 void snd_timer_params_free(snd_timer_params_t *obj);
jpayne@69 221 void snd_timer_params_copy(snd_timer_params_t *dst, const snd_timer_params_t *src);
jpayne@69 222
jpayne@69 223 int snd_timer_params_set_auto_start(snd_timer_params_t * params, int auto_start);
jpayne@69 224 int snd_timer_params_get_auto_start(snd_timer_params_t * params);
jpayne@69 225 int snd_timer_params_set_exclusive(snd_timer_params_t * params, int exclusive);
jpayne@69 226 int snd_timer_params_get_exclusive(snd_timer_params_t * params);
jpayne@69 227 int snd_timer_params_set_early_event(snd_timer_params_t * params, int early_event);
jpayne@69 228 int snd_timer_params_get_early_event(snd_timer_params_t * params);
jpayne@69 229 void snd_timer_params_set_ticks(snd_timer_params_t * params, long ticks);
jpayne@69 230 long snd_timer_params_get_ticks(snd_timer_params_t * params);
jpayne@69 231 void snd_timer_params_set_queue_size(snd_timer_params_t * params, long queue_size);
jpayne@69 232 long snd_timer_params_get_queue_size(snd_timer_params_t * params);
jpayne@69 233 void snd_timer_params_set_filter(snd_timer_params_t * params, unsigned int filter);
jpayne@69 234 unsigned int snd_timer_params_get_filter(snd_timer_params_t * params);
jpayne@69 235
jpayne@69 236 size_t snd_timer_status_sizeof(void);
jpayne@69 237 /** allocate #snd_timer_status_t container on stack */
jpayne@69 238 #define snd_timer_status_alloca(ptr) __snd_alloca(ptr, snd_timer_status)
jpayne@69 239 int snd_timer_status_malloc(snd_timer_status_t **ptr);
jpayne@69 240 void snd_timer_status_free(snd_timer_status_t *obj);
jpayne@69 241 void snd_timer_status_copy(snd_timer_status_t *dst, const snd_timer_status_t *src);
jpayne@69 242
jpayne@69 243 snd_htimestamp_t snd_timer_status_get_timestamp(snd_timer_status_t * status);
jpayne@69 244 long snd_timer_status_get_resolution(snd_timer_status_t * status);
jpayne@69 245 long snd_timer_status_get_lost(snd_timer_status_t * status);
jpayne@69 246 long snd_timer_status_get_overrun(snd_timer_status_t * status);
jpayne@69 247 long snd_timer_status_get_queue(snd_timer_status_t * status);
jpayne@69 248
jpayne@69 249 /* deprecated functions, for compatibility */
jpayne@69 250 long snd_timer_info_get_ticks(snd_timer_info_t * info);
jpayne@69 251
jpayne@69 252 /** \} */
jpayne@69 253
jpayne@69 254 #ifdef __cplusplus
jpayne@69 255 }
jpayne@69 256 #endif
jpayne@69 257
jpayne@69 258 #endif /** __ALSA_TIMER_H */
jpayne@69 259