1d5ac70f0Sopenharmony_ci/** 2d5ac70f0Sopenharmony_ci * \file include/global.h 3d5ac70f0Sopenharmony_ci * \brief Application interface library for the ALSA driver 4d5ac70f0Sopenharmony_ci * \author Jaroslav Kysela <perex@perex.cz> 5d5ac70f0Sopenharmony_ci * \author Abramo Bagnara <abramo@alsa-project.org> 6d5ac70f0Sopenharmony_ci * \author Takashi Iwai <tiwai@suse.de> 7d5ac70f0Sopenharmony_ci * \date 1998-2001 8d5ac70f0Sopenharmony_ci * 9d5ac70f0Sopenharmony_ci * Application interface library for the ALSA driver 10d5ac70f0Sopenharmony_ci */ 11d5ac70f0Sopenharmony_ci/* 12d5ac70f0Sopenharmony_ci * This library is free software; you can redistribute it and/or modify 13d5ac70f0Sopenharmony_ci * it under the terms of the GNU Lesser General Public License as 14d5ac70f0Sopenharmony_ci * published by the Free Software Foundation; either version 2.1 of 15d5ac70f0Sopenharmony_ci * the License, or (at your option) any later version. 16d5ac70f0Sopenharmony_ci * 17d5ac70f0Sopenharmony_ci * This program is distributed in the hope that it will be useful, 18d5ac70f0Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 19d5ac70f0Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20d5ac70f0Sopenharmony_ci * GNU Lesser General Public License for more details. 21d5ac70f0Sopenharmony_ci * 22d5ac70f0Sopenharmony_ci * You should have received a copy of the GNU Lesser General Public 23d5ac70f0Sopenharmony_ci * License along with this library; if not, write to the Free Software 24d5ac70f0Sopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25d5ac70f0Sopenharmony_ci * 26d5ac70f0Sopenharmony_ci */ 27d5ac70f0Sopenharmony_ci 28d5ac70f0Sopenharmony_ci#ifndef __ALSA_GLOBAL_H_ 29d5ac70f0Sopenharmony_ci#define __ALSA_GLOBAL_H_ 30d5ac70f0Sopenharmony_ci 31d5ac70f0Sopenharmony_ci/* for timeval and timespec */ 32d5ac70f0Sopenharmony_ci#include <time.h> 33d5ac70f0Sopenharmony_ci 34d5ac70f0Sopenharmony_ci#ifdef __cplusplus 35d5ac70f0Sopenharmony_ciextern "C" { 36d5ac70f0Sopenharmony_ci#endif 37d5ac70f0Sopenharmony_ci 38d5ac70f0Sopenharmony_ci/** 39d5ac70f0Sopenharmony_ci * \defgroup Global Global defines and functions 40d5ac70f0Sopenharmony_ci * Global defines and functions. 41d5ac70f0Sopenharmony_ci * \par 42d5ac70f0Sopenharmony_ci * The ALSA library implementation uses these macros and functions. 43d5ac70f0Sopenharmony_ci * Most applications probably do not need them. 44d5ac70f0Sopenharmony_ci * \{ 45d5ac70f0Sopenharmony_ci */ 46d5ac70f0Sopenharmony_ci 47d5ac70f0Sopenharmony_ciconst char *snd_asoundlib_version(void); 48d5ac70f0Sopenharmony_ci 49d5ac70f0Sopenharmony_ci#ifndef ATTRIBUTE_UNUSED 50d5ac70f0Sopenharmony_ci/** do not print warning (gcc) when function parameter is not used */ 51d5ac70f0Sopenharmony_ci#define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) 52d5ac70f0Sopenharmony_ci#endif 53d5ac70f0Sopenharmony_ci 54d5ac70f0Sopenharmony_ci#ifndef __STRING 55d5ac70f0Sopenharmony_ci/** \brief Return 'x' argument as string */ 56d5ac70f0Sopenharmony_ci#define __STRING(x) #x 57d5ac70f0Sopenharmony_ci#endif 58d5ac70f0Sopenharmony_ci 59d5ac70f0Sopenharmony_ci#ifdef PIC /* dynamic build */ 60d5ac70f0Sopenharmony_ci 61d5ac70f0Sopenharmony_ci/** \hideinitializer \brief Helper macro for #SND_DLSYM_BUILD_VERSION. */ 62d5ac70f0Sopenharmony_ci#define __SND_DLSYM_VERSION(name, version) _ ## name ## version 63d5ac70f0Sopenharmony_ci/** 64d5ac70f0Sopenharmony_ci * \hideinitializer 65d5ac70f0Sopenharmony_ci * \brief Appends the build version to the name of a versioned dynamic symbol. 66d5ac70f0Sopenharmony_ci */ 67d5ac70f0Sopenharmony_ci#define SND_DLSYM_BUILD_VERSION(name, version) char __SND_DLSYM_VERSION(name, version); 68d5ac70f0Sopenharmony_ci 69d5ac70f0Sopenharmony_ci#else /* static build */ 70d5ac70f0Sopenharmony_ci 71d5ac70f0Sopenharmony_cistruct snd_dlsym_link { 72d5ac70f0Sopenharmony_ci struct snd_dlsym_link *next; 73d5ac70f0Sopenharmony_ci const char *dlsym_name; 74d5ac70f0Sopenharmony_ci const void *dlsym_ptr; 75d5ac70f0Sopenharmony_ci}; 76d5ac70f0Sopenharmony_ci 77d5ac70f0Sopenharmony_ciextern struct snd_dlsym_link *snd_dlsym_start; 78d5ac70f0Sopenharmony_ci 79d5ac70f0Sopenharmony_ci/** \hideinitializer \brief Helper macro for #SND_DLSYM_BUILD_VERSION. */ 80d5ac70f0Sopenharmony_ci#define __SND_DLSYM_VERSION(prefix, name, version) _ ## prefix ## name ## version 81d5ac70f0Sopenharmony_ci/** 82d5ac70f0Sopenharmony_ci * \hideinitializer 83d5ac70f0Sopenharmony_ci * \brief Appends the build version to the name of a versioned dynamic symbol. 84d5ac70f0Sopenharmony_ci */ 85d5ac70f0Sopenharmony_ci#define SND_DLSYM_BUILD_VERSION(name, version) \ 86d5ac70f0Sopenharmony_ci static struct snd_dlsym_link __SND_DLSYM_VERSION(snd_dlsym_, name, version); \ 87d5ac70f0Sopenharmony_ci void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) __attribute__ ((constructor)); \ 88d5ac70f0Sopenharmony_ci void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) { \ 89d5ac70f0Sopenharmony_ci __SND_DLSYM_VERSION(snd_dlsym_, name, version).next = snd_dlsym_start; \ 90d5ac70f0Sopenharmony_ci __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_name = __STRING(name); \ 91d5ac70f0Sopenharmony_ci __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_ptr = (void *)&name; \ 92d5ac70f0Sopenharmony_ci snd_dlsym_start = &__SND_DLSYM_VERSION(snd_dlsym_, name, version); \ 93d5ac70f0Sopenharmony_ci } 94d5ac70f0Sopenharmony_ci 95d5ac70f0Sopenharmony_ci#endif 96d5ac70f0Sopenharmony_ci 97d5ac70f0Sopenharmony_ci/** \brief Returns the version of a dynamic symbol as a string. */ 98d5ac70f0Sopenharmony_ci#define SND_DLSYM_VERSION(version) __STRING(version) 99d5ac70f0Sopenharmony_ci 100d5ac70f0Sopenharmony_ciint snd_dlpath(char *path, size_t path_len, const char *name); 101d5ac70f0Sopenharmony_civoid *snd_dlopen(const char *file, int mode, char *errbuf, size_t errbuflen); 102d5ac70f0Sopenharmony_civoid *snd_dlsym(void *handle, const char *name, const char *version); 103d5ac70f0Sopenharmony_ciint snd_dlclose(void *handle); 104d5ac70f0Sopenharmony_ci 105d5ac70f0Sopenharmony_ci 106d5ac70f0Sopenharmony_ci/** \brief alloca helper macro. */ 107d5ac70f0Sopenharmony_ci#define __snd_alloca(ptr,type) do { *ptr = (type##_t *) alloca(type##_sizeof()); memset(*ptr, 0, type##_sizeof()); } while (0) 108d5ac70f0Sopenharmony_ci 109d5ac70f0Sopenharmony_ci/** 110d5ac70f0Sopenharmony_ci * \brief Internal structure for an async notification client handler. 111d5ac70f0Sopenharmony_ci * 112d5ac70f0Sopenharmony_ci * The ALSA library uses a pointer to this structure as a handle to an async 113d5ac70f0Sopenharmony_ci * notification object. Applications don't access its contents directly. 114d5ac70f0Sopenharmony_ci */ 115d5ac70f0Sopenharmony_citypedef struct _snd_async_handler snd_async_handler_t; 116d5ac70f0Sopenharmony_ci 117d5ac70f0Sopenharmony_ci/** 118d5ac70f0Sopenharmony_ci * \brief Async notification callback. 119d5ac70f0Sopenharmony_ci * 120d5ac70f0Sopenharmony_ci * See the #snd_async_add_handler function for details. 121d5ac70f0Sopenharmony_ci */ 122d5ac70f0Sopenharmony_citypedef void (*snd_async_callback_t)(snd_async_handler_t *handler); 123d5ac70f0Sopenharmony_ci 124d5ac70f0Sopenharmony_ciint snd_async_add_handler(snd_async_handler_t **handler, int fd, 125d5ac70f0Sopenharmony_ci snd_async_callback_t callback, void *private_data); 126d5ac70f0Sopenharmony_ciint snd_async_del_handler(snd_async_handler_t *handler); 127d5ac70f0Sopenharmony_ciint snd_async_handler_get_fd(snd_async_handler_t *handler); 128d5ac70f0Sopenharmony_ciint snd_async_handler_get_signo(snd_async_handler_t *handler); 129d5ac70f0Sopenharmony_civoid *snd_async_handler_get_callback_private(snd_async_handler_t *handler); 130d5ac70f0Sopenharmony_ci 131d5ac70f0Sopenharmony_cistruct snd_shm_area *snd_shm_area_create(int shmid, void *ptr); 132d5ac70f0Sopenharmony_cistruct snd_shm_area *snd_shm_area_share(struct snd_shm_area *area); 133d5ac70f0Sopenharmony_ciint snd_shm_area_destroy(struct snd_shm_area *area); 134d5ac70f0Sopenharmony_ci 135d5ac70f0Sopenharmony_ciint snd_user_file(const char *file, char **result); 136d5ac70f0Sopenharmony_ci 137d5ac70f0Sopenharmony_ci#ifdef __GLIBC__ 138d5ac70f0Sopenharmony_ci#if !defined(_POSIX_C_SOURCE) && !defined(_POSIX_SOURCE) 139d5ac70f0Sopenharmony_cistruct timeval { 140d5ac70f0Sopenharmony_ci time_t tv_sec; /* seconds */ 141d5ac70f0Sopenharmony_ci long tv_usec; /* microseconds */ 142d5ac70f0Sopenharmony_ci}; 143d5ac70f0Sopenharmony_ci 144d5ac70f0Sopenharmony_cistruct timespec { 145d5ac70f0Sopenharmony_ci time_t tv_sec; /* seconds */ 146d5ac70f0Sopenharmony_ci long tv_nsec; /* nanoseconds */ 147d5ac70f0Sopenharmony_ci}; 148d5ac70f0Sopenharmony_ci#endif 149d5ac70f0Sopenharmony_ci#endif 150d5ac70f0Sopenharmony_ci 151d5ac70f0Sopenharmony_ci/** Timestamp */ 152d5ac70f0Sopenharmony_citypedef struct timeval snd_timestamp_t; 153d5ac70f0Sopenharmony_ci/** Hi-res timestamp */ 154d5ac70f0Sopenharmony_citypedef struct timespec snd_htimestamp_t; 155d5ac70f0Sopenharmony_ci 156d5ac70f0Sopenharmony_ci/** \} */ 157d5ac70f0Sopenharmony_ci 158d5ac70f0Sopenharmony_ci#ifdef __cplusplus 159d5ac70f0Sopenharmony_ci} 160d5ac70f0Sopenharmony_ci#endif 161d5ac70f0Sopenharmony_ci 162d5ac70f0Sopenharmony_ci#endif /* __ALSA_GLOBAL_H */ 163