2001-01-01 15:15:41 +00:00
|
|
|
/*
|
|
|
|
|
* ALSA lib - local header file
|
|
|
|
|
* Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org>
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or modify
|
2001-12-30 09:22:54 +00:00
|
|
|
* it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2.1 of
|
2001-01-01 15:15:41 +00:00
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2001-12-30 09:22:54 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2001-01-01 15:15:41 +00:00
|
|
|
*
|
2001-12-30 09:22:54 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2001-01-01 15:15:41 +00:00
|
|
|
* License along with this library; if not, write to the Free Software
|
2001-12-30 09:22:54 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2001-01-01 15:15:41 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2001-02-06 23:48:10 +00:00
|
|
|
#ifndef __LOCAL_H
|
|
|
|
|
#define __LOCAL_H
|
|
|
|
|
|
2001-09-13 11:38:32 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <endian.h>
|
2003-06-24 19:30:08 +00:00
|
|
|
#include <stdarg.h>
|
2001-09-13 11:38:32 +00:00
|
|
|
#include <sys/poll.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
2001-06-26 10:45:10 +00:00
|
|
|
#include "config.h"
|
2005-02-11 16:35:24 +00:00
|
|
|
#ifdef SUPPORT_RESMGR
|
|
|
|
|
#include <resmgr.h>
|
|
|
|
|
#endif
|
2007-03-22 00:48:18 +01:00
|
|
|
#ifdef HAVE_LIBDL
|
|
|
|
|
#include <dlfcn.h>
|
|
|
|
|
#else
|
|
|
|
|
#define RTLD_NOW 0
|
|
|
|
|
#endif
|
2001-06-04 18:04:18 +00:00
|
|
|
|
2001-03-30 10:12:19 +00:00
|
|
|
#define _snd_config_iterator list_head
|
2001-02-04 17:03:17 +00:00
|
|
|
#define _snd_interval sndrv_interval
|
|
|
|
|
#define _snd_pcm_info sndrv_pcm_info
|
|
|
|
|
#define _snd_pcm_hw_params sndrv_pcm_hw_params
|
|
|
|
|
#define _snd_pcm_sw_params sndrv_pcm_sw_params
|
|
|
|
|
#define _snd_pcm_status sndrv_pcm_status
|
|
|
|
|
|
2001-02-07 15:13:15 +00:00
|
|
|
#define _snd_ctl_card_info sndrv_ctl_card_info
|
2001-02-09 11:20:31 +00:00
|
|
|
#define _snd_ctl_elem_id sndrv_ctl_elem_id
|
|
|
|
|
#define _snd_ctl_elem_list sndrv_ctl_elem_list
|
|
|
|
|
#define _snd_ctl_elem_info sndrv_ctl_elem_info
|
2001-02-11 15:45:35 +00:00
|
|
|
#define _snd_ctl_elem_value sndrv_ctl_elem_value
|
2001-02-06 23:48:10 +00:00
|
|
|
#define _snd_ctl_event sndrv_ctl_event
|
|
|
|
|
|
2001-02-04 17:03:17 +00:00
|
|
|
#define _snd_rawmidi_info sndrv_rawmidi_info
|
|
|
|
|
#define _snd_rawmidi_params sndrv_rawmidi_params
|
|
|
|
|
#define _snd_rawmidi_status sndrv_rawmidi_status
|
|
|
|
|
|
2001-02-05 15:44:42 +00:00
|
|
|
#define _snd_hwdep_info sndrv_hwdep_info
|
2003-02-19 15:39:35 +00:00
|
|
|
#define _snd_hwdep_dsp_status sndrv_hwdep_dsp_status
|
|
|
|
|
#define _snd_hwdep_dsp_image sndrv_hwdep_dsp_image
|
2001-02-05 15:44:42 +00:00
|
|
|
|
2001-07-04 13:54:13 +00:00
|
|
|
#define _snd_seq_queue_tempo sndrv_seq_queue_tempo
|
|
|
|
|
#define _snd_seq_client_info sndrv_seq_client_info
|
|
|
|
|
#define _snd_seq_port_info sndrv_seq_port_info
|
|
|
|
|
#define _snd_seq_system_info sndrv_seq_system_info
|
|
|
|
|
#define _snd_seq_queue_info sndrv_seq_queue_info
|
|
|
|
|
#define _snd_seq_queue_status sndrv_seq_queue_status
|
|
|
|
|
#define _snd_seq_queue_timer sndrv_seq_queue_timer
|
|
|
|
|
#define _snd_seq_port_subscribe sndrv_seq_port_subscribe
|
|
|
|
|
#define _snd_seq_query_subscribe sndrv_seq_query_subs
|
|
|
|
|
#define _snd_seq_client_pool sndrv_seq_client_pool
|
|
|
|
|
#define _snd_seq_remove_events sndrv_seq_remove_events
|
|
|
|
|
|
2005-09-29 19:11:50 +00:00
|
|
|
#define sndrv_seq_addr snd_seq_addr
|
|
|
|
|
#define sndrv_seq_tick_time_t snd_seq_tick_time_t
|
|
|
|
|
#define sndrv_seq_real_time snd_seq_real_time
|
|
|
|
|
#define sndrv_seq_timestamp snd_seq_timestamp
|
|
|
|
|
#define sndrv_seq_event snd_seq_event
|
|
|
|
|
|
2001-08-20 13:15:30 +00:00
|
|
|
#if 0
|
2001-07-04 13:54:13 +00:00
|
|
|
typedef struct sndrv_seq_addr snd_seq_addr_t;
|
|
|
|
|
#define snd_seq_tick_time_t sndrv_seq_tick_time_t
|
|
|
|
|
typedef struct sndrv_seq_real_time snd_seq_real_time_t;
|
|
|
|
|
typedef union sndrv_seq_timestamp snd_seq_timestamp_t;
|
|
|
|
|
typedef struct sndrv_seq_event snd_seq_event_t;
|
2001-08-20 13:15:30 +00:00
|
|
|
#endif
|
2001-07-04 13:54:13 +00:00
|
|
|
|
2001-07-16 13:33:55 +00:00
|
|
|
#define _snd_timer_id sndrv_timer_id
|
2003-03-04 20:01:06 +00:00
|
|
|
#define _snd_timer_ginfo sndrv_timer_ginfo
|
|
|
|
|
#define _snd_timer_gparams sndrv_timer_gparams
|
|
|
|
|
#define _snd_timer_gstatus sndrv_timer_gstatus
|
2001-07-16 13:33:55 +00:00
|
|
|
#define _snd_timer_select sndrv_timer_select
|
|
|
|
|
#define _snd_timer_info sndrv_timer_info
|
|
|
|
|
#define _snd_timer_params sndrv_timer_params
|
|
|
|
|
#define _snd_timer_status sndrv_timer_status
|
|
|
|
|
|
2002-09-17 12:33:05 +00:00
|
|
|
#define ALSA_LIBRARY_BUILD
|
|
|
|
|
|
2001-08-20 13:15:30 +00:00
|
|
|
#include <sound/asound.h>
|
2001-09-11 09:34:13 +00:00
|
|
|
#include <sound/asoundef.h>
|
2002-09-17 12:33:05 +00:00
|
|
|
#include "alsa-symbols.h"
|
2001-09-13 11:38:32 +00:00
|
|
|
#include "version.h"
|
|
|
|
|
#include "global.h"
|
|
|
|
|
#include "input.h"
|
|
|
|
|
#include "output.h"
|
|
|
|
|
#include "error.h"
|
|
|
|
|
#include "conf.h"
|
|
|
|
|
#include "pcm.h"
|
2002-01-12 10:52:42 +00:00
|
|
|
#include "pcm_plugin.h"
|
2001-09-13 11:38:32 +00:00
|
|
|
#include "rawmidi.h"
|
|
|
|
|
#include "timer.h"
|
|
|
|
|
#include "hwdep.h"
|
|
|
|
|
#include "control.h"
|
|
|
|
|
#include "mixer.h"
|
|
|
|
|
#include "seq_event.h"
|
|
|
|
|
#include "seq.h"
|
2005-09-29 19:11:50 +00:00
|
|
|
#include <sound/asequencer.h>
|
2001-09-13 11:38:32 +00:00
|
|
|
#include "seqmid.h"
|
|
|
|
|
#include "seq_midi_event.h"
|
2001-06-20 20:52:12 +00:00
|
|
|
#include "list.h"
|
|
|
|
|
|
2001-08-28 15:39:55 +00:00
|
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
|
|
|
#define SND_LITTLE_ENDIAN
|
|
|
|
|
#endif
|
|
|
|
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
|
|
|
|
#define SND_BIG_ENDIAN
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-06-20 20:52:12 +00:00
|
|
|
struct _snd_async_handler {
|
|
|
|
|
enum {
|
|
|
|
|
SND_ASYNC_HANDLER_GENERIC,
|
|
|
|
|
SND_ASYNC_HANDLER_CTL,
|
2005-05-11 12:18:51 +00:00
|
|
|
SND_ASYNC_HANDLER_PCM,
|
|
|
|
|
SND_ASYNC_HANDLER_TIMER,
|
2001-06-20 20:52:12 +00:00
|
|
|
} type;
|
|
|
|
|
int fd;
|
|
|
|
|
union {
|
|
|
|
|
snd_ctl_t *ctl;
|
2005-05-11 12:18:51 +00:00
|
|
|
snd_pcm_t *pcm;
|
|
|
|
|
snd_timer_t *timer;
|
2001-06-20 20:52:12 +00:00
|
|
|
} u;
|
|
|
|
|
snd_async_callback_t callback;
|
|
|
|
|
void *private_data;
|
|
|
|
|
struct list_head glist;
|
|
|
|
|
struct list_head hlist;
|
|
|
|
|
};
|
2001-01-01 15:15:41 +00:00
|
|
|
|
2001-03-29 10:11:38 +00:00
|
|
|
typedef enum _snd_set_mode {
|
2001-02-06 23:48:10 +00:00
|
|
|
SND_CHANGE,
|
|
|
|
|
SND_TRY,
|
|
|
|
|
SND_TEST,
|
2001-03-29 10:11:38 +00:00
|
|
|
} snd_set_mode_t;
|
2001-02-06 23:48:10 +00:00
|
|
|
|
2001-02-21 21:59:35 +00:00
|
|
|
size_t page_align(size_t size);
|
|
|
|
|
size_t page_size(void);
|
2002-04-23 15:51:29 +00:00
|
|
|
size_t page_ptr(size_t object_offset, size_t object_size, size_t *offset, size_t *mmap_offset);
|
2001-02-21 21:59:35 +00:00
|
|
|
|
2001-06-11 13:35:48 +00:00
|
|
|
int safe_strtol(const char *str, long *val);
|
|
|
|
|
|
2003-03-18 18:00:05 +00:00
|
|
|
int snd_send_fd(int sock, void *data, size_t len, int fd);
|
|
|
|
|
int snd_receive_fd(int sock, void *data, size_t len, int *fd);
|
|
|
|
|
|
2004-12-21 14:11:00 +00:00
|
|
|
/*
|
|
|
|
|
* error messages
|
|
|
|
|
*/
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
#define CHECK_SANITY(x) x
|
|
|
|
|
extern snd_lib_error_handler_t snd_err_msg;
|
|
|
|
|
#define SNDMSG(args...) snd_err_msg(__FILE__, __LINE__, __FUNCTION__, 0, ##args)
|
|
|
|
|
#define SYSMSG(args...) snd_err_msg(__FILE__, __LINE__, __FUNCTION__, errno, ##args)
|
|
|
|
|
#else
|
|
|
|
|
#define CHECK_SANITY(x) 0 /* not evaluated */
|
|
|
|
|
#define SNDMSG(args...) /* nop */
|
|
|
|
|
#define SYSMSG(args...) /* nop */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*/
|
2001-04-19 21:18:23 +00:00
|
|
|
#define HAVE_GNU_LD
|
|
|
|
|
#define HAVE_ELF
|
|
|
|
|
#define HAVE_ASM_PREVIOUS_DIRECTIVE
|
|
|
|
|
|
|
|
|
|
/* Stolen from libc-symbols.h in GNU glibc */
|
|
|
|
|
|
|
|
|
|
/* When a reference to SYMBOL is encountered, the linker will emit a
|
|
|
|
|
warning message MSG. */
|
2006-09-19 18:07:51 +02:00
|
|
|
|
|
|
|
|
#define ASM_NAME(name) __SYMBOL_PREFIX name
|
|
|
|
|
|
2001-04-19 21:18:23 +00:00
|
|
|
#ifdef HAVE_GNU_LD
|
|
|
|
|
# ifdef HAVE_ELF
|
|
|
|
|
|
|
|
|
|
/* We want the .gnu.warning.SYMBOL section to be unallocated. */
|
|
|
|
|
# ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
|
|
|
|
|
# define __make_section_unallocated(section_string) \
|
|
|
|
|
asm (".section " section_string "\n\t.previous");
|
|
|
|
|
# elif defined HAVE_ASM_POPSECTION_DIRECTIVE
|
|
|
|
|
# define __make_section_unallocated(section_string) \
|
|
|
|
|
asm (".pushsection " section_string "\n\t.popsection");
|
|
|
|
|
# else
|
|
|
|
|
# define __make_section_unallocated(section_string)
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
/* Tacking on "\n\t#" to the section name makes gcc put it's bogus
|
|
|
|
|
section attributes on what looks like a comment to the assembler. */
|
|
|
|
|
# ifdef HAVE_SECTION_QUOTES
|
|
|
|
|
# define link_warning(symbol, msg) \
|
2006-09-19 18:07:51 +02:00
|
|
|
__make_section_unallocated (".gnu.warning." ASM_NAME(#symbol)) \
|
2001-04-19 21:18:23 +00:00
|
|
|
static const char __evoke_link_warning_##symbol[] \
|
2006-09-19 18:07:51 +02:00
|
|
|
__attribute__ ((section (".gnu.warning." ASM_NAME(#symbol) "\"\n\t#\""))) = msg;
|
2001-04-19 21:18:23 +00:00
|
|
|
# else
|
|
|
|
|
# define link_warning(symbol, msg) \
|
2006-09-19 18:07:51 +02:00
|
|
|
__make_section_unallocated (".gnu.warning." ASM_NAME(#symbol)) \
|
2001-04-19 21:18:23 +00:00
|
|
|
static const char __evoke_link_warning_##symbol[] \
|
2006-09-19 18:07:51 +02:00
|
|
|
__attribute__ ((section (".gnu.warning." ASM_NAME(#symbol) "\n\t#"))) = msg;
|
2001-04-19 21:18:23 +00:00
|
|
|
# endif
|
|
|
|
|
# else
|
|
|
|
|
# define link_warning(symbol, msg) \
|
|
|
|
|
asm (".stabs \"" msg "\",30,0,0,0\n\t" \
|
2006-09-19 18:07:51 +02:00
|
|
|
".stabs \"" ASM_NAME(#symbol) "\",1,0,0,0\n");
|
2001-04-19 21:18:23 +00:00
|
|
|
# endif
|
|
|
|
|
#else
|
|
|
|
|
/* We will never be heard; they will all die horribly. */
|
|
|
|
|
# define link_warning(symbol, msg)
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-02-11 16:35:24 +00:00
|
|
|
static inline int snd_open_device(const char *filename, int fmode)
|
|
|
|
|
{
|
2009-11-07 21:29:23 +02:00
|
|
|
int fd;
|
|
|
|
|
|
|
|
|
|
#ifdef O_CLOEXEC
|
|
|
|
|
fmode |= O_CLOEXEC;
|
|
|
|
|
#endif
|
|
|
|
|
fd = open(filename, fmode);
|
|
|
|
|
|
|
|
|
|
/* open with resmgr */
|
|
|
|
|
#ifdef SUPPORT_RESMGR
|
|
|
|
|
if (fd < 0) {
|
|
|
|
|
if (errno == EAGAIN || errno == EBUSY)
|
|
|
|
|
return fd;
|
|
|
|
|
if (! access(filename, F_OK))
|
|
|
|
|
fd = rsm_open_device(filename, fmode);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2005-02-11 16:35:24 +00:00
|
|
|
if (fd >= 0)
|
2009-11-07 21:29:23 +02:00
|
|
|
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
|
|
|
|
return fd;
|
2005-02-11 16:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-11-30 18:26:13 +01:00
|
|
|
/* make local functions really local */
|
|
|
|
|
#define snd_dlobj_cache_lookup \
|
|
|
|
|
snd1_dlobj_cache_lookup
|
|
|
|
|
#define snd_dlobj_cache_add \
|
|
|
|
|
snd1_dlobj_cache_add
|
|
|
|
|
#define snd_dlobj_cache_cleanup \
|
|
|
|
|
snd1_dlobj_cache_cleanup
|
|
|
|
|
#define snd_config_set_hop \
|
|
|
|
|
snd1_config_set_hop
|
|
|
|
|
#define snd_config_check_hop \
|
|
|
|
|
snd1_config_check_hop
|
|
|
|
|
#define snd_config_search_alias_hooks \
|
|
|
|
|
snd1_config_search_alias_hooks
|
|
|
|
|
|
2005-02-14 15:09:09 +00:00
|
|
|
/* dlobj cache */
|
|
|
|
|
void *snd_dlobj_cache_lookup(const char *name);
|
|
|
|
|
int snd_dlobj_cache_add(const char *name, void *dlobj, void *open_func);
|
|
|
|
|
void snd_dlobj_cache_cleanup(void);
|
|
|
|
|
|
2006-01-30 14:41:51 +00:00
|
|
|
/* for recursive checks */
|
|
|
|
|
void snd_config_set_hop(snd_config_t *conf, int hop);
|
|
|
|
|
int snd_config_check_hop(snd_config_t *conf);
|
|
|
|
|
#define SND_CONF_MAX_HOPS 64
|
|
|
|
|
|
2006-10-11 13:18:57 +02:00
|
|
|
int snd_config_search_alias_hooks(snd_config_t *config,
|
|
|
|
|
const char *base, const char *key,
|
|
|
|
|
snd_config_t **result);
|
|
|
|
|
|
2001-02-06 23:48:10 +00:00
|
|
|
#endif
|