jpayne@69
|
1 /**
|
jpayne@69
|
2 * \file include/global.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_GLOBAL_H_
|
jpayne@69
|
29 #define __ALSA_GLOBAL_H_
|
jpayne@69
|
30
|
jpayne@69
|
31 /* for timeval and timespec */
|
jpayne@69
|
32 #include <time.h>
|
jpayne@69
|
33
|
jpayne@69
|
34 #ifdef __cplusplus
|
jpayne@69
|
35 extern "C" {
|
jpayne@69
|
36 #endif
|
jpayne@69
|
37
|
jpayne@69
|
38 /**
|
jpayne@69
|
39 * \defgroup Global Global defines and functions
|
jpayne@69
|
40 * Global defines and functions.
|
jpayne@69
|
41 * \par
|
jpayne@69
|
42 * The ALSA library implementation uses these macros and functions.
|
jpayne@69
|
43 * Most applications probably do not need them.
|
jpayne@69
|
44 * \{
|
jpayne@69
|
45 */
|
jpayne@69
|
46
|
jpayne@69
|
47 const char *snd_asoundlib_version(void);
|
jpayne@69
|
48
|
jpayne@69
|
49 #ifndef ATTRIBUTE_UNUSED
|
jpayne@69
|
50 /** do not print warning (gcc) when function parameter is not used */
|
jpayne@69
|
51 #define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
jpayne@69
|
52 #endif
|
jpayne@69
|
53
|
jpayne@69
|
54 #ifdef PIC /* dynamic build */
|
jpayne@69
|
55
|
jpayne@69
|
56 /** \hideinitializer \brief Helper macro for #SND_DLSYM_BUILD_VERSION. */
|
jpayne@69
|
57 #define __SND_DLSYM_VERSION(name, version) _ ## name ## version
|
jpayne@69
|
58 /**
|
jpayne@69
|
59 * \hideinitializer
|
jpayne@69
|
60 * \brief Appends the build version to the name of a versioned dynamic symbol.
|
jpayne@69
|
61 */
|
jpayne@69
|
62 #define SND_DLSYM_BUILD_VERSION(name, version) char __SND_DLSYM_VERSION(name, version);
|
jpayne@69
|
63
|
jpayne@69
|
64 #else /* static build */
|
jpayne@69
|
65
|
jpayne@69
|
66 struct snd_dlsym_link {
|
jpayne@69
|
67 struct snd_dlsym_link *next;
|
jpayne@69
|
68 const char *dlsym_name;
|
jpayne@69
|
69 const void *dlsym_ptr;
|
jpayne@69
|
70 };
|
jpayne@69
|
71
|
jpayne@69
|
72 extern struct snd_dlsym_link *snd_dlsym_start;
|
jpayne@69
|
73
|
jpayne@69
|
74 /** \hideinitializer \brief Helper macro for #SND_DLSYM_BUILD_VERSION. */
|
jpayne@69
|
75 #define __SND_DLSYM_VERSION(prefix, name, version) _ ## prefix ## name ## version
|
jpayne@69
|
76 /**
|
jpayne@69
|
77 * \hideinitializer
|
jpayne@69
|
78 * \brief Appends the build version to the name of a versioned dynamic symbol.
|
jpayne@69
|
79 */
|
jpayne@69
|
80 #define SND_DLSYM_BUILD_VERSION(name, version) \
|
jpayne@69
|
81 static struct snd_dlsym_link __SND_DLSYM_VERSION(snd_dlsym_, name, version); \
|
jpayne@69
|
82 void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) __attribute__ ((constructor)); \
|
jpayne@69
|
83 void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) { \
|
jpayne@69
|
84 __SND_DLSYM_VERSION(snd_dlsym_, name, version).next = snd_dlsym_start; \
|
jpayne@69
|
85 __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_name = # name; \
|
jpayne@69
|
86 __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_ptr = (void *)&name; \
|
jpayne@69
|
87 snd_dlsym_start = &__SND_DLSYM_VERSION(snd_dlsym_, name, version); \
|
jpayne@69
|
88 }
|
jpayne@69
|
89
|
jpayne@69
|
90 #endif
|
jpayne@69
|
91
|
jpayne@69
|
92 #ifndef __STRING
|
jpayne@69
|
93 /** \brief Return 'x' argument as string */
|
jpayne@69
|
94 #define __STRING(x) #x
|
jpayne@69
|
95 #endif
|
jpayne@69
|
96
|
jpayne@69
|
97 /** \brief Returns the version of a dynamic symbol as a string. */
|
jpayne@69
|
98 #define SND_DLSYM_VERSION(version) __STRING(version)
|
jpayne@69
|
99
|
jpayne@69
|
100 int snd_dlpath(char *path, size_t path_len, const char *name);
|
jpayne@69
|
101 void *snd_dlopen(const char *file, int mode, char *errbuf, size_t errbuflen);
|
jpayne@69
|
102 void *snd_dlsym(void *handle, const char *name, const char *version);
|
jpayne@69
|
103 int snd_dlclose(void *handle);
|
jpayne@69
|
104
|
jpayne@69
|
105
|
jpayne@69
|
106 /** \brief alloca helper macro. */
|
jpayne@69
|
107 #define __snd_alloca(ptr,type) do { *ptr = (type##_t *) alloca(type##_sizeof()); memset(*ptr, 0, type##_sizeof()); } while (0)
|
jpayne@69
|
108
|
jpayne@69
|
109 /**
|
jpayne@69
|
110 * \brief Internal structure for an async notification client handler.
|
jpayne@69
|
111 *
|
jpayne@69
|
112 * The ALSA library uses a pointer to this structure as a handle to an async
|
jpayne@69
|
113 * notification object. Applications don't access its contents directly.
|
jpayne@69
|
114 */
|
jpayne@69
|
115 typedef struct _snd_async_handler snd_async_handler_t;
|
jpayne@69
|
116
|
jpayne@69
|
117 /**
|
jpayne@69
|
118 * \brief Async notification callback.
|
jpayne@69
|
119 *
|
jpayne@69
|
120 * See the #snd_async_add_handler function for details.
|
jpayne@69
|
121 */
|
jpayne@69
|
122 typedef void (*snd_async_callback_t)(snd_async_handler_t *handler);
|
jpayne@69
|
123
|
jpayne@69
|
124 int snd_async_add_handler(snd_async_handler_t **handler, int fd,
|
jpayne@69
|
125 snd_async_callback_t callback, void *private_data);
|
jpayne@69
|
126 int snd_async_del_handler(snd_async_handler_t *handler);
|
jpayne@69
|
127 int snd_async_handler_get_fd(snd_async_handler_t *handler);
|
jpayne@69
|
128 int snd_async_handler_get_signo(snd_async_handler_t *handler);
|
jpayne@69
|
129 void *snd_async_handler_get_callback_private(snd_async_handler_t *handler);
|
jpayne@69
|
130
|
jpayne@69
|
131 struct snd_shm_area *snd_shm_area_create(int shmid, void *ptr);
|
jpayne@69
|
132 struct snd_shm_area *snd_shm_area_share(struct snd_shm_area *area);
|
jpayne@69
|
133 int snd_shm_area_destroy(struct snd_shm_area *area);
|
jpayne@69
|
134
|
jpayne@69
|
135 int snd_user_file(const char *file, char **result);
|
jpayne@69
|
136
|
jpayne@69
|
137 #ifdef __GLIBC__
|
jpayne@69
|
138 #if !defined(_POSIX_C_SOURCE) && !defined(_POSIX_SOURCE)
|
jpayne@69
|
139 struct timeval {
|
jpayne@69
|
140 time_t tv_sec; /* seconds */
|
jpayne@69
|
141 long tv_usec; /* microseconds */
|
jpayne@69
|
142 };
|
jpayne@69
|
143
|
jpayne@69
|
144 struct timespec {
|
jpayne@69
|
145 time_t tv_sec; /* seconds */
|
jpayne@69
|
146 long tv_nsec; /* nanoseconds */
|
jpayne@69
|
147 };
|
jpayne@69
|
148 #endif
|
jpayne@69
|
149 #endif
|
jpayne@69
|
150
|
jpayne@69
|
151 /** Timestamp */
|
jpayne@69
|
152 typedef struct timeval snd_timestamp_t;
|
jpayne@69
|
153 /** Hi-res timestamp */
|
jpayne@69
|
154 typedef struct timespec snd_htimestamp_t;
|
jpayne@69
|
155
|
jpayne@69
|
156 /** \} */
|
jpayne@69
|
157
|
jpayne@69
|
158 #ifdef __cplusplus
|
jpayne@69
|
159 }
|
jpayne@69
|
160 #endif
|
jpayne@69
|
161
|
jpayne@69
|
162 #endif /* __ALSA_GLOBAL_H */
|