ALSA project - the C library reference
global.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  *
26  */
27 
28 #if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
29 /* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
30 #warning "use #include <alsa/asoundlib.h>, <alsa/global.h> should not be used directly"
31 #include <alsa/asoundlib.h>
32 #endif
33 
34 #ifndef __ALSA_GLOBAL_H_
35 #define __ALSA_GLOBAL_H_
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
50 const char *snd_asoundlib_version(void);
51 
52 #ifndef ATTRIBUTE_UNUSED
54 #define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
55 #endif
56 
57 #ifndef __STRING
59 #define __STRING(x) #x
60 #endif
61 
62 #ifdef PIC /* dynamic build */
63 
65 #define __SND_DLSYM_VERSION(name, version) _ ## name ## version
70 #define SND_DLSYM_BUILD_VERSION(name, version) char __SND_DLSYM_VERSION(name, version);
71 
72 #else /* static build */
73 
74 struct snd_dlsym_link {
75  struct snd_dlsym_link *next;
76  const char *dlsym_name;
77  const void *dlsym_ptr;
78 };
79 
80 extern struct snd_dlsym_link *snd_dlsym_start;
81 
83 #define __SND_DLSYM_VERSION(prefix, name, version) _ ## prefix ## name ## version
88 #define SND_DLSYM_BUILD_VERSION(name, version) \
89  static struct snd_dlsym_link __SND_DLSYM_VERSION(snd_dlsym_, name, version); \
90  void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) __attribute__ ((constructor)); \
91  void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) { \
92  __SND_DLSYM_VERSION(snd_dlsym_, name, version).next = snd_dlsym_start; \
93  __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_name = __STRING(name); \
94  __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_ptr = (void *)&name; \
95  snd_dlsym_start = &__SND_DLSYM_VERSION(snd_dlsym_, name, version); \
96  }
97 
98 #endif
99 
101 #define SND_DLSYM_VERSION(version) __STRING(version)
102 
103 int snd_dlpath(char *path, size_t path_len, const char *name);
104 void *snd_dlopen(const char *file, int mode, char *errbuf, size_t errbuflen);
105 void *snd_dlsym(void *handle, const char *name, const char *version);
106 int snd_dlclose(void *handle);
107 
108 
110 #define __snd_alloca(ptr,type) do { *ptr = (type##_t *) alloca(type##_sizeof()); memset(*ptr, 0, type##_sizeof()); } while (0)
111 
118 typedef struct _snd_async_handler snd_async_handler_t;
119 
125 typedef void (*snd_async_callback_t)(snd_async_handler_t *handler);
126 
127 int snd_async_add_handler(snd_async_handler_t **handler, int fd,
128  snd_async_callback_t callback, void *private_data);
133 
134 struct snd_shm_area *snd_shm_area_create(int shmid, void *ptr);
135 struct snd_shm_area *snd_shm_area_share(struct snd_shm_area *area);
136 int snd_shm_area_destroy(struct snd_shm_area *area);
137 
138 int snd_user_file(const char *file, char **result);
139 
140 #ifdef __GLIBC__
141 #if !defined(_POSIX_C_SOURCE) && !defined(_POSIX_SOURCE)
142 struct timeval {
143  time_t tv_sec; /* seconds */
144  long tv_usec; /* microseconds */
145 };
146 
147 struct timespec {
148  time_t tv_sec; /* seconds */
149  long tv_nsec; /* nanoseconds */
150 };
151 #endif
152 #endif
153 
155 typedef struct timeval snd_timestamp_t;
157 typedef struct timespec snd_htimestamp_t;
158 
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 #endif /* __ALSA_GLOBAL_H */
const char * snd_asoundlib_version(void)
Returns the ALSA sound library version in ASCII format.
Definition: error.c:143
int snd_async_del_handler(snd_async_handler_t *handler)
Deletes an async handler.
Definition: async.c:150
struct timespec snd_htimestamp_t
Definition: global.h:157
struct snd_shm_area * snd_shm_area_create(int shmid, void *ptr)
Create a shm area record.
Definition: shmarea.c:68
int snd_shm_area_destroy(struct snd_shm_area *area)
Release the shared area record.
Definition: shmarea.c:103
int snd_dlclose(void *handle)
Closes a dynamic library - ALSA wrapper for dlclose.
Definition: dlmisc.c:186
struct _snd_async_handler snd_async_handler_t
Internal structure for an async notification client handler.
Definition: global.h:118
void * snd_dlopen(const char *file, int mode, char *errbuf, size_t errbuflen)
Opens a dynamic library - ALSA wrapper for dlopen.
Definition: dlmisc.c:122
struct snd_shm_area * snd_shm_area_share(struct snd_shm_area *area)
Increase the reference counter of shm area record.
Definition: shmarea.c:87
int snd_user_file(const char *file, char **result)
Get the full file name.
Definition: userfile.c:72
int snd_async_handler_get_signo(snd_async_handler_t *handler)
Returns the signal number assigned to an async handler.
Definition: async.c:210
int snd_async_handler_get_fd(snd_async_handler_t *handler)
Returns the file descriptor assigned to an async handler.
Definition: async.c:221
void * snd_async_handler_get_callback_private(snd_async_handler_t *handler)
Returns the private data assigned to an async handler.
Definition: async.c:232
struct timeval snd_timestamp_t
Definition: global.h:155
void * snd_dlsym(void *handle, const char *name, const char *version)
Resolves a symbol from a dynamic library - ALSA wrapper for dlsym.
Definition: dlmisc.c:246
int snd_dlpath(char *path, size_t path_len, const char *name)
Compose the dynamic path.
Definition: dlmisc.c:90
void(* snd_async_callback_t)(snd_async_handler_t *handler)
Async notification callback.
Definition: global.h:125
int snd_async_add_handler(snd_async_handler_t **handler, int fd, snd_async_callback_t callback, void *private_data)
Registers an async handler.
Definition: async.c:112