Path: blob/master/thirdparty/linuxbsd_headers/alsa/timer.h
9903 views
/**1* \file include/timer.h2* \brief Application interface library for the ALSA driver3* \author Jaroslav Kysela <[email protected]>4* \author Abramo Bagnara <[email protected]>5* \author Takashi Iwai <[email protected]>6* \date 1998-20017*8* Application interface library for the ALSA driver9*/10/*11* This library is free software; you can redistribute it and/or modify12* it under the terms of the GNU Lesser General Public License as13* published by the Free Software Foundation; either version 2.1 of14* the License, or (at your option) any later version.15*16* This program is distributed in the hope that it will be useful,17* but WITHOUT ANY WARRANTY; without even the implied warranty of18* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19* GNU Lesser General Public License for more details.20*21* You should have received a copy of the GNU Lesser General Public22* License along with this library; if not, write to the Free Software23* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA24*25*/2627#ifndef __ALSA_TIMER_H28#define __ALSA_TIMER_H2930#ifdef __cplusplus31extern "C" {32#endif3334/**35* \defgroup Timer Timer Interface36* Timer Interface. See \ref timer page for more details.37* \{38*/3940/** dlsym version for interface entry callback */41#define SND_TIMER_DLSYM_VERSION _dlsym_timer_00142/** dlsym version for interface entry callback */43#define SND_TIMER_QUERY_DLSYM_VERSION _dlsym_timer_query_0014445/** timer identification structure */46typedef struct _snd_timer_id snd_timer_id_t;47/** timer global info structure */48typedef struct _snd_timer_ginfo snd_timer_ginfo_t;49/** timer global params structure */50typedef struct _snd_timer_gparams snd_timer_gparams_t;51/** timer global status structure */52typedef struct _snd_timer_gstatus snd_timer_gstatus_t;53/** timer info structure */54typedef struct _snd_timer_info snd_timer_info_t;55/** timer params structure */56typedef struct _snd_timer_params snd_timer_params_t;57/** timer status structure */58typedef struct _snd_timer_status snd_timer_status_t;59/** timer master class */60typedef enum _snd_timer_class {61SND_TIMER_CLASS_NONE = -1, /**< invalid */62SND_TIMER_CLASS_SLAVE = 0, /**< slave timer */63SND_TIMER_CLASS_GLOBAL, /**< global timer */64SND_TIMER_CLASS_CARD, /**< card timer */65SND_TIMER_CLASS_PCM, /**< PCM timer */66SND_TIMER_CLASS_LAST = SND_TIMER_CLASS_PCM /**< last timer */67} snd_timer_class_t;6869/** timer slave class */70typedef enum _snd_timer_slave_class {71SND_TIMER_SCLASS_NONE = 0, /**< none */72SND_TIMER_SCLASS_APPLICATION, /**< for internal use */73SND_TIMER_SCLASS_SEQUENCER, /**< sequencer timer */74SND_TIMER_SCLASS_OSS_SEQUENCER, /**< OSS sequencer timer */75SND_TIMER_SCLASS_LAST = SND_TIMER_SCLASS_OSS_SEQUENCER /**< last slave timer */76} snd_timer_slave_class_t;7778/** timer read event identification */79typedef enum _snd_timer_event {80SND_TIMER_EVENT_RESOLUTION = 0, /* val = resolution in ns */81SND_TIMER_EVENT_TICK, /* val = ticks */82SND_TIMER_EVENT_START, /* val = resolution in ns */83SND_TIMER_EVENT_STOP, /* val = 0 */84SND_TIMER_EVENT_CONTINUE, /* val = resolution in ns */85SND_TIMER_EVENT_PAUSE, /* val = 0 */86SND_TIMER_EVENT_EARLY, /* val = 0 */87SND_TIMER_EVENT_SUSPEND, /* val = 0 */88SND_TIMER_EVENT_RESUME, /* val = resolution in ns */89/* master timer events for slave timer instances */90SND_TIMER_EVENT_MSTART = SND_TIMER_EVENT_START + 10,91SND_TIMER_EVENT_MSTOP = SND_TIMER_EVENT_STOP + 10,92SND_TIMER_EVENT_MCONTINUE = SND_TIMER_EVENT_CONTINUE + 10,93SND_TIMER_EVENT_MPAUSE = SND_TIMER_EVENT_PAUSE + 10,94SND_TIMER_EVENT_MSUSPEND = SND_TIMER_EVENT_SUSPEND + 10,95SND_TIMER_EVENT_MRESUME = SND_TIMER_EVENT_RESUME + 1096} snd_timer_event_t;9798/** timer read structure */99typedef struct _snd_timer_read {100unsigned int resolution; /**< tick resolution in nanoseconds */101unsigned int ticks; /**< count of happened ticks */102} snd_timer_read_t;103104/** timer tstamp + event read structure */105typedef struct _snd_timer_tread {106snd_timer_event_t event; /**< Timer event */107snd_htimestamp_t tstamp; /**< Time stamp of each event */108unsigned int val; /**< Event value */109} snd_timer_tread_t;110111/** global timer - system */112#define SND_TIMER_GLOBAL_SYSTEM 0113/** global timer - RTC */114#define SND_TIMER_GLOBAL_RTC 1115/** global timer - HPET */116#define SND_TIMER_GLOBAL_HPET 2117/** global timer - HRTIMER */118#define SND_TIMER_GLOBAL_HRTIMER 3119120/** timer open mode flag - non-blocking behaviour */121#define SND_TIMER_OPEN_NONBLOCK (1<<0)122/** use timestamps and event notification - enhanced read */123#define SND_TIMER_OPEN_TREAD (1<<1)124125/** timer handle type */126typedef enum _snd_timer_type {127/** Kernel level HwDep */128SND_TIMER_TYPE_HW = 0,129/** Shared memory client timer (not yet implemented) */130SND_TIMER_TYPE_SHM,131/** INET client timer (not yet implemented) */132SND_TIMER_TYPE_INET133} snd_timer_type_t;134135/** timer query handle */136typedef struct _snd_timer_query snd_timer_query_t;137/** timer handle */138typedef struct _snd_timer snd_timer_t;139140141int snd_timer_query_open(snd_timer_query_t **handle, const char *name, int mode);142int snd_timer_query_open_lconf(snd_timer_query_t **handle, const char *name, int mode, snd_config_t *lconf);143int snd_timer_query_close(snd_timer_query_t *handle);144int snd_timer_query_next_device(snd_timer_query_t *handle, snd_timer_id_t *tid);145int snd_timer_query_info(snd_timer_query_t *handle, snd_timer_ginfo_t *info);146int snd_timer_query_params(snd_timer_query_t *handle, snd_timer_gparams_t *params);147int snd_timer_query_status(snd_timer_query_t *handle, snd_timer_gstatus_t *status);148149int snd_timer_open(snd_timer_t **handle, const char *name, int mode);150int snd_timer_open_lconf(snd_timer_t **handle, const char *name, int mode, snd_config_t *lconf);151int snd_timer_close(snd_timer_t *handle);152int snd_async_add_timer_handler(snd_async_handler_t **handler, snd_timer_t *timer,153snd_async_callback_t callback, void *private_data);154snd_timer_t *snd_async_handler_get_timer(snd_async_handler_t *handler);155int snd_timer_poll_descriptors_count(snd_timer_t *handle);156int snd_timer_poll_descriptors(snd_timer_t *handle, struct pollfd *pfds, unsigned int space);157int snd_timer_poll_descriptors_revents(snd_timer_t *timer, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);158int snd_timer_info(snd_timer_t *handle, snd_timer_info_t *timer);159int snd_timer_params(snd_timer_t *handle, snd_timer_params_t *params);160int snd_timer_status(snd_timer_t *handle, snd_timer_status_t *status);161int snd_timer_start(snd_timer_t *handle);162int snd_timer_stop(snd_timer_t *handle);163int snd_timer_continue(snd_timer_t *handle);164ssize_t snd_timer_read(snd_timer_t *handle, void *buffer, size_t size);165166size_t snd_timer_id_sizeof(void);167/** allocate #snd_timer_id_t container on stack */168#define snd_timer_id_alloca(ptr) __snd_alloca(ptr, snd_timer_id)169int snd_timer_id_malloc(snd_timer_id_t **ptr);170void snd_timer_id_free(snd_timer_id_t *obj);171void snd_timer_id_copy(snd_timer_id_t *dst, const snd_timer_id_t *src);172173void snd_timer_id_set_class(snd_timer_id_t *id, int dev_class);174int snd_timer_id_get_class(snd_timer_id_t *id);175void snd_timer_id_set_sclass(snd_timer_id_t *id, int dev_sclass);176int snd_timer_id_get_sclass(snd_timer_id_t *id);177void snd_timer_id_set_card(snd_timer_id_t *id, int card);178int snd_timer_id_get_card(snd_timer_id_t *id);179void snd_timer_id_set_device(snd_timer_id_t *id, int device);180int snd_timer_id_get_device(snd_timer_id_t *id);181void snd_timer_id_set_subdevice(snd_timer_id_t *id, int subdevice);182int snd_timer_id_get_subdevice(snd_timer_id_t *id);183184size_t snd_timer_ginfo_sizeof(void);185/** allocate #snd_timer_ginfo_t container on stack */186#define snd_timer_ginfo_alloca(ptr) __snd_alloca(ptr, snd_timer_ginfo)187int snd_timer_ginfo_malloc(snd_timer_ginfo_t **ptr);188void snd_timer_ginfo_free(snd_timer_ginfo_t *obj);189void snd_timer_ginfo_copy(snd_timer_ginfo_t *dst, const snd_timer_ginfo_t *src);190191int snd_timer_ginfo_set_tid(snd_timer_ginfo_t *obj, snd_timer_id_t *tid);192snd_timer_id_t *snd_timer_ginfo_get_tid(snd_timer_ginfo_t *obj);193unsigned int snd_timer_ginfo_get_flags(snd_timer_ginfo_t *obj);194int snd_timer_ginfo_get_card(snd_timer_ginfo_t *obj);195char *snd_timer_ginfo_get_id(snd_timer_ginfo_t *obj);196char *snd_timer_ginfo_get_name(snd_timer_ginfo_t *obj);197unsigned long snd_timer_ginfo_get_resolution(snd_timer_ginfo_t *obj);198unsigned long snd_timer_ginfo_get_resolution_min(snd_timer_ginfo_t *obj);199unsigned long snd_timer_ginfo_get_resolution_max(snd_timer_ginfo_t *obj);200unsigned int snd_timer_ginfo_get_clients(snd_timer_ginfo_t *obj);201202size_t snd_timer_info_sizeof(void);203/** allocate #snd_timer_info_t container on stack */204#define snd_timer_info_alloca(ptr) __snd_alloca(ptr, snd_timer_info)205int snd_timer_info_malloc(snd_timer_info_t **ptr);206void snd_timer_info_free(snd_timer_info_t *obj);207void snd_timer_info_copy(snd_timer_info_t *dst, const snd_timer_info_t *src);208209int snd_timer_info_is_slave(snd_timer_info_t * info);210int snd_timer_info_get_card(snd_timer_info_t * info);211const char *snd_timer_info_get_id(snd_timer_info_t * info);212const char *snd_timer_info_get_name(snd_timer_info_t * info);213long snd_timer_info_get_resolution(snd_timer_info_t * info);214215size_t snd_timer_params_sizeof(void);216/** allocate #snd_timer_params_t container on stack */217#define snd_timer_params_alloca(ptr) __snd_alloca(ptr, snd_timer_params)218int snd_timer_params_malloc(snd_timer_params_t **ptr);219void snd_timer_params_free(snd_timer_params_t *obj);220void snd_timer_params_copy(snd_timer_params_t *dst, const snd_timer_params_t *src);221222int snd_timer_params_set_auto_start(snd_timer_params_t * params, int auto_start);223int snd_timer_params_get_auto_start(snd_timer_params_t * params);224int snd_timer_params_set_exclusive(snd_timer_params_t * params, int exclusive);225int snd_timer_params_get_exclusive(snd_timer_params_t * params);226int snd_timer_params_set_early_event(snd_timer_params_t * params, int early_event);227int snd_timer_params_get_early_event(snd_timer_params_t * params);228void snd_timer_params_set_ticks(snd_timer_params_t * params, long ticks);229long snd_timer_params_get_ticks(snd_timer_params_t * params);230void snd_timer_params_set_queue_size(snd_timer_params_t * params, long queue_size);231long snd_timer_params_get_queue_size(snd_timer_params_t * params);232void snd_timer_params_set_filter(snd_timer_params_t * params, unsigned int filter);233unsigned int snd_timer_params_get_filter(snd_timer_params_t * params);234235size_t snd_timer_status_sizeof(void);236/** allocate #snd_timer_status_t container on stack */237#define snd_timer_status_alloca(ptr) __snd_alloca(ptr, snd_timer_status)238int snd_timer_status_malloc(snd_timer_status_t **ptr);239void snd_timer_status_free(snd_timer_status_t *obj);240void snd_timer_status_copy(snd_timer_status_t *dst, const snd_timer_status_t *src);241242snd_htimestamp_t snd_timer_status_get_timestamp(snd_timer_status_t * status);243long snd_timer_status_get_resolution(snd_timer_status_t * status);244long snd_timer_status_get_lost(snd_timer_status_t * status);245long snd_timer_status_get_overrun(snd_timer_status_t * status);246long snd_timer_status_get_queue(snd_timer_status_t * status);247248/* deprecated functions, for compatibility */249long snd_timer_info_get_ticks(snd_timer_info_t * info);250251/** \} */252253#ifdef __cplusplus254}255#endif256257#endif /** __ALSA_TIMER_H */258259260261