OSDN Git Service

Configuration:
[android-x86/external-alsa-lib.git] / include / global.h
1 /**
2  * \file <alsa/global.h>
3  * \brief Application interface library for the ALSA driver
4  * \author Jaroslav Kysela <perex@suse.cz>
5  * \author Abramo Bagnara <abramo@alsa-project.org>
6  * \author Takashi Iwai <tiwai@suse.de>
7  * \date 1998-2001
8  *
9  * Application interface library for the ALSA driver
10  *
11  *
12  *   This library is free software; you can redistribute it and/or modify
13  *   it under the terms of the GNU Library General Public License as
14  *   published by the Free Software Foundation; either version 2 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 Library General Public License for more details.
21  *
22  *   You should have received a copy of the GNU Library General Public
23  *   License along with this library; if not, write to the Free Software
24  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  *
26  */
27
28 #ifndef __ALSA_GLOBAL_H_
29 #define __ALSA_GLOBAL_H_
30
31 /**
32  *  \defgroup Global Global defines and functions
33  *  Global defines and functions.
34  *  \{
35  */
36
37 #ifndef ATTRIBUTE_UNUSED
38 /** do not print warning (gcc) when function parameter is not used */
39 #define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
40 #endif
41
42 #ifdef PIC /* dynamic build */
43
44 /** helper macro for SND_DLSYM_BUILD_VERSION \hideinitializer */
45 #define __SND_DLSYM_VERSION(name, version) _ ## name ## version
46 /** build version for versioned dynamic symbol \hideinitializer */
47 #define SND_DLSYM_BUILD_VERSION(name, version) char __SND_DLSYM_VERSION(name, version);
48
49 #else /* static build */
50
51 struct snd_dlsym_link {
52         struct snd_dlsym_link *next;
53         const char *dlsym_name;
54         const void *dlsym_ptr;
55 };
56
57 extern struct snd_dlsym_link *snd_dlsym_start;
58
59 /** helper macro for SND_DLSYM_BUILD_VERSION \hideinitializer */
60 #define __SND_DLSYM_VERSION(prefix, name, version) _ ## prefix ## name ## version
61 /** build version for versioned dynamic symbol \hideinitializer */
62 #define SND_DLSYM_BUILD_VERSION(name, version) \
63   static struct snd_dlsym_link __SND_DLSYM_VERSION(snd_dlsym_, name, version); \
64   void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) __attribute__ ((constructor)); \
65   void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) { \
66     __SND_DLSYM_VERSION(snd_dlsym_, name, version).next = snd_dlsym_start; \
67     __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_name = # name; \
68     __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_ptr = (void *)&name; \
69     snd_dlsym_start = &__SND_DLSYM_VERSION(snd_dlsym_, name, version); \
70   }
71
72 #endif
73
74 /** get version of dynamic symbol as string */
75 #define SND_DLSYM_VERSION(version) __STRING(version)
76
77 void *snd_dlopen(const char *file, int mode);
78 void *snd_dlsym(void *handle, const char *name, const char *version);
79 int snd_dlclose(void *handle);
80
81
82 /** Async notification client handler */
83 typedef struct _snd_async_handler snd_async_handler_t;
84
85 /** Async notification callback */
86 typedef void (*snd_async_callback_t)(snd_async_handler_t *handler);
87
88 int snd_async_add_handler(snd_async_handler_t **handler, int fd, 
89                           snd_async_callback_t callback, void *private_data);
90 int snd_async_del_handler(snd_async_handler_t *handler);
91 int snd_async_handler_get_fd(snd_async_handler_t *handler);
92 int snd_async_handler_get_signo(snd_async_handler_t *handler);
93 void *snd_async_handler_get_callback_private(snd_async_handler_t *handler);
94
95 /** \} */
96
97 #endif /* __ALSA_GLOBAL_H */