2 * ALSA lib - local header file
3 * Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org>
6 * This library is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #elif defined(HAVE_SYS_ENDIAN_H)
36 #include <sys/endian.h>
38 #define __BYTE_ORDER BYTE_ORDER
40 #ifndef __LITTLE_ENDIAN
41 #define __LITTLE_ENDIAN LITTLE_ENDIAN
44 #define __BIG_ENDIAN BIG_ENDIAN
47 #error Header defining endianness not defined
51 #include <sys/types.h>
53 #if defined(__linux__)
54 #include <linux/types.h>
55 #include <linux/ioctl.h>
57 #include "type_compat.h"
69 #if __BYTE_ORDER == __LITTLE_ENDIAN
70 #define SND_LITTLE_ENDIAN
71 #define SNDRV_LITTLE_ENDIAN
72 #elif __BYTE_ORDER == __BIG_ENDIAN
73 #define SND_BIG_ENDIAN
74 #define SNDRV_BIG_ENDIAN
76 #error "Unsupported endian..."
79 #define _snd_config_iterator list_head
80 #define _snd_interval snd_interval
81 #define _snd_pcm_info snd_pcm_info
82 #define _snd_pcm_hw_params snd_pcm_hw_params
83 #define _snd_pcm_sw_params snd_pcm_sw_params
84 #define _snd_pcm_status snd_pcm_status
86 #define _snd_ctl_card_info snd_ctl_card_info
87 #define _snd_ctl_elem_id snd_ctl_elem_id
88 #define _snd_ctl_elem_list snd_ctl_elem_list
89 #define _snd_ctl_elem_info snd_ctl_elem_info
90 #define _snd_ctl_elem_value snd_ctl_elem_value
91 #define _snd_ctl_event snd_ctl_event
93 #define _snd_rawmidi_info snd_rawmidi_info
94 #define _snd_rawmidi_params snd_rawmidi_params
95 #define _snd_rawmidi_status snd_rawmidi_status
97 #define _snd_hwdep_info snd_hwdep_info
98 #define _snd_hwdep_dsp_status snd_hwdep_dsp_status
99 #define _snd_hwdep_dsp_image snd_hwdep_dsp_image
101 #define _snd_seq_queue_tempo snd_seq_queue_tempo
102 #define _snd_seq_client_info snd_seq_client_info
103 #define _snd_seq_port_info snd_seq_port_info
104 #define _snd_seq_system_info snd_seq_system_info
105 #define _snd_seq_queue_info snd_seq_queue_info
106 #define _snd_seq_queue_status snd_seq_queue_status
107 #define _snd_seq_queue_timer snd_seq_queue_timer
108 #define _snd_seq_port_subscribe snd_seq_port_subscribe
109 #define _snd_seq_query_subscribe snd_seq_query_subs
110 #define _snd_seq_client_pool snd_seq_client_pool
111 #define _snd_seq_remove_events snd_seq_remove_events
113 #define _snd_timer_id snd_timer_id
114 #define _snd_timer_ginfo snd_timer_ginfo
115 #define _snd_timer_gparams snd_timer_gparams
116 #define _snd_timer_gstatus snd_timer_gstatus
117 #define _snd_timer_select snd_timer_select
118 #define _snd_timer_info snd_timer_info
119 #define _snd_timer_params snd_timer_params
120 #define _snd_timer_status snd_timer_status
122 #define ALSA_LIBRARY_BUILD
124 /* rename some types for avoiding conflicts with alsalib's definitions */
125 #define snd_aes_iec958 sndrv_aes_iec958
126 #define snd_pcm_uframes_t sndrv_pcm_uframes_t
127 #define snd_pcm_sframes_t sndrv_pcm_sframes_t
128 #define snd_pcm_access_t sndrv_pcm_access_t
129 #define snd_pcm_format_t sndrv_pcm_format_t
130 #define snd_pcm_subformat_t sndrv_pcm_subformat_t
131 #define snd_pcm_state_t sndrv_pcm_state_t
132 #define snd_interval sndrv_interval
133 #define snd_mask sndrv_mask
134 #define snd_ctl_elem_type_t sndrv_ctl_elem_type_t
135 #define snd_ctl_elem_iface_t sndrv_ctl_elem_iface_t
136 #define snd_ctl_tlv sndrv_ctl_tlv
138 /* kill and replace kernel-specific types */
146 #include <sound/asound.h>
148 /* take back superfluous renames; some can be kept as is */
149 #undef snd_aes_iec958
150 #undef snd_pcm_uframes_t
151 #undef snd_pcm_sframes_t
152 #undef snd_pcm_access_t
153 #undef snd_pcm_format_t
154 #undef snd_pcm_subformat_t
155 #undef snd_pcm_state_t
156 #undef snd_ctl_elem_type_t
157 #undef snd_ctl_elem_iface_t
159 #include <sound/asoundef.h>
160 #include "alsa-symbols.h"
168 #include "pcm_plugin.h"
174 #include "seq_event.h"
177 /* rename some types for avoiding conflicts with alsalib's definitions */
178 #define snd_seq_addr sndrv_seq_addr
179 #define snd_seq_tick_time_t sndrv_seq_tick_time_t
180 #define snd_seq_real_time sndrv_seq_real_time
181 #define snd_seq_timestamp sndrv_seq_timestamp
182 #define snd_seq_event_type_t sndrv_seq_event_type_t
183 #define snd_seq_event sndrv_seq_event
184 #define snd_seq_connect sndrv_seq_connect
185 #define snd_seq_ev_note sndrv_seq_ev_note
186 #define snd_seq_ev_ctrl sndrv_seq_ev_ctrl
187 #define snd_seq_ev_raw8 sndrv_seq_ev_raw8
188 #define snd_seq_ev_raw32 sndrv_seq_ev_raw32
189 #define snd_seq_ev_ext sndrv_seq_ev_ext
190 #define snd_seq_result sndrv_seq_result
191 #define snd_seq_queue_skew sndrv_seq_queue_skew
192 #define snd_seq_ev_queue_control sndrv_seq_ev_queue_control
193 #define snd_seq_client_t sndrv_seq_client_t
194 #define snd_seq_client_type_t sndrv_seq_client_type_t
196 #include <sound/asequencer.h>
198 /* take back some renames */
199 #undef snd_seq_client_t
200 #undef snd_seq_client_type_t
203 #include "seq_midi_event.h"
206 struct _snd_async_handler {
208 SND_ASYNC_HANDLER_GENERIC,
209 SND_ASYNC_HANDLER_CTL,
210 SND_ASYNC_HANDLER_PCM,
211 SND_ASYNC_HANDLER_TIMER,
219 snd_async_callback_t callback;
221 struct list_head glist;
222 struct list_head hlist;
225 typedef enum _snd_set_mode {
231 size_t page_align(size_t size);
232 size_t page_size(void);
233 size_t page_ptr(size_t object_offset, size_t object_size, size_t *offset, size_t *mmap_offset);
235 int safe_strtol(const char *str, long *val);
237 int snd_send_fd(int sock, void *data, size_t len, int fd);
238 int snd_receive_fd(int sock, void *data, size_t len, int *fd);
244 #define CHECK_SANITY(x) x
245 extern snd_lib_error_handler_t snd_err_msg;
246 #define SNDMSG(args...) snd_err_msg(__FILE__, __LINE__, __FUNCTION__, 0, ##args)
247 #define SYSMSG(args...) snd_err_msg(__FILE__, __LINE__, __FUNCTION__, errno, ##args)
249 #define CHECK_SANITY(x) 0 /* not evaluated */
250 #define SNDMSG(args...) /* nop */
251 #define SYSMSG(args...) /* nop */
258 #define HAVE_ASM_PREVIOUS_DIRECTIVE
260 /* Stolen from libc-symbols.h in GNU glibc */
262 /* When a reference to SYMBOL is encountered, the linker will emit a
263 warning message MSG. */
265 #define ASM_NAME(name) __SYMBOL_PREFIX name
270 /* We want the .gnu.warning.SYMBOL section to be unallocated. */
271 # ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
272 # define __make_section_unallocated(section_string) \
273 asm (".section " section_string "\n\t.previous");
274 # elif defined HAVE_ASM_POPSECTION_DIRECTIVE
275 # define __make_section_unallocated(section_string) \
276 asm (".pushsection " section_string "\n\t.popsection");
278 # define __make_section_unallocated(section_string)
281 /* Tacking on "\n\t#" to the section name makes gcc put it's bogus
282 section attributes on what looks like a comment to the assembler. */
283 # ifdef HAVE_SECTION_QUOTES
284 # define link_warning(symbol, msg) \
285 __make_section_unallocated (".gnu.warning." ASM_NAME(#symbol)) \
286 static const char __evoke_link_warning_##symbol[] \
287 __attribute__ ((section (".gnu.warning." ASM_NAME(#symbol) "\"\n\t#\""))) = msg;
289 # define link_warning(symbol, msg) \
290 __make_section_unallocated (".gnu.warning." ASM_NAME(#symbol)) \
291 static const char __evoke_link_warning_##symbol[] \
292 __attribute__ ((section (".gnu.warning." ASM_NAME(#symbol) "\n\t#"))) = msg;
295 # define link_warning(symbol, msg) \
296 asm (".stabs \"" msg "\",30,0,0,0\n\t" \
297 ".stabs \"" ASM_NAME(#symbol) "\",1,0,0,0\n");
300 /* We will never be heard; they will all die horribly. */
301 # define link_warning(symbol, msg)
304 static inline int snd_open_device(const char *filename, int fmode)
311 fd = open(filename, fmode);
313 /* open with resmgr */
314 #ifdef SUPPORT_RESMGR
316 if (errno == EAGAIN || errno == EBUSY)
318 if (! access(filename, F_OK))
319 fd = rsm_open_device(filename, fmode);
323 fcntl(fd, F_SETFD, FD_CLOEXEC);
327 /* make local functions really local */
328 #define snd_dlobj_cache_get \
330 #define snd_dlobj_cache_put \
332 #define snd_dlobj_cache_cleanup \
333 snd1_dlobj_cache_cleanup
334 #define snd_config_set_hop \
336 #define snd_config_check_hop \
337 snd1_config_check_hop
338 #define snd_config_search_alias_hooks \
339 snd1_config_search_alias_hooks
342 void *snd_dlobj_cache_get(const char *lib, const char *name, const char *version, int verbose);
343 int snd_dlobj_cache_put(void *open_func);
344 void snd_dlobj_cache_cleanup(void);
346 /* for recursive checks */
347 void snd_config_set_hop(snd_config_t *conf, int hop);
348 int snd_config_check_hop(snd_config_t *conf);
349 #define SND_CONF_MAX_HOPS 64
351 int snd_config_search_alias_hooks(snd_config_t *config,
352 const char *base, const char *key,
353 snd_config_t **result);
355 int _snd_conf_generic_id(const char *id);
357 /* convenience macros */
358 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
360 #define container_of(ptr, type, member) ({ \
361 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
362 (type *)( (char *)__mptr - offsetof(type,member) );})