Merge branch 'master' into update-upstream

This commit is contained in:
Jochem van Grondelle 2025-11-08 20:39:04 +07:00 committed by GitHub
commit 00b5d9d8c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
183 changed files with 4482 additions and 3930 deletions

View file

@ -50,7 +50,7 @@ char *command;
fprintf(stderr, ##args); \
putc('\n', stderr); \
} while (0)
#endif
#endif
#define SYSERROR(string) ERROR(string ": %s", strerror(errno))
@ -67,7 +67,7 @@ static int make_local_socket(const char *filename)
SYSERROR("socket failed");
return result;
}
unlink(filename);
addr->sun_family = AF_LOCAL;
@ -94,7 +94,7 @@ static int make_inet_socket(int port)
SYSERROR("socket failed");
return result;
}
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
@ -329,7 +329,7 @@ static int pcm_shm_close(client_t *client)
}
err = snd_pcm_close(client->device.pcm.handle);
ctrl->result = err;
if (err < 0)
if (err < 0)
ERROR("snd_pcm_close");
if (client->transport.shm.ctrl) {
err = shmdt((void *)client->transport.shm.ctrl);
@ -592,7 +592,7 @@ static int ctl_shm_close(client_t *client)
}
err = snd_ctl_close(client->device.ctl.handle);
ctrl->result = err;
if (err < 0)
if (err < 0)
ERROR("snd_ctl_close");
if (client->transport.shm.ctrl) {
err = shmdt((void *)client->transport.shm.ctrl);
@ -1005,7 +1005,7 @@ static int server(const char *sockname, int port)
free(waiters);
return result;
}
static void usage(void)
{
@ -1056,7 +1056,7 @@ int main(int argc, char **argv)
return 1;
}
if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid type for server %s definition", srvname);
snd_error(ASERVER, "Invalid type for server %s definition", srvname);
return -EINVAL;
}
snd_config_for_each(i, next, conf) {

View file

@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(alsa-lib, 1.2.14)
AC_INIT(alsa-lib, 1.2.15pre1)
AC_CONFIG_SRCDIR([src/control/control.c])
AC_CONFIG_MACRO_DIR([m4])

View file

@ -16,6 +16,7 @@ INPUT = @top_srcdir@/doc/index.doxygen \
@top_srcdir@/include/conf.h \
@top_srcdir@/include/control.h \
@top_srcdir@/include/pcm.h \
@top_srcdir@/include/pcm_plugin.h \
@top_srcdir@/include/rawmidi.h \
@top_srcdir@/include/ump.h \
@top_srcdir@/include/ump_msg.h \
@ -127,7 +128,7 @@ INHERIT_DOCS = YES
ENABLED_SECTIONS = ""
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
PREDEFINED = DOXYGEN PIC "DOC_HIDDEN" \
PREDEFINED = DOXYGEN PIC "DOC_HIDDEN" "ALSA_LIBRARY_BUILD" \
"ATTRIBUTE_UNUSED=" \
ALSA_PCM_NEW_HW_PARAMS_API \
_POSIX_C_SOURCE \
@ -140,5 +141,3 @@ TYPEDEF_HIDES_STRUCT = YES # needed in doxygen >= 1.5.4
#INPUT_FILTER = inputfilter
#FILTER_SOURCE_FILES = YES
HTML_TIMESTAMP = NO

View file

@ -56,8 +56,8 @@
#define use_symbol_version(real, name, version) /* nothing */
#if defined(__alpha__) || defined(__mips__)
#define use_default_symbol_version(real, name, version) \
__asm__ (".weak " ASM_NAME(#name)); \
__asm__ (ASM_NAME(#name) " = " ASM_NAME(#real))
__asm__ (".weak " ASM_NAME(#name)); \
__asm__ (ASM_NAME(#name) " = " ASM_NAME(#real))
#else
#define use_default_symbol_version(real, name, version) \
__asm__ (".weak " ASM_NAME(#name)); \

View file

@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "../src/pcm/pcm_local.h"
#include "../src/control/control_local.h"
#include <netdb.h>
@ -106,7 +106,7 @@ typedef struct {
} snd_pcm_shm_ctrl_t;
#define PCM_SHM_SIZE sizeof(snd_pcm_shm_ctrl_t)
#define SND_CTL_IOCTL_READ _IOR('U', 0xf1, snd_ctl_event_t)
#define SND_CTL_IOCTL_CLOSE _IO ('U', 0xf2)
#define SND_CTL_IOCTL_POLL_DESCRIPTOR _IO ('U', 0xf3)

View file

@ -32,7 +32,7 @@
#endif
#ifndef __ALSA_ASOUNDEF_H
#define __ALSA_ASOUNDEF_H
#define __ALSA_ASOUNDEF_H /**< header include loop protection */
#ifdef __cplusplus
extern "C" {

View file

@ -31,7 +31,7 @@
#endif
#ifndef __ALSA_CONF_H
#define __ALSA_CONF_H
#define __ALSA_CONF_H /**< header include loop protection */
#ifdef __cplusplus
extern "C" {
@ -52,15 +52,15 @@ extern "C" {
/** \brief Configuration node type. */
typedef enum _snd_config_type {
/** Integer number. */
SND_CONFIG_TYPE_INTEGER,
SND_CONFIG_TYPE_INTEGER,
/** 64-bit integer number. */
SND_CONFIG_TYPE_INTEGER64,
SND_CONFIG_TYPE_INTEGER64,
/** Real number. */
SND_CONFIG_TYPE_REAL,
SND_CONFIG_TYPE_REAL,
/** Character string. */
SND_CONFIG_TYPE_STRING,
/** Pointer (runtime only, cannot be saved). */
SND_CONFIG_TYPE_POINTER,
SND_CONFIG_TYPE_STRING,
/** Pointer (runtime only, cannot be saved). */
SND_CONFIG_TYPE_POINTER,
/** Compound node. */
SND_CONFIG_TYPE_COMPOUND = 1024
} snd_config_type_t;
@ -108,7 +108,7 @@ void snd_config_unref(snd_config_t *top);
int snd_config_search(snd_config_t *config, const char *key,
snd_config_t **result);
int snd_config_searchv(snd_config_t *config,
int snd_config_searchv(snd_config_t *config,
snd_config_t **result, ...);
int snd_config_search_definition(snd_config_t *config,
const char *base, const char *key,
@ -122,7 +122,7 @@ int snd_config_search_definition(snd_config_t *config,
* \param[in] private_data Handle to the \c private_data node.
* \return A non-negative value if successful, otherwise a negative error code.
*
* Use a function of this type to define a custom expansion
* Use a function of this type to define a custom expansion
*/
typedef int (*snd_config_expand_fcn_t)(snd_config_t **dst, const char *s, void *private_data);

View file

@ -32,7 +32,7 @@
#endif
#ifndef __ALSA_CONTROL_H
#define __ALSA_CONTROL_H
#define __ALSA_CONTROL_H /**< header include loop protection */
#ifdef __cplusplus
extern "C" {
@ -386,7 +386,7 @@ int snd_ctl_open_fallback(snd_ctl_t **ctl, snd_config_t *root, const char *name,
int snd_ctl_close(snd_ctl_t *ctl);
int snd_ctl_nonblock(snd_ctl_t *ctl, int nonblock);
static __inline__ int snd_ctl_abort(snd_ctl_t *ctl) { return snd_ctl_nonblock(ctl, 2); }
int snd_async_add_ctl_handler(snd_async_handler_t **handler, snd_ctl_t *ctl,
int snd_async_add_ctl_handler(snd_async_handler_t **handler, snd_ctl_t *ctl,
snd_async_callback_t callback, void *private_data);
snd_ctl_t *snd_async_handler_get_ctl(snd_async_handler_t *handler);
int snd_ctl_poll_descriptors_count(snd_ctl_t *ctl);
@ -718,7 +718,7 @@ typedef int (*snd_hctl_compare_t)(const snd_hctl_elem_t *e1,
const snd_hctl_elem_t *e2);
int snd_hctl_compare_fast(const snd_hctl_elem_t *c1,
const snd_hctl_elem_t *c2);
/**
/**
* \brief HCTL callback function
* \param hctl HCTL handle
* \param mask event mask
@ -728,7 +728,7 @@ int snd_hctl_compare_fast(const snd_hctl_elem_t *c1,
typedef int (*snd_hctl_callback_t)(snd_hctl_t *hctl,
unsigned int mask,
snd_hctl_elem_t *elem);
/**
/**
* \brief HCTL element callback function
* \param elem HCTL element
* \param mask event mask

View file

@ -32,7 +32,7 @@
#endif
#ifndef __ALSA_ERROR_H
#define __ALSA_ERROR_H
#define __ALSA_ERROR_H /**< header include loop protection */
#ifdef __cplusplus
extern "C" {
@ -49,42 +49,108 @@ extern "C" {
const char *snd_strerror(int errnum);
#define SND_LOG_ERROR 1 /**< error priority level */
#define SND_LOG_WARN 2 /**< warning priority level */
#define SND_LOG_INFO 3 /**< info priority level */
#define SND_LOG_DEBUG 4 /**< debug priority level */
#define SND_LOG_TRACE 5 /**< trace priority level */
#define SND_LOG_LAST SND_LOG_TRACE /**< last known value for priority level */
#define SND_ILOG_CORE 1 /**< core library code */
#define SND_ILOG_CONFIG 2 /**< configuration parsing and operations */
#define SND_ILOG_CONTROL 3 /**< control API */
#define SND_ILOG_HWDEP 4 /**< hwdep API */
#define SND_ILOG_TIMER 5 /**< timer API */
#define SND_ILOG_RAWMIDI 6 /**< RawMidi API */
#define SND_ILOG_PCM 7 /**< PCM API */
#define SND_ILOG_MIXER 8 /**< mixer API */
#define SND_ILOG_SEQUENCER 9 /**< sequencer API */
#define SND_ILOG_UCM 10 /**< UCM API */
#define SND_ILOG_TOPOLOGY 11 /**< topology API */
#define SND_ILOG_ASERVER 12 /**< aserver */
#define SND_ILOG_LAST SND_ILOG_ASERVER /**< last known value for interface */
/**
* \brief Error handler callback.
* \brief Log handler callback.
* \param prio Priority (SND_LOG_* defines).
* \param interface Interface (SND_ILOG_* defines).
* \param file Source file name.
* \param line Line number.
* \param function Function name.
* \param err Value of \c errno, or 0 if not relevant.
* \param errcode Value of \c errno, or 0 if not relevant.
* \param fmt \c printf(3) format.
* \param ... \c printf(3) arguments.
*
* A function of this type is called by the ALSA library when an error occurs.
* This function usually shows the message on the screen, and/or logs it.
*/
typedef void (*snd_lib_error_handler_t)(const char *file, int line, const char *function, int err, const char *fmt, ...) /* __attribute__ ((format (printf, 5, 6))) */;
extern snd_lib_error_handler_t snd_lib_error;
extern int snd_lib_error_set_handler(snd_lib_error_handler_t handler);
typedef void (*snd_lib_log_handler_t)(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg);
extern snd_lib_log_handler_t snd_lib_vlog;
int snd_lib_log_filter(int prio, int interface, const char *configstr);
void snd_lib_log(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...) /* __attribute__ ((format (printf, 7, 8))) */;
void snd_lib_check(int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...);
snd_lib_log_handler_t snd_lib_log_set_handler(snd_lib_log_handler_t handler);
snd_lib_log_handler_t snd_lib_log_set_local(snd_lib_log_handler_t handler);
const char *snd_lib_log_priority(int prio);
const char *snd_lib_log_interface(int interface);
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
#define SNDERR(...) snd_lib_error(__FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows a sound error message. */
#define SYSERR(...) snd_lib_error(__FILE__, __LINE__, __func__, errno, __VA_ARGS__) /**< Shows a system error message (related to \c errno). */
#define snd_error(interface, ...) snd_lib_log(SND_LOG_ERROR, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows an error log message. */
#define snd_errornum(interface, ...) snd_lib_log(SND_LOG_ERROR, SND_ILOG_##interface, __FILE__, __LINE__, __func__, errno, __VA_ARGS__) /**< Shows a system error log message (related to \c errno). */
#define snd_warn(interface, ...) snd_lib_log(SND_LOG_WARN, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows an error log message. */
#define snd_info(interface, ...) snd_lib_log(SND_LOG_INFO, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows an informational log message. */
#define snd_debug(interface, ...) snd_lib_log(SND_LOG_DEBUG, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows an debug log message. */
#define snd_trace(interface, ...) snd_lib_log(SND_LOG_TRACE, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows an trace log message. */
#define snd_check(interface, ...) snd_lib_check(SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows an check log message. */
#define snd_checknum(interface, ...) snd_lib_check(SND_ILOG_##interface, __FILE__, __LINE__, __func__, errno, __VA_ARGS__) /**< Shows an check log message (related to \c errno). */
#else
#define SNDERR(args...) snd_lib_error(__FILE__, __LINE__, __func__, 0, ##args) /**< Shows a sound error message. */
#define SYSERR(args...) snd_lib_error(__FILE__, __LINE__, __func__, errno, ##args) /**< Shows a system error message (related to \c errno). */
#define snd_error(interface, args...) snd_lib_log(SND_LOG_ERROR, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows an error log message. */
#define snd_errornum(interface, args...) snd_lib_log(SND_LOG_ERROR, SND_ILOG_##interface, __FILE__, __LINE__, __func__, errno, ##args) /**< Shows a system error log message (related to \c errno). */
#define snd_warn(interface, args...) snd_lib_log(SND_LOG_WARN, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows an error log message. */
#define snd_info(interface, args...) snd_lib_log(SND_LOG_INFO, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows an error log message. */
#define snd_debug(interface, args...) snd_lib_log(SND_LOG_DEBUG, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows an error log message. */
#define snd_trace(interface, args...) snd_lib_log(SND_LOG_TRACE, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows an trace log message. */
#define snd_check(interface, args...) snd_lib_check(SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows an check log message. */
#define snd_check(interface, args...) snd_lib_check(SND_ILOG_##interface, __FILE__, __LINE__, __func__, errno, ##args) /**< Shows an check log message (related to \c errno). */
#endif
/**
* \brief Error handler callback.
* \param file Source file name.
* \param line Line number.
* \param function Function name.
* \param errcode Value of \c errno, or 0 if not relevant.
* \param fmt \c printf(3) format.
* \param ... \c printf(3) arguments.
* \deprecated Since 1.2.15
*
* A function of this type is called by the ALSA library when an error occurs.
* This function usually shows the message on the screen, and/or logs it.
*/
typedef void (*snd_lib_error_handler_t)(const char *file, int line, const char *function, int errcode, const char *fmt, ...) /* __attribute__ ((format (printf, 5, 6))) */;
extern snd_lib_error_handler_t snd_lib_error;
int snd_lib_error_set_handler(snd_lib_error_handler_t handler);
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
#define SNDERR(...) snd_lib_log(SND_LOG_ERROR, 0, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows a sound error message. */
#define SYSERR(...) snd_lib_log(SND_LOG_ERROR, 0, __FILE__, __LINE__, __func__, errno, __VA_ARGS__) /**< Shows a system error message (related to \c errno). */
#else
#define SNDERR(args...) snd_lib_log(SND_LOG_ERROR, 0, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows a sound error message. */
#define SYSERR(args...) snd_lib_log(SND_LOG_ERROR, 0, __FILE__, __LINE__, __func__, errno, ##args) /**< Shows a system error message (related to \c errno). */
#endif
/** Local error handler function type */
typedef void (*snd_local_error_handler_t)(const char *file, int line,
const char *func, int errcode,
const char *fmt, va_list arg);
snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func);
/** \} */
#ifdef __cplusplus
}
#endif
/** Local error handler function type */
typedef void (*snd_local_error_handler_t)(const char *file, int line,
const char *func, int err,
const char *fmt, va_list arg);
snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func);
#endif /* __ALSA_ERROR_H */

View file

@ -32,7 +32,7 @@
#endif
#ifndef __ALSA_GLOBAL_H_
#define __ALSA_GLOBAL_H_
#define __ALSA_GLOBAL_H_ /**< header include loop protection */
#ifdef __cplusplus
extern "C" {
@ -124,7 +124,7 @@ typedef struct _snd_async_handler snd_async_handler_t;
*/
typedef void (*snd_async_callback_t)(snd_async_handler_t *handler);
int snd_async_add_handler(snd_async_handler_t **handler, int fd,
int snd_async_add_handler(snd_async_handler_t **handler, int fd,
snd_async_callback_t callback, void *private_data);
int snd_async_del_handler(snd_async_handler_t *handler);
int snd_async_handler_get_fd(snd_async_handler_t *handler);

View file

@ -32,7 +32,7 @@
#endif
#ifndef __ALSA_HWDEP_H
#define __ALSA_HWDEP_H
#define __ALSA_HWDEP_H /**< header include loop protection */
#ifdef __cplusplus
extern "C" {

View file

@ -274,13 +274,8 @@ size_t snd_strlcat(char *dst, const char *src, size_t size);
*/
#ifndef NDEBUG
#define CHECK_SANITY(x) x
extern snd_lib_error_handler_t snd_err_msg;
#define SNDMSG(args...) snd_err_msg(__FILE__, __LINE__, __func__, 0, ##args)
#define SYSMSG(args...) snd_err_msg(__FILE__, __LINE__, __func__, errno, ##args)
#else
#define CHECK_SANITY(x) 0 /* not evaluated */
#define SNDMSG(args...) /* nop */
#define SYSMSG(args...) /* nop */
#endif
/*
@ -386,7 +381,7 @@ int snd_config_check_hop(snd_config_t *conf);
#define SND_CONF_MAX_HOPS 64
int snd_config_search_alias_hooks(snd_config_t *config,
const char *base, const char *key,
const char *base, const char *key,
snd_config_t **result);
int _snd_conf_generic_id(const char *id);

View file

@ -32,7 +32,7 @@
#endif
#ifndef __ALSA_MIXER_H
#define __ALSA_MIXER_H
#define __ALSA_MIXER_H /**< header include loop protection */
#ifdef __cplusplus
extern "C" {
@ -51,7 +51,7 @@ typedef struct _snd_mixer_class snd_mixer_class_t;
/** Mixer element handle */
typedef struct _snd_mixer_elem snd_mixer_elem_t;
/**
/**
* \brief Mixer callback function
* \param ctl Mixer handle
* \param mask event mask
@ -62,7 +62,7 @@ typedef int (*snd_mixer_callback_t)(snd_mixer_t *ctl,
unsigned int mask,
snd_mixer_elem_t *elem);
/**
/**
* \brief Mixer element callback function
* \param elem Mixer element
* \param mask event mask
@ -276,17 +276,17 @@ int snd_mixer_selem_set_playback_switch(snd_mixer_elem_t *elem, snd_mixer_selem_
int snd_mixer_selem_set_capture_switch(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, int value);
int snd_mixer_selem_set_playback_switch_all(snd_mixer_elem_t *elem, int value);
int snd_mixer_selem_set_capture_switch_all(snd_mixer_elem_t *elem, int value);
int snd_mixer_selem_get_playback_volume_range(snd_mixer_elem_t *elem,
int snd_mixer_selem_get_playback_volume_range(snd_mixer_elem_t *elem,
long *min, long *max);
int snd_mixer_selem_get_playback_dB_range(snd_mixer_elem_t *elem,
int snd_mixer_selem_get_playback_dB_range(snd_mixer_elem_t *elem,
long *min, long *max);
int snd_mixer_selem_set_playback_volume_range(snd_mixer_elem_t *elem,
int snd_mixer_selem_set_playback_volume_range(snd_mixer_elem_t *elem,
long min, long max);
int snd_mixer_selem_get_capture_volume_range(snd_mixer_elem_t *elem,
int snd_mixer_selem_get_capture_volume_range(snd_mixer_elem_t *elem,
long *min, long *max);
int snd_mixer_selem_get_capture_dB_range(snd_mixer_elem_t *elem,
int snd_mixer_selem_get_capture_dB_range(snd_mixer_elem_t *elem,
long *min, long *max);
int snd_mixer_selem_set_capture_volume_range(snd_mixer_elem_t *elem,
int snd_mixer_selem_set_capture_volume_range(snd_mixer_elem_t *elem,
long min, long max);
int snd_mixer_selem_is_enumerated(snd_mixer_elem_t *elem);

View file

@ -43,11 +43,11 @@ extern "C" {
#define SM_CAP_GSWITCH (1<<2)
#define SM_CAP_PVOLUME (1<<3)
#define SM_CAP_PVOLUME_JOIN (1<<4)
#define SM_CAP_PSWITCH (1<<5)
#define SM_CAP_PSWITCH_JOIN (1<<6)
#define SM_CAP_CVOLUME (1<<7)
#define SM_CAP_CVOLUME_JOIN (1<<8)
#define SM_CAP_CSWITCH (1<<9)
#define SM_CAP_PSWITCH (1<<5)
#define SM_CAP_PSWITCH_JOIN (1<<6)
#define SM_CAP_CVOLUME (1<<7)
#define SM_CAP_CVOLUME_JOIN (1<<8)
#define SM_CAP_CSWITCH (1<<9)
#define SM_CAP_CSWITCH_JOIN (1<<10)
#define SM_CAP_CSWITCH_EXCL (1<<11)
#define SM_CAP_PENUM (1<<12)
@ -77,7 +77,7 @@ typedef struct _sm_class_basic {
snd_ctl_card_info_t *info;
} sm_class_basic_t;
struct sm_elem_ops {
struct sm_elem_ops {
int (*is)(snd_mixer_elem_t *elem, int dir, int cmd, int val);
int (*get_range)(snd_mixer_elem_t *elem, int dir, long *min, long *max);
int (*set_range)(snd_mixer_elem_t *elem, int dir, long min, long max);

View file

@ -33,7 +33,7 @@
#endif
#ifndef __ALSA_PCM_H
#define __ALSA_PCM_H
#define __ALSA_PCM_H /**< header include loop protection */
#ifdef __cplusplus
extern "C" {
@ -303,7 +303,7 @@ typedef enum _snd_pcm_subformat {
typedef enum _snd_pcm_state {
/** Open */
SND_PCM_STATE_OPEN = 0,
/** Setup installed */
/** Setup installed */
SND_PCM_STATE_SETUP,
/** Ready to start */
SND_PCM_STATE_PREPARED,
@ -525,9 +525,9 @@ typedef union _snd_pcm_sync_id {
/** #SND_PCM_TYPE_METER scope handle */
typedef struct _snd_pcm_scope snd_pcm_scope_t;
int snd_pcm_open(snd_pcm_t **pcm, const char *name,
int snd_pcm_open(snd_pcm_t **pcm, const char *name,
snd_pcm_stream_t stream, int mode);
int snd_pcm_open_lconf(snd_pcm_t **pcm, const char *name,
int snd_pcm_open_lconf(snd_pcm_t **pcm, const char *name,
snd_pcm_stream_t stream, int mode,
snd_config_t *lconf);
int snd_pcm_open_fallback(snd_pcm_t **pcm, snd_config_t *root,
@ -543,7 +543,7 @@ int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int s
int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock);
static __inline__ int snd_pcm_abort(snd_pcm_t *pcm) { return snd_pcm_nonblock(pcm, 2); }
int snd_async_add_pcm_handler(snd_async_handler_t **handler, snd_pcm_t *pcm,
int snd_async_add_pcm_handler(snd_async_handler_t **handler, snd_pcm_t *pcm,
snd_async_callback_t callback, void *private_data);
snd_pcm_t *snd_async_handler_get_pcm(snd_async_handler_t *handler);
int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info);
@ -679,15 +679,15 @@ snd_pcm_chmap_t *snd_pcm_chmap_parse_string(const char *str);
int snd_pcm_recover(snd_pcm_t *pcm, int err, int silent);
int snd_pcm_set_params(snd_pcm_t *pcm,
snd_pcm_format_t format,
snd_pcm_access_t access,
unsigned int channels,
unsigned int rate,
int soft_resample,
unsigned int latency);
snd_pcm_format_t format,
snd_pcm_access_t access,
unsigned int channels,
unsigned int rate,
int soft_resample,
unsigned int latency);
int snd_pcm_get_params(snd_pcm_t *pcm,
snd_pcm_uframes_t *buffer_size,
snd_pcm_uframes_t *period_size);
snd_pcm_uframes_t *buffer_size,
snd_pcm_uframes_t *period_size);
/** \} */
@ -1149,7 +1149,7 @@ snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t *pcm,
snd_pcm_sframes_t snd_pcm_mmap_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
snd_pcm_sframes_t snd_pcm_mmap_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
snd_pcm_sframes_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
snd_pcm_sframes_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
snd_pcm_sframes_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
/** \} */
@ -1326,7 +1326,7 @@ int16_t *snd_pcm_scope_s16_get_channel_buffer(snd_pcm_scope_t *scope,
/** Simple PCM latency type */
typedef enum _snd_spcm_latency {
/** standard latency - for standard playback or capture
(estimated latency in one direction 350ms) */
(estimated latency in one direction 350ms) */
SND_SPCM_LATENCY_STANDARD = 0,
/** medium latency - software phones etc.
(estimated latency in one direction maximally 25ms */

View file

@ -34,7 +34,7 @@
#endif
#ifndef __ALSA_PCM_EXTPLUG_H
#define __ALSA_PCM_EXTPLUG_H
#define __ALSA_PCM_EXTPLUG_H /**< header include loop protection */
/**
* \defgroup PCM_ExtPlug External Filter plugin SDK
@ -49,7 +49,7 @@ enum {
SND_PCM_EXTPLUG_HW_CHANNELS, /**< channels */
SND_PCM_EXTPLUG_HW_PARAMS /**< max number of hw constraints */
};
/** Handle of external filter plugin */
typedef struct snd_pcm_extplug snd_pcm_extplug_t;
/** Callback table of extplug */

View file

@ -34,7 +34,7 @@
#endif
#ifndef __ALSA_PCM_IOPLUG_H
#define __ALSA_PCM_IOPLUG_H
#define __ALSA_PCM_IOPLUG_H /**< header include loop protection */
/**
* \defgroup PCM_IOPlug External I/O plugin SDK
@ -54,7 +54,7 @@ enum {
SND_PCM_IOPLUG_HW_PERIODS, /**< number of periods */
SND_PCM_IOPLUG_HW_PARAMS /**< max number of hw constraints */
};
/** I/O plugin handle */
typedef struct snd_pcm_ioplug snd_pcm_ioplug_t;
/** Callback table of ioplug */
@ -114,7 +114,7 @@ struct snd_pcm_ioplug {
*/
snd_pcm_t *pcm;
snd_pcm_stream_t stream; /**< stream direcion; read-only */
snd_pcm_stream_t stream; /**< stream direcion; read-only */
snd_pcm_state_t state; /**< current PCM state; read-only */
volatile snd_pcm_uframes_t appl_ptr; /**< application pointer; read-only */
volatile snd_pcm_uframes_t hw_ptr; /**< hw pointer; read-only */

View file

@ -38,7 +38,7 @@
* See the \ref pcm_plugins page for more details.
* \{
*/
#define SND_PCM_PLUGIN_RATE_MIN 4000 /**< minimal rate for the rate plugin */
#define SND_PCM_PLUGIN_RATE_MAX 768000 /**< maximal rate for the rate plugin */
@ -81,8 +81,8 @@ int snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_t *slave, int close_slave);
int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *root, snd_config_t *conf,
snd_pcm_stream_t stream, int mode);
snd_pcm_stream_t stream, int mode);
/*
* Linear conversion plugin
*/
@ -111,7 +111,7 @@ int snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name,
int close_slave);
int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *root, snd_config_t *conf,
snd_pcm_stream_t stream, int mode);
snd_pcm_stream_t stream, int mode);
/*
* Linear<->a-Law conversion plugin
@ -202,13 +202,37 @@ int _snd_pcm_ladspa_open(snd_pcm_t **pcmp, const char *name,
/*
* Jack plugin
*/
/**
* \brief Creates a new Jack PCM
* \param pcmp Returns created PCM handle
* \param name Name of PCM
* \param playback_conf Playback configuration
* \param capture_conf Capture configuration
* \param stream Stream direction
* \param mode PCM open mode
* \retval zero on success otherwise a negative error code
* \warning alsa-lib must be compiled against the JACK library for this plugin to be available
*/
int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *playback_conf,
snd_config_t *capture_conf,
snd_pcm_stream_t stream, int mode);
/**
* \brief Creates a new Jack PCM (internal)
* \param pcmp Returns created PCM handle
* \param name Name of PCM
* \param root Root configuration node
* \param conf Configuration for this PCM
* \param stream Stream direction
* \param mode PCM open mode
* \retval zero on success otherwise a negative error code
* \warning alsa-lib must be compiled against the JACK library for this plugin to be available
*/
int _snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *root, snd_config_t *conf,
snd_pcm_stream_t stream, int mode);
snd_config_t *root, snd_config_t *conf,
snd_pcm_stream_t stream, int mode);
/** \} */

View file

@ -32,7 +32,7 @@
#endif
#ifndef __ALSA_RAWMIDI_H
#define __ALSA_RAWMIDI_H
#define __ALSA_RAWMIDI_H /**< header include loop protection */
#ifdef __cplusplus
extern "C" {
@ -101,7 +101,10 @@ typedef enum _snd_rawmidi_read_mode {
/** rawmidi info bit flags */
#define SND_RAWMIDI_INFO_UMP 0x00000008 /**< rawmidi is UMP */
#define SNDRV_RAWMIDI_INFO_STREAM_INACTIVE 0x00000010 /**< the selected substream is inactive */
#define SND_RAWMIDI_INFO_STREAM_INACTIVE 0x00000010 /**< the selected substream is inactive */
#ifndef SNDRV_RAWMIDI_INFO_STREAM_INACTIVE
#define SNDRV_RAWMIDI_INFO_STREAM_INACTIVE SND_RAWMIDI_INFO_STREAM_INACTIVE /**< compatibility alias for SND_RAWMIDI_INFO_STREAM_INACTIVE */
#endif
int snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi,
const char *name, int mode);

View file

@ -33,7 +33,7 @@
#endif
#ifndef __ALSA_SEQ_H
#define __ALSA_SEQ_H
#define __ALSA_SEQ_H /**< header include loop protection */
#ifdef __cplusplus
extern "C" {
@ -135,7 +135,7 @@ typedef enum snd_seq_client_type {
SND_SEQ_USER_CLIENT = 1, /**< user client */
SND_SEQ_KERNEL_CLIENT = 2 /**< kernel client */
} snd_seq_client_type_t;
/** client MIDI version */
enum {
SND_SEQ_CLIENT_LEGACY_MIDI = 0, /**< Legacy client */

View file

@ -32,7 +32,7 @@
#endif
#ifndef __ALSA_SEQ_EVENT_H
#define __ALSA_SEQ_EVENT_H
#define __ALSA_SEQ_EVENT_H /**< header include loop protection */
/**
* \defgroup SeqEvents Sequencer Event Definitions
@ -61,7 +61,7 @@ enum snd_seq_event_type {
SND_SEQ_EVENT_NOTEOFF,
/** key pressure change (aftertouch); event data type = #snd_seq_ev_note_t */
SND_SEQ_EVENT_KEYPRESS,
/** controller; event data type = #snd_seq_ev_ctrl_t */
SND_SEQ_EVENT_CONTROLLER = 10,
/** program change; event data type = #snd_seq_ev_ctrl_t */
@ -87,7 +87,7 @@ enum snd_seq_event_type {
SND_SEQ_EVENT_TIMESIGN,
/** SMF Key Signature event; event data type = #snd_seq_ev_ctrl_t */
SND_SEQ_EVENT_KEYSIGN,
/** MIDI Real Time Start message; event data type = #snd_seq_ev_queue_control_t */
SND_SEQ_EVENT_START = 30,
/** MIDI Real Time Continue message; event data type = #snd_seq_ev_queue_control_t */
@ -329,7 +329,7 @@ typedef struct snd_seq_event {
snd_seq_event_type_t type; /**< event type */
unsigned char flags; /**< event flags */
unsigned char tag; /**< tag */
unsigned char queue; /**< schedule queue */
snd_seq_timestamp_t time; /**< schedule time */

View file

@ -32,7 +32,7 @@
#endif
#ifndef __ALSA_SEQMID_H
#define __ALSA_SEQMID_H
#define __ALSA_SEQMID_H /**< header include loop protection */
#ifdef __cplusplus
extern "C" {
@ -48,7 +48,7 @@ extern "C" {
/**
* \brief initialize event record
* \param ev event record pointer
*
*
* This macro clears the given event record pointer to the default status.
*/
static inline void snd_seq_ev_clear(snd_seq_event_t *ev)
@ -130,7 +130,7 @@ static inline void snd_seq_ump_ev_clear(snd_seq_ump_event_t *ev)
*
* This macro sets the event to the direct passing mode
* to be delivered immediately without queueing.
*
*
* \sa snd_seq_ev_schedule_tick(), snd_seq_ev_schedule_real()
*/
#define snd_seq_ev_set_direct(ev) \

View file

@ -29,7 +29,7 @@
#define SNDRV_SEQ_EVENT_NOTEON 6
#define SNDRV_SEQ_EVENT_NOTEOFF 7
#define SNDRV_SEQ_EVENT_KEYPRESS 8
/** control messages (channel specific)
* event data type = #snd_seq_ev_ctrl
*/
@ -49,13 +49,13 @@
#define SNDRV_SEQ_EVENT_QFRAME 22 /* midi time code quarter frame */
#define SNDRV_SEQ_EVENT_TIMESIGN 23 /* SMF Time Signature event */
#define SNDRV_SEQ_EVENT_KEYSIGN 24 /* SMF Key Signature event */
/** timer messages
* event data type = snd_seq_ev_queue_control
*/
#define SNDRV_SEQ_EVENT_START 30 /* midi Real Time Start message */
#define SNDRV_SEQ_EVENT_CONTINUE 31 /* midi Real Time Continue message */
#define SNDRV_SEQ_EVENT_STOP 32 /* midi Real Time Stop message */
#define SNDRV_SEQ_EVENT_STOP 32 /* midi Real Time Stop message */
#define SNDRV_SEQ_EVENT_SETPOS_TICK 33 /* set tick queue position */
#define SNDRV_SEQ_EVENT_SETPOS_TIME 34 /* set realtime queue position */
#define SNDRV_SEQ_EVENT_TEMPO 35 /* (SMF) Tempo event */
@ -282,7 +282,7 @@ struct snd_seq_event {
snd_seq_event_type_t type; /* event type */
unsigned char flags; /* event flags */
char tag;
unsigned char queue; /* schedule queue */
union snd_seq_timestamp time; /* schedule time */
@ -352,7 +352,7 @@ typedef int __bitwise snd_seq_client_type_t;
#define NO_CLIENT ((snd_seq_client_type_t) 0)
#define USER_CLIENT ((snd_seq_client_type_t) 1)
#define KERNEL_CLIENT ((snd_seq_client_type_t) 2)
/* event filter flags */
#define SNDRV_SEQ_FILTER_BROADCAST (1U<<0) /* accept broadcast messages */
#define SNDRV_SEQ_FILTER_MULTICAST (1U<<1) /* accept multicast messages */

View file

@ -409,7 +409,7 @@ struct snd_pcm_hw_params {
SNDRV_PCM_HW_PARAM_FIRST_MASK + 1];
struct snd_mask mres[5]; /* reserved masks */
struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL -
SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1];
SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1];
struct snd_interval ires[9]; /* reserved intervals */
unsigned int rmask; /* W: requested masks */
unsigned int cmask; /* R: changed masks */

View file

@ -188,7 +188,7 @@
#define A_EXTIN_SPDIF_CD_L 0x02 /* digital CD left */
#define A_EXTIN_SPDIF_CD_R 0x03 /* digital CD left */
#define A_EXTIN_OPT_SPDIF_L 0x04 /* audigy drive Optical SPDIF - left */
#define A_EXTIN_OPT_SPDIF_R 0x05 /* right */
#define A_EXTIN_OPT_SPDIF_R 0x05 /* right */
#define A_EXTIN_LINE2_L 0x08 /* audigy drive line2/mic2 - left */
#define A_EXTIN_LINE2_R 0x09 /* right */
#define A_EXTIN_ADC_L 0x0a /* Philips ADC - left */

View file

@ -4,7 +4,7 @@
/*
* Copyright (C) 2003 Thomas Charbonnel (thomas@undata.org)
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@ -65,7 +65,7 @@ struct hdsp_config_info {
unsigned char clock_source;
unsigned char autosync_ref;
unsigned char line_out;
unsigned char passthru;
unsigned char passthru;
unsigned char da_gain;
unsigned char ad_gain;
unsigned char phone_gain;

View file

@ -5,7 +5,7 @@
*
* SB16ASP/AWE32 CSP control
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.

View file

@ -32,7 +32,7 @@
#endif
#ifndef __ALSA_TIMER_H
#define __ALSA_TIMER_H
#define __ALSA_TIMER_H /**< header include loop protection */
#ifdef __cplusplus
extern "C" {
@ -99,13 +99,13 @@ typedef enum _snd_timer_event {
SND_TIMER_EVENT_MCONTINUE = SND_TIMER_EVENT_CONTINUE + 10,
SND_TIMER_EVENT_MPAUSE = SND_TIMER_EVENT_PAUSE + 10,
SND_TIMER_EVENT_MSUSPEND = SND_TIMER_EVENT_SUSPEND + 10,
SND_TIMER_EVENT_MRESUME = SND_TIMER_EVENT_RESUME + 10
SND_TIMER_EVENT_MRESUME = SND_TIMER_EVENT_RESUME + 10
} snd_timer_event_t;
/** timer read structure */
typedef struct _snd_timer_read {
unsigned int resolution; /**< tick resolution in nanoseconds */
unsigned int ticks; /**< count of happened ticks */
unsigned int ticks; /**< count of happened ticks */
} snd_timer_read_t;
/** timer tstamp + event read structure */

View file

@ -13,7 +13,7 @@
#endif
#ifndef __ALSA_UMP_H
#define __ALSA_UMP_H
#define __ALSA_UMP_H /**< header include loop protection */
#ifdef __cplusplus
extern "C" {

View file

@ -239,14 +239,14 @@ int snd_use_case_free_list(const char *list[], int items);
*
*/
int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr,
const char *identifier,
const char **list[]);
const char *identifier,
const char **list[]);
/**
* \brief Get current - string
* \param uc_mgr Use case manager
* \param identifier
* \param identifier
* \param value Value pointer
* \return Zero if success, otherwise a negative error code
*
@ -410,14 +410,14 @@ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr,
* increase latency.
*/
int snd_use_case_get(snd_use_case_mgr_t *uc_mgr,
const char *identifier,
const char **value);
const char *identifier,
const char **value);
/**
* \brief Get current - integer
* \param uc_mgr Use case manager
* \param identifier
* \param value result
* \param identifier
* \param value result
* \return Zero if success, otherwise a negative error code
*
* Known identifiers:
@ -456,8 +456,8 @@ int snd_use_case_geti(snd_use_case_mgr_t *uc_mgr,
* - check transmit sequence firstly
*/
int snd_use_case_set(snd_use_case_mgr_t *uc_mgr,
const char *identifier,
const char *value);
const char *identifier,
const char *value);
/**
* \brief Open and initialise use case core for sound card
@ -482,7 +482,7 @@ int snd_use_case_set(snd_use_case_mgr_t *uc_mgr,
* only one ALSA sound card in this case.
*/
int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr,
const char *card_name);
const char *card_name);
/**

View file

@ -75,7 +75,7 @@ int alsa_mixer_simple_init(snd_mixer_class_t *class)
{
struct bclass_base_ops *ops;
int err;
err = mixer_simple_basic_dlopen(class, &ops);
if (err < 0)
return 0;

View file

@ -76,7 +76,7 @@ int alsa_mixer_simple_init(snd_mixer_class_t *class)
{
struct bclass_base_ops *ops;
int err;
err = mixer_simple_basic_dlopen(class, &ops);
if (err < 0)
return 0;

View file

@ -68,24 +68,24 @@ static PyInterpreterState *main_interpreter;
static inline int get_long(PyObject *o, long *val)
{
#if PY_MAJOR_VERSION < 3
if (PyInt_Check(o)) {
*val = PyInt_AsLong(o);
return 0;
}
if (PyInt_Check(o)) {
*val = PyInt_AsLong(o);
return 0;
}
#endif
if (PyLong_Check(o)) {
*val = PyLong_AsLong(o);
return 0;
}
return 1;
if (PyLong_Check(o)) {
*val = PyLong_AsLong(o);
return 0;
}
return 1;
}
static inline PyObject *InternFromString(const char *name)
{
#if PY_MAJOR_VERSION < 3
return PyString_InternFromString(name);
return PyString_InternFromString(name);
#else
return PyUnicode_InternFromString(name);
return PyUnicode_InternFromString(name);
#endif
}
@ -191,12 +191,12 @@ static int is_ops(snd_mixer_elem_t *elem, int dir, int cmd, int val)
}
static int get_x_range_ops(snd_mixer_elem_t *elem, int dir,
long *min, long *max, const char *attr)
long *min, long *max, const char *attr)
{
PyObject *obj1, *t1, *t2, *res;
struct pymelem *pymelem = melem_to_pymelem(elem);
int err;
obj1 = PyTuple_New(1);
PyTuple_SET_ITEM(obj1, 0, PyInt_FromLong(dir));
err = pcall(pymelem, attr, obj1, &res);
@ -225,13 +225,13 @@ static int get_x_range_ops(snd_mixer_elem_t *elem, int dir,
}
static int get_range_ops(snd_mixer_elem_t *elem, int dir,
long *min, long *max)
long *min, long *max)
{
return get_x_range_ops(elem, dir, min, max, "opsGetRange");
}
static int set_range_ops(snd_mixer_elem_t *elem, int dir,
long min, long max)
long min, long max)
{
PyObject *obj1;
struct pymelem *pymelem = melem_to_pymelem(elem);
@ -244,13 +244,13 @@ static int set_range_ops(snd_mixer_elem_t *elem, int dir,
}
static int get_x_ops(snd_mixer_elem_t *elem, int dir,
long channel, long *value,
const char *attr)
long channel, long *value,
const char *attr)
{
PyObject *obj1, *t1, *res;
struct pymelem *pymelem = melem_to_pymelem(elem);
int err;
obj1 = PyTuple_New(2);
PyTuple_SET_ITEM(obj1, 0, PyInt_FromLong(dir));
PyTuple_SET_ITEM(obj1, 1, PyInt_FromLong(channel));
@ -283,7 +283,7 @@ static int get_volume_ops(snd_mixer_elem_t *elem, int dir,
}
static int get_switch_ops(snd_mixer_elem_t *elem, int dir,
snd_mixer_selem_channel_id_t channel, int *value)
snd_mixer_selem_channel_id_t channel, int *value)
{
long value1;
int res;
@ -309,7 +309,7 @@ static int ask_dB_vol_ops(snd_mixer_elem_t *elem,
PyObject *obj1, *t1, *res;
struct pymelem *pymelem = melem_to_pymelem(elem);
int err;
obj1 = PyTuple_New(3);
PyTuple_SET_ITEM(obj1, 0, PyInt_FromLong(dir));
PyTuple_SET_ITEM(obj1, 1, PyInt_FromLong(value));
@ -337,21 +337,21 @@ static int ask_dB_vol_ops(snd_mixer_elem_t *elem,
}
static int get_dB_ops(snd_mixer_elem_t *elem,
int dir,
snd_mixer_selem_channel_id_t channel,
long *value)
int dir,
snd_mixer_selem_channel_id_t channel,
long *value)
{
return get_x_ops(elem, dir, channel, value, "opsGetDB");
}
static int get_dB_range_ops(snd_mixer_elem_t *elem, int dir,
long *min, long *max)
long *min, long *max)
{
return get_x_range_ops(elem, dir, min, max, "opsGetDBRange");
}
static int set_volume_ops(snd_mixer_elem_t *elem, int dir,
snd_mixer_selem_channel_id_t channel, long value)
snd_mixer_selem_channel_id_t channel, long value)
{
PyObject *obj1;
struct pymelem *pymelem = melem_to_pymelem(elem);
@ -364,7 +364,7 @@ static int set_volume_ops(snd_mixer_elem_t *elem, int dir,
}
static int set_switch_ops(snd_mixer_elem_t *elem, int dir,
snd_mixer_selem_channel_id_t channel, int value)
snd_mixer_selem_channel_id_t channel, int value)
{
PyObject *obj1;
struct pymelem *pymelem = melem_to_pymelem(elem);
@ -377,8 +377,8 @@ static int set_switch_ops(snd_mixer_elem_t *elem, int dir,
}
static int set_dB_ops(snd_mixer_elem_t *elem, int dir,
snd_mixer_selem_channel_id_t channel,
long db_gain, int xdir)
snd_mixer_selem_channel_id_t channel,
long db_gain, int xdir)
{
PyObject *obj1;
struct pymelem *pymelem = melem_to_pymelem(elem);
@ -392,15 +392,15 @@ static int set_dB_ops(snd_mixer_elem_t *elem, int dir,
}
static int enum_item_name_ops(snd_mixer_elem_t *elem,
unsigned int item,
size_t maxlen, char *buf)
unsigned int item,
size_t maxlen, char *buf)
{
PyObject *obj1, *obj2, *t1, *res;
struct pymelem *pymelem = melem_to_pymelem(elem);
int err;
unsigned int len;
char *s;
obj1 = PyTuple_New(1);
PyTuple_SET_ITEM(obj1, 0, PyInt_FromLong(item));
err = pcall(pymelem, "opsGetEnumItemName", obj1, &res);
@ -441,13 +441,13 @@ errlbl:
}
static int get_enum_item_ops(snd_mixer_elem_t *elem,
snd_mixer_selem_channel_id_t channel,
unsigned int *itemp)
snd_mixer_selem_channel_id_t channel,
unsigned int *itemp)
{
PyObject *obj1, *t1, *res;
struct pymelem *pymelem = melem_to_pymelem(elem);
int err;
obj1 = PyTuple_New(1);
PyTuple_SET_ITEM(obj1, 0, PyInt_FromLong(channel));
err = pcall(pymelem, "opsGetEnumItem", obj1, &res);
@ -473,8 +473,8 @@ static int get_enum_item_ops(snd_mixer_elem_t *elem,
}
static int set_enum_item_ops(snd_mixer_elem_t *elem,
snd_mixer_selem_channel_id_t channel,
unsigned int item)
snd_mixer_selem_channel_id_t channel,
unsigned int item)
{
PyObject *obj1;
struct pymelem *pymelem = melem_to_pymelem(elem);
@ -486,21 +486,21 @@ static int set_enum_item_ops(snd_mixer_elem_t *elem,
}
static struct sm_elem_ops simple_python_ops = {
.is = is_ops,
.get_range = get_range_ops,
.get_dB_range = get_dB_range_ops,
.set_range = set_range_ops,
.ask_vol_dB = ask_vol_dB_ops,
.ask_dB_vol = ask_dB_vol_ops,
.get_volume = get_volume_ops,
.get_dB = get_dB_ops,
.set_volume = set_volume_ops,
.set_dB = set_dB_ops,
.get_switch = get_switch_ops,
.set_switch = set_switch_ops,
.enum_item_name = enum_item_name_ops,
.get_enum_item = get_enum_item_ops,
.set_enum_item = set_enum_item_ops
.is = is_ops,
.get_range = get_range_ops,
.get_dB_range = get_dB_range_ops,
.set_range = set_range_ops,
.ask_vol_dB = ask_vol_dB_ops,
.ask_dB_vol = ask_dB_vol_ops,
.get_volume = get_volume_ops,
.get_dB = get_dB_ops,
.set_volume = set_volume_ops,
.set_dB = set_dB_ops,
.get_switch = get_switch_ops,
.set_switch = set_switch_ops,
.enum_item_name = enum_item_name_ops,
.get_enum_item = get_enum_item_ops,
.set_enum_item = set_enum_item_ops
};
static void selem_free(snd_mixer_elem_t *elem)
@ -578,7 +578,7 @@ pymelem_attach(struct pymelem *pymelem, PyObject *args)
PyObject *obj;
snd_hctl_elem_t *helem;
int err;
if (!PyArg_ParseTuple(args, "O", &obj))
return NULL;
helem = (snd_hctl_elem_t *)get_C_ptr(obj, "get_C_helem");
@ -587,7 +587,7 @@ pymelem_attach(struct pymelem *pymelem, PyObject *args)
err = snd_mixer_elem_attach(pymelem->melem, helem);
if (err < 0) {
PyErr_Format(PyExc_RuntimeError, "Cannot attach hcontrol element to mixer element: %s", snd_strerror(err));
return NULL;
return NULL;
}
Py_RETURN_NONE;
}
@ -598,7 +598,7 @@ pymelem_detach(struct pymelem *pymelem, PyObject *args)
PyObject *obj;
snd_hctl_elem_t *helem;
int err;
if (!PyArg_ParseTuple(args, "O", &obj))
return NULL;
helem = (snd_hctl_elem_t *)get_C_ptr(obj, "get_C_helem");
@ -607,7 +607,7 @@ pymelem_detach(struct pymelem *pymelem, PyObject *args)
err = snd_mixer_elem_detach(pymelem->melem, helem);
if (err < 0) {
PyErr_Format(PyExc_RuntimeError, "Cannot detach hcontrol element to mixer element: %s", snd_strerror(err));
return NULL;
return NULL;
}
Py_RETURN_NONE;
}
@ -679,14 +679,14 @@ static PyGetSetDef pymelem_getseters[] = {
{"name", (getter)pymelem_get_name, NULL, NULL, NULL},
{"index", (getter)pymelem_get_index, NULL, NULL, NULL},
{NULL,NULL,NULL,NULL,NULL}
};
static PyMethodDef pymelem_methods[] = {
{"attach", (PyCFunction)pymelem_attach, METH_VARARGS, NULL},
{"detach", (PyCFunction)pymelem_detach, METH_VARARGS, NULL},
/* "default" functions - no functionality */
{"opsIsActive", (PyCFunction)pymelem_ignore1, METH_VARARGS, NULL},
{"opsIsMono", (PyCFunction)pymelem_ignore, METH_VARARGS, NULL},
@ -695,7 +695,7 @@ static PyMethodDef pymelem_methods[] = {
{"opsIsEnumCnt", (PyCFunction)pymelem_ignore, METH_VARARGS, NULL},
{"opsGetDB", (PyCFunction)pymelem_error, METH_VARARGS, NULL},
{"eventInfo", (PyCFunction)pymelem_event_info, METH_VARARGS, NULL},
{"eventValue", (PyCFunction)pymelem_event_value, METH_VARARGS, NULL},
@ -703,18 +703,18 @@ static PyMethodDef pymelem_methods[] = {
};
static PyTypeObject pymelem_type = {
PyVarObject_HEAD_INIT(NULL, 0)
tp_name: "smixer_python.InternalMElement",
tp_basicsize: sizeof(struct pymelem),
tp_dealloc: (destructor)pymelem_dealloc,
tp_flags: Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
tp_doc: NULL /* mixerinit__doc__ */,
tp_getset: pymelem_getseters,
tp_init: (initproc)pymelem_init,
tp_alloc: PyType_GenericAlloc,
tp_new: PyType_GenericNew,
tp_free: PyObject_Del,
tp_methods: pymelem_methods,
PyVarObject_HEAD_INIT(NULL, 0)
tp_name: "smixer_python.InternalMElement",
tp_basicsize: sizeof(struct pymelem),
tp_dealloc: (destructor)pymelem_dealloc,
tp_flags: Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
tp_doc: NULL /* mixerinit__doc__ */,
tp_getset: pymelem_getseters,
tp_init: (initproc)pymelem_init,
tp_alloc: PyType_GenericAlloc,
tp_new: PyType_GenericNew,
tp_free: PyObject_Del,
tp_methods: pymelem_methods,
};
static PyObject *
@ -724,7 +724,7 @@ pymixer_attach_hctl(struct pymixer *pymixer, PyObject *args)
snd_hctl_t *hctl;
void **hctls;
int err;
if (!PyArg_ParseTuple(args, "O", &obj))
return NULL;
hctl = (snd_hctl_t *)get_C_ptr(obj, "get_C_hctl");
@ -752,7 +752,7 @@ static PyObject *
pymixer_register(struct pymixer *pymixer, PyObject *args)
{
int err;
if (!PyArg_ParseTuple(args, ""))
return NULL;
err = snd_mixer_class_register(pymixer->class, pymixer->mixer);
@ -769,7 +769,7 @@ pymixer_melement_new(struct pymixer *pymixer, PyObject *args)
PyObject *obj, *obj1, *obj2;
char *class, *name;
long index, weight;
if (!PyArg_ParseTuple(args, "ssii", &class, &name, &index, &weight))
return NULL;
obj = PyDict_GetItemString(pymixer->mdict, class);
@ -808,14 +808,14 @@ pymixer_melement_add(struct pymixer *pymixer, PyObject *args)
PyObject *obj;
struct pymelem *pymelem;
int err;
if (!PyArg_ParseTuple(args, "O", &obj))
return NULL;
pymelem = (struct pymelem *)obj;
err = snd_mixer_elem_add(pymelem->melem, pymixer->class);
if (err < 0) {
PyErr_Format(PyExc_RuntimeError, "Cannot add mixer element: %s", snd_strerror(err));
return NULL;
return NULL;
}
Py_RETURN_NONE;
}
@ -842,7 +842,7 @@ static void
pymixer_free(struct pymixer *self)
{
int idx;
for (idx = 0; idx < self->hctl_count; idx++) {
snd_mixer_detach_hctl(self->mixer, self->hctl[idx*2]);
Py_DECREF((PyObject *)self->hctl[idx*2+1]);
@ -884,18 +884,18 @@ static PyMethodDef pymixer_methods[] = {
};
static PyTypeObject pymixer_type = {
PyVarObject_HEAD_INIT(NULL, 0)
tp_name: "smixer_python.InternalMixer",
tp_basicsize: sizeof(struct pymixer),
tp_dealloc: (destructor)pymixer_dealloc,
tp_flags: Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
tp_doc: NULL /* mixerinit__doc__ */,
tp_getset: pymixer_getseters,
tp_init: (initproc)pymixer_init,
tp_alloc: PyType_GenericAlloc,
tp_new: PyType_GenericNew,
tp_free: PyObject_Del,
tp_methods: pymixer_methods,
PyVarObject_HEAD_INIT(NULL, 0)
tp_name: "smixer_python.InternalMixer",
tp_basicsize: sizeof(struct pymixer),
tp_dealloc: (destructor)pymixer_dealloc,
tp_flags: Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
tp_doc: NULL /* mixerinit__doc__ */,
tp_getset: pymixer_getseters,
tp_init: (initproc)pymixer_init,
tp_alloc: PyType_GenericAlloc,
tp_new: PyType_GenericNew,
tp_free: PyObject_Del,
tp_methods: pymixer_methods,
};
static PyMethodDef python_methods[] = {
@ -931,7 +931,7 @@ static PyObject *new_helem(struct python_priv *priv, snd_hctl_elem_t *helem)
}
Py_XDECREF(obj1);
} else {
SNDERR("Unable to create InternalMixer object");
snd_error(MIXER, "Unable to create InternalMixer object");
return NULL;
}
if (obj2) {
@ -984,20 +984,20 @@ int alsa_mixer_simple_event(snd_mixer_class_t *class, unsigned int mask,
tstate = PyThreadState_New(main_interpreter);
PyThreadState_Swap(tstate);
t = PyTuple_New(3);
if (t) {
PyTuple_SET_ITEM(t, 0, (PyObject *)PyInt_FromLong(mask));
o = find_helem(priv, helem);
if (mask & SND_CTL_EVENT_MASK_ADD) {
if (o == NULL)
o = new_helem(priv, helem);
t = PyTuple_New(3);
if (t) {
PyTuple_SET_ITEM(t, 0, (PyObject *)PyInt_FromLong(mask));
o = find_helem(priv, helem);
if (mask & SND_CTL_EVENT_MASK_ADD) {
if (o == NULL)
o = new_helem(priv, helem);
}
if (o == NULL)
return 0;
if (o == NULL)
return 0;
PyTuple_SET_ITEM(t, 1, o);
Py_INCREF(o);
o = melem ? find_melem(priv, melem) : Py_None;
o = melem ? find_melem(priv, melem) : Py_None;
PyTuple_SET_ITEM(t, 2, o);
Py_INCREF(o);
r = PyObject_CallObject(priv->py_event_func, t);
@ -1019,7 +1019,7 @@ int alsa_mixer_simple_event(snd_mixer_class_t *class, unsigned int mask,
res = -EIO;
}
}
return res;
}
@ -1039,8 +1039,8 @@ static void alsa_mixer_simple_free(snd_mixer_class_t *class)
}
static int alsa_mixer_simple_pyinit(struct python_priv *priv,
PyObject *py_mod,
FILE *fp,
PyObject *py_mod,
FILE *fp,
const char *file,
snd_mixer_class_t *class,
snd_mixer_t *mixer,
@ -1073,7 +1073,7 @@ static int alsa_mixer_simple_pyinit(struct python_priv *priv,
PyDict_SetItemString(mdict, "mixer", obj2);
priv->py_mixer = obj2;
} else {
SNDERR("Unable to create InternalMixer object");
snd_error(MIXER, "Unable to create InternalMixer object");
return -EIO;
}
@ -1083,7 +1083,7 @@ static int alsa_mixer_simple_pyinit(struct python_priv *priv,
Py_XDECREF(obj);
priv->py_event_func = PyDict_GetItemString(mdict, "event");
if (priv->py_event_func == NULL) {
SNDERR("Unable to find python function 'event'");
snd_error(MIXER, "Unable to find python function 'event'");
return -EIO;
}
return 0;
@ -1091,15 +1091,15 @@ static int alsa_mixer_simple_pyinit(struct python_priv *priv,
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef smixer_python_module = {
PyModuleDef_HEAD_INIT,
"smixer_python",
NULL,
0,
python_methods,
NULL,
NULL,
NULL,
NULL
PyModuleDef_HEAD_INIT,
"smixer_python",
NULL,
0,
python_methods,
NULL,
NULL,
NULL,
NULL
};
#endif
@ -1128,10 +1128,10 @@ int alsa_mixer_simple_finit(snd_mixer_class_t *class,
fp = fopen(file, "r");
if (fp == NULL) {
SNDERR("Unable to find python module '%s'", file);
snd_error(MIXER, "Unable to find python module '%s'", file);
return -ENODEV;
}
Py_Initialize();
if (PyType_Ready(&pymelem_type) < 0 ||
PyType_Ready(&pymixer_type) < 0) {

View file

@ -43,7 +43,7 @@ static int selem_read(snd_mixer_elem_t *elem);
static unsigned int chanmap_to_channels(unsigned int chanmap)
{
unsigned int i, res;
for (i = 0, res = 0; i < MAX_CHANNEL; i++)
if (chanmap & (1 << i))
res++;
@ -61,11 +61,11 @@ static long to_user(struct selem_base *s, int dir, struct helem_base *c, long va
}
static long from_user(struct selem_base *s, int dir, struct helem_base *c, long value)
{
int64_t n;
{
int64_t n;
if (s->dir[dir].max == s->dir[dir].min)
return c->min;
n = (int64_t) (value - s->dir[dir].min) * (c->max - c->min);
n = (int64_t) (value - s->dir[dir].min) * (c->max - c->min);
return c->min + (n + (s->dir[dir].max - s->dir[dir].min) / 2) / (s->dir[dir].max - s->dir[dir].min);
}
#endif
@ -77,7 +77,7 @@ static void update_ranges(struct selem_base *s)
unsigned int dir, ok_flag;
struct list_head *pos;
struct helem_base *helem;
for (dir = 0; dir < 2; dir++) {
s->dir[dir].min = 0;
s->dir[dir].max = 0;
@ -139,7 +139,7 @@ static int is_ops(snd_mixer_elem_t *elem, int dir, int cmd, int val)
helem = list_entry(s->helems.next, struct helem_base, list);
return !!(helem->purpose == PURPOSE_ENUMLIST);
}
case SM_OPS_IS_ENUMCNT: {
struct helem_base *helem;
helem = list_entry(s->helems.next, struct helem_base, list);
@ -147,7 +147,7 @@ static int is_ops(snd_mixer_elem_t *elem, int dir, int cmd, int val)
}
}
return 1;
}
@ -155,7 +155,7 @@ static int get_range_ops(snd_mixer_elem_t *elem, int dir,
long *min, long *max)
{
struct selem_base *s = snd_mixer_elem_get_private(elem);
*min = s->dir[dir].min;
*max = s->dir[dir].max;
@ -179,7 +179,7 @@ static int set_range_ops(snd_mixer_elem_t *elem, int dir,
s->dir[dir].forced_range = 1;
s->dir[dir].min = min;
s->dir[dir].max = max;
if ((err = selem_read(elem)) < 0)
return err;
return 0;
@ -189,7 +189,7 @@ static int get_volume_ops(snd_mixer_elem_t *elem, int dir,
snd_mixer_selem_channel_id_t channel, long *value)
{
struct selem_base *s = snd_mixer_elem_get_private(elem);
*value = s->dir[dir].vol[channel];
return 0;
}
@ -330,7 +330,7 @@ static int simple_event_add1(snd_mixer_class_t *class,
struct bclass_sid *bsid;
struct melem_sids *sid;
unsigned int ui;
list_for_each(pos, &priv->sids) {
bsid = list_entry(pos, struct bclass_sid, list);
for (ui = 0; ui < bsid->count; ui++) {
@ -361,7 +361,7 @@ static int simple_event_add1(snd_mixer_class_t *class,
min = max = 0;
break;
}
printf("event add: %p, %p (%s)\n", helem, sel, snd_hctl_elem_get_name(helem));
if (snd_mixer_selem_id_malloc(&id))
return -ENOMEM;
@ -374,7 +374,7 @@ static int simple_event_add1(snd_mixer_class_t *class,
case PURPOSE_SWITCH:
if (ctype != SND_CTL_ELEM_TYPE_BOOLEAN) {
__invalid_type:
snd_mixer_selem_id_free(id);
snd_mixer_selem_id_free(id);
free(hsimple);
return -EINVAL;
}
@ -446,9 +446,9 @@ static int simple_event_add1(snd_mixer_class_t *class,
err = snd_mixer_elem_value(melem);
return err;
__error:
if (new)
snd_mixer_elem_free(melem);
return -EINVAL;
if (new)
snd_mixer_elem_free(melem);
return -EINVAL;
}
static int simple_event_add(snd_mixer_class_t *class, snd_hctl_elem_t *helem)

View file

@ -65,27 +65,27 @@ int mixer_simple_basic_dlopen(snd_mixer_class_t *class,
strcat(xlib, lib);
h = snd_dlopen(xlib, RTLD_NOW, errbuf, sizeof(errbuf));
if (h == NULL) {
SNDERR("Unable to open library '%s': %s", xlib, errbuf);
snd_error(MIXER, "Unable to open library '%s': %s", xlib, errbuf);
goto __error;
}
initpriv = dlsym(h, "alsa_mixer_sbasic_initpriv");
if (initpriv == NULL) {
SNDERR("Symbol 'alsa_mixer_sbasic_initpriv' was not found in '%s'", xlib);
snd_error(MIXER, "Symbol 'alsa_mixer_sbasic_initpriv' was not found in '%s'", xlib);
goto __error;
}
priv->ops.event = dlsym(h, "alsa_mixer_sbasic_event");
if (priv->ops.event == NULL) {
SNDERR("Symbol 'alsa_mixer_sbasic_event' was not found in '%s'", xlib);
snd_error(MIXER, "Symbol 'alsa_mixer_sbasic_event' was not found in '%s'", xlib);
goto __error;
}
priv->ops.selreg = dlsym(h, "alsa_mixer_sbasic_selreg");
if (priv->ops.selreg == NULL) {
SNDERR("Symbol 'alsa_mixer_sbasic_selreg' was not found in '%s'", xlib);
snd_error(MIXER, "Symbol 'alsa_mixer_sbasic_selreg' was not found in '%s'", xlib);
goto __error;
}
priv->ops.sidreg = dlsym(h, "alsa_mixer_sbasic_sidreg");
if (priv->ops.sidreg == NULL) {
SNDERR("Symbol 'alsa_mixer_sbasic_sidreg' was not found in '%s'", xlib);
snd_error(MIXER, "Symbol 'alsa_mixer_sbasic_sidreg' was not found in '%s'", xlib);
goto __error;
}
free(xlib);
@ -97,8 +97,8 @@ int mixer_simple_basic_dlopen(snd_mixer_class_t *class,
return 1;
__error:
if (initflag)
free(priv);
if (initflag)
free(priv);
if (h)
snd_dlclose(h);
free(xlib);

View file

@ -214,3 +214,17 @@ ALSA_1.2.13 {
@SYMBOL_PREFIX@snd_ump_packet_length;
#endif
} ALSA_1.2.10;
ALSA_1.2.15 {
global:
@SYMBOL_PREFIX@snd_lib_vlog;
@SYMBOL_PREFIX@snd_lib_log;
@SYMBOL_PREFIX@snd_lib_log_set_handler;
@SYMBOL_PREFIX@snd_lib_log_set_local;
@SYMBOL_PREFIX@snd_lib_log_priority;
@SYMBOL_PREFIX@snd_lib_log_interface;
@SYMBOL_PREFIX@snd_lib_log_filter;
@SYMBOL_PREFIX@snd_lib_check;
} ALSA_1.2.13;

View file

@ -43,7 +43,7 @@ void snd_async_init(void)
{
snd_async_signo = __libc_allocate_rtsig(0);
if (snd_async_signo < 0) {
SNDERR("Unable to find a RT signal to use for snd_async");
snd_error(CORE, "Unable to find a RT signal to use for snd_async");
exit(1);
}
}
@ -109,7 +109,7 @@ static void snd_async_handler(int signo ATTRIBUTE_UNUSED, siginfo_t *siginfo, vo
*
* \see snd_async_add_pcm_handler, snd_async_add_ctl_handler
*/
int snd_async_add_handler(snd_async_handler_t **handler, int fd,
int snd_async_add_handler(snd_async_handler_t **handler, int fd,
snd_async_callback_t callback, void *private_data)
{
snd_async_handler_t *h;
@ -135,7 +135,7 @@ int snd_async_add_handler(snd_async_handler_t **handler, int fd,
assert(!previous_action.sa_sigaction);
err = sigaction(snd_async_signo, &act, &previous_action);
if (err < 0) {
SYSERR("sigaction");
snd_errornum(CORE, "sigaction");
return -errno;
}
}
@ -189,7 +189,7 @@ int snd_async_del_handler(snd_async_handler_t *handler)
if (!was_empty && list_empty(&snd_async_handlers)) {
err = sigaction(snd_async_signo, &previous_action, NULL);
if (err < 0) {
SYSERR("sigaction");
snd_errornum(CORE, "sigaction");
return -errno;
}
memset(&previous_action, 0, sizeof(previous_action));

View file

@ -51,7 +51,7 @@ any surplus whitespace is discarded. For example, the two sequences
and
\code
a 1
a 1
b 2
\endcode
@ -255,8 +255,8 @@ name [=] value [,|;]
# Compound assignment (first style)
name [=] {
name1 [=] value [,|;]
...
name1 [=] value [,|;]
...
}
# Compound assignment (second style)
@ -264,9 +264,9 @@ name.name1 [=] value [,|;]
# Array assignment (first style)
name [
value0 [,|;]
value1 [,|;]
...
value0 [,|;]
value1 [,|;]
...
]
# Array assignment (second style)
@ -377,7 +377,7 @@ values in the current compound are used as configuration for the function.
If the compound func.\<function_name\> is defined in the root node, then the
library and function from this compound configuration are used, otherwise
'snd_func_' is prefixed to the string and code from the ALSA library is used.
The definition of a function looks like:</P>
The definition of a function looks like:</P>
\code
func.remove_first_char {
@ -811,7 +811,7 @@ static int get_char_skip_comments(input_t *input)
dirp = opendir(str);
if (!dirp) {
SNDERR("Invalid search dir %s", str);
snd_error(CONFIG, "Invalid search dir %s", str);
free(str);
return -EINVAL;
}
@ -819,7 +819,7 @@ static int get_char_skip_comments(input_t *input)
err = add_include_path(input->current, str);
if (err < 0) {
SNDERR("Cannot add search dir %s", str);
snd_error(CORE, "Cannot add search dir %s", str);
free(str);
return err;
}
@ -840,7 +840,7 @@ static int get_char_skip_comments(input_t *input)
}
if (err < 0) {
SNDERR("Cannot access file %s", str);
snd_error(CORE, "Cannot access file %s", str);
free(str);
return err;
}
@ -868,10 +868,10 @@ static int get_char_skip_comments(input_t *input)
break;
}
}
return c;
}
static int get_nonwhite(input_t *input)
{
@ -1057,7 +1057,7 @@ static int get_freestring(char **string, int id, input_t *input)
free_local_string(&str);
return c;
}
static int get_delimstring(char **string, int delim, input_t *input)
{
struct local_string str;
@ -1145,7 +1145,7 @@ static int _snd_config_make(snd_config_t **config, char **id, snd_config_type_t
*config = n;
return 0;
}
static int _snd_config_make_add(snd_config_t **config, char **id,
snd_config_type_t type, snd_config_t *parent)
@ -1162,7 +1162,7 @@ static int _snd_config_make_add(snd_config_t **config, char **id,
return 0;
}
static int _snd_config_search(snd_config_t *config,
static int _snd_config_search(snd_config_t *config,
const char *id, int len, snd_config_t **result)
{
snd_config_iterator_t i, next;
@ -1205,7 +1205,7 @@ static int parse_value(snd_config_t **_n, snd_config_t *parent, input_t *input,
free(s);
if (n) {
if (n->type != SND_CONFIG_TYPE_REAL) {
SNDERR("%s is not a real", *id);
snd_error(CORE, "%s is not a real", *id);
return -EINVAL;
}
} else {
@ -1221,20 +1221,20 @@ static int parse_value(snd_config_t **_n, snd_config_t *parent, input_t *input,
free(s);
if (n) {
if (n->type != SND_CONFIG_TYPE_INTEGER && n->type != SND_CONFIG_TYPE_INTEGER64) {
SNDERR("%s is not an integer", *id);
snd_error(CORE, "%s is not an integer", *id);
return -EINVAL;
}
} else {
if (i <= INT_MAX)
if (i <= INT_MAX)
err = _snd_config_make_add(&n, id, SND_CONFIG_TYPE_INTEGER, parent);
else
err = _snd_config_make_add(&n, id, SND_CONFIG_TYPE_INTEGER64, parent);
if (err < 0)
return err;
}
if (n->type == SND_CONFIG_TYPE_INTEGER)
if (n->type == SND_CONFIG_TYPE_INTEGER)
n->u.integer = (long) i;
else
else
n->u.integer64 = i;
*_n = n;
return 0;
@ -1242,7 +1242,7 @@ static int parse_value(snd_config_t **_n, snd_config_t *parent, input_t *input,
}
if (n) {
if (n->type != SND_CONFIG_TYPE_STRING) {
SNDERR("%s is not a string", *id);
snd_error(CORE, "%s is not a string", *id);
free(s);
return -EINVAL;
}
@ -1268,13 +1268,13 @@ static int parse_array_def(snd_config_t *parent, input_t *input, int *idx, int s
snd_config_t *n = NULL;
if (!skip) {
snd_config_t *g;
char static_id[12];
while (1) {
snprintf(static_id, sizeof(static_id), "%i", *idx);
if (_snd_config_search(parent, static_id, -1, &g) == 0) {
if (_snd_config_search(parent, static_id, -1, &n) == 0) {
if (override) {
snd_config_delete(n);
/* fallthrough to break */
} else {
/* merge */
(*idx)++;
@ -1283,6 +1283,7 @@ static int parse_array_def(snd_config_t *parent, input_t *input, int *idx, int s
}
break;
}
n = NULL;
id = strdup(static_id);
if (id == NULL)
return -ENOMEM;
@ -1300,7 +1301,7 @@ static int parse_array_def(snd_config_t *parent, input_t *input, int *idx, int s
if (!skip) {
if (n) {
if (n->type != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("%s is not a compound", id);
snd_error(CORE, "%s is not a compound", id);
err = -EINVAL;
goto __end;
}
@ -1340,7 +1341,7 @@ static int parse_array_def(snd_config_t *parent, input_t *input, int *idx, int s
err = 0;
__end:
free(id);
return err;
return err;
}
static int parse_array_defs(snd_config_t *parent, input_t *input, int skip, int override)
@ -1407,7 +1408,7 @@ static int parse_def(snd_config_t *parent, input_t *input, int skip, int overrid
}
if (mode != OVERRIDE) {
if (n->type != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("%s is not a compound", id);
snd_error(CORE, "%s is not a compound", id);
return -EINVAL;
}
n->u.compound.join = true;
@ -1418,7 +1419,7 @@ static int parse_def(snd_config_t *parent, input_t *input, int skip, int overrid
snd_config_delete(n);
}
if (mode == MERGE) {
SNDERR("%s does not exists", id);
snd_error(CORE, "%s does not exists", id);
err = -ENOENT;
goto __end;
}
@ -1445,7 +1446,7 @@ static int parse_def(snd_config_t *parent, input_t *input, int skip, int overrid
} else {
n = NULL;
if (mode == MERGE) {
SNDERR("%s does not exists", id);
snd_error(CORE, "%s does not exists", id);
err = -ENOENT;
goto __end;
}
@ -1459,7 +1460,7 @@ static int parse_def(snd_config_t *parent, input_t *input, int skip, int overrid
if (!skip) {
if (n) {
if (n->type != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("%s is not a compound", id);
snd_error(CORE, "%s is not a compound", id);
err = -EINVAL;
goto __end;
}
@ -1504,7 +1505,7 @@ static int parse_def(snd_config_t *parent, input_t *input, int skip, int overrid
free(id);
return err;
}
static int parse_defs(snd_config_t *parent, input_t *input, int skip, int override)
{
int c, err;
@ -1644,7 +1645,7 @@ int _snd_config_save_node_value(snd_config_t *n, snd_output_t *out,
string_print(n->u.string, 0, out);
break;
case SND_CONFIG_TYPE_POINTER:
SNDERR("cannot save runtime pointer type");
snd_error(CORE, "cannot save runtime pointer type");
return -EINVAL;
case SND_CONFIG_TYPE_COMPOUND:
array = snd_config_is_array(n);
@ -2011,13 +2012,13 @@ int _snd_config_load_with_include(snd_config_t *config, snd_input_t *in,
str = strerror(-err);
break;
}
SNDERR("%s:%d:%d:%s", fd->name ? fd->name : "_toplevel_", fd->line, fd->column, str);
snd_error(CORE, "%s:%d:%d:%s", fd->name ? fd->name : "_toplevel_", fd->line, fd->column, str);
goto _end;
}
err = get_char(&input);
fd = input.current;
if (err != LOCAL_UNEXPECTED_EOF) {
SNDERR("%s:%d:%d:Unexpected }", fd->name ? fd->name : "", fd->line, fd->column);
snd_error(CORE, "%s:%d:%d:Unexpected }", fd->name ? fd->name : "", fd->line, fd->column);
err = -EINVAL;
goto _end;
}
@ -2773,7 +2774,7 @@ __make:
int snd_config_imake_integer(snd_config_t **config, const char *id, const long value)
{
int err;
err = snd_config_make(config, id, SND_CONFIG_TYPE_INTEGER);
if (err < 0)
return err;
@ -2803,7 +2804,7 @@ int snd_config_imake_integer(snd_config_t **config, const char *id, const long v
int snd_config_imake_integer64(snd_config_t **config, const char *id, const long long value)
{
int err;
err = snd_config_make(config, id, SND_CONFIG_TYPE_INTEGER64);
if (err < 0)
return err;
@ -2830,7 +2831,7 @@ int snd_config_imake_integer64(snd_config_t **config, const char *id, const long
int snd_config_imake_real(snd_config_t **config, const char *id, const double value)
{
int err;
err = snd_config_make(config, id, SND_CONFIG_TYPE_REAL);
if (err < 0)
return err;
@ -2861,7 +2862,7 @@ int snd_config_imake_string(snd_config_t **config, const char *id, const char *v
{
int err;
snd_config_t *tmp;
err = snd_config_make(&tmp, id, SND_CONFIG_TYPE_STRING);
if (err < 0)
return err;
@ -2949,7 +2950,7 @@ int snd_config_imake_safe_string(snd_config_t **config, const char *id, const ch
int snd_config_imake_pointer(snd_config_t **config, const char *id, const void *value)
{
int err;
err = snd_config_make(config, id, SND_CONFIG_TYPE_POINTER);
if (err < 0)
return err;
@ -3564,9 +3565,9 @@ int snd_config_save(snd_config_t *config, snd_output_t *out)
assert(key); \
if (!first && (strcmp(key, old_key) == 0 || maxloop <= 0)) { \
if (maxloop == 0) \
SNDERR("maximum loop count reached (circular configuration?)"); \
snd_error(CORE, "maximum loop count reached (circular configuration?)"); \
else \
SNDERR("key %s refers to itself", key); \
snd_error(CORE, "key %s refers to itself", key); \
err = -EINVAL; \
res = NULL; \
break; \
@ -3970,12 +3971,12 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c
err = snd_config_search(config, "func", &c);
if (err < 0) {
SNDERR("Field func is missing");
snd_error(CORE, "Field func is missing");
return err;
}
err = snd_config_get_string(c, &str);
if (err < 0) {
SNDERR("Invalid type for field func");
snd_error(CORE, "Invalid type for field func");
return err;
}
assert(str);
@ -3983,7 +3984,7 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c
if (err >= 0) {
snd_config_iterator_t i, next;
if (snd_config_get_type(func_conf) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid type for func %s definition", str);
snd_error(CORE, "Invalid type for func %s definition", str);
err = -EINVAL;
goto _err;
}
@ -3995,7 +3996,7 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c
if (strcmp(id, "lib") == 0) {
err = snd_config_get_string(n, &lib);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(CORE, "Invalid type for %s", id);
goto _err;
}
continue;
@ -4003,12 +4004,12 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c
if (strcmp(id, "func") == 0) {
err = snd_config_get_string(n, &func_name);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(CORE, "Invalid type for %s", id);
goto _err;
}
continue;
}
SNDERR("Unknown field %s", id);
snd_error(CORE, "Unknown field %s", id);
}
}
if (!func_name) {
@ -4026,10 +4027,10 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c
func = h ? snd_dlsym(h, func_name, SND_DLSYM_VERSION(SND_CONFIG_DLSYM_VERSION_HOOK)) : NULL;
err = 0;
if (!h) {
SNDERR("Cannot open shared library %s (%s)", lib, errbuf);
snd_error(CORE, "Cannot open shared library %s (%s)", lib, errbuf);
err = -ENOENT;
} else if (!func) {
SNDERR("symbol %s is not defined inside %s", func_name, lib);
snd_error(CORE, "symbol %s is not defined inside %s", func_name, lib);
snd_dlclose(h);
err = -ENXIO;
}
@ -4040,7 +4041,7 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c
snd_config_t *nroot;
err = func(root, config, &nroot, private_data);
if (err < 0)
SNDERR("function %s returned error: %s", func_name, snd_strerror(err));
snd_error(CORE, "function %s returned error: %s", func_name, snd_strerror(err));
snd_dlclose(h);
if (err >= 0 && nroot)
err = snd_config_substitute(root, nroot);
@ -4069,7 +4070,7 @@ static int snd_config_hooks(snd_config_t *config, snd_config_t *private_data)
long i;
err = safe_strtol(id, &i);
if (err < 0) {
SNDERR("id of field %s is not and integer", id);
snd_error(CORE, "id of field %s is not and integer", id);
err = -EINVAL;
goto _err;
}
@ -4108,24 +4109,27 @@ static int config_filename_filter(const struct dirent64 *dirent)
return 0;
}
static int config_file_open(snd_config_t *root, const char *filename)
static int config_file_open(snd_config_t *root, const char *filename, int merge)
{
snd_input_t *in;
int err;
err = snd_input_stdio_open(&in, filename, "r");
if (err >= 0) {
err = snd_config_load(root, in);
if (merge)
err = snd_config_load(root, in);
else
err = snd_config_load_override(root, in);
snd_input_close(in);
if (err < 0)
SNDERR("%s may be old or corrupted: consider to remove or fix it", filename);
snd_error(CORE, "%s may be old or corrupted: consider to remove or fix it", filename);
} else
SNDERR("cannot access file %s", filename);
snd_error(CORE, "cannot access file %s", filename);
return err;
}
static int config_file_load(snd_config_t *root, const char *fn, int errors)
static int config_file_load(snd_config_t *root, const char *fn, int errors, int merge)
{
struct stat64 st;
struct dirent64 **namelist;
@ -4134,13 +4138,20 @@ static int config_file_load(snd_config_t *root, const char *fn, int errors)
if (!errors && access(fn, R_OK) < 0)
return 1;
if (stat64(fn, &st) < 0) {
SNDERR("cannot stat file/directory %s", fn);
snd_error(CORE, "cannot stat file/directory %s", fn);
return 1;
}
if (!S_ISDIR(st.st_mode))
return config_file_open(root, fn);
return config_file_open(root, fn, merge);
#ifndef DOC_HIDDEN
#if defined(_GNU_SOURCE) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__sun) && !defined(__ANDROID__)
#if defined(_GNU_SOURCE) && \
!defined(__NetBSD__) && \
!defined(__FreeBSD__) && \
!defined(__OpenBSD__) && \
!defined(__DragonFly__) && \
!defined(__sun) && \
!defined(__ANDROID__) && \
!defined(__OHOS__)
#define SORTFUNC versionsort64
#else
#define SORTFUNC alphasort64
@ -4157,7 +4168,7 @@ static int config_file_load(snd_config_t *root, const char *fn, int errors)
snprintf(filename, sl, "%s/%s", fn, namelist[j]->d_name);
filename[sl-1] = '\0';
err = config_file_open(root, filename);
err = config_file_open(root, filename, merge);
free(filename);
}
free(namelist[j]);
@ -4169,20 +4180,20 @@ static int config_file_load(snd_config_t *root, const char *fn, int errors)
return 0;
}
static int config_file_load_user(snd_config_t *root, const char *fn, int errors)
static int config_file_load_user(snd_config_t *root, const char *fn, int errors, int merge)
{
char *fn2;
int err;
err = snd_user_file(fn, &fn2);
if (err < 0)
return config_file_load(root, fn, errors);
err = config_file_load(root, fn2, errors);
return config_file_load(root, fn, errors, merge);
err = config_file_load(root, fn2, errors, merge);
free(fn2);
return err;
}
static int config_file_load_user_all(snd_config_t *_root, snd_config_t *_file, int errors)
static int config_file_load_user_all(snd_config_t *_root, snd_config_t *_file, int errors, int merge)
{
snd_config_t *file = _file, *root = _root, *n;
char *name, *name2, *remain, *rname = NULL;
@ -4190,13 +4201,13 @@ static int config_file_load_user_all(snd_config_t *_root, snd_config_t *_file, i
if (snd_config_get_type(_file) == SND_CONFIG_TYPE_COMPOUND) {
if ((err = snd_config_search(_file, "file", &file)) < 0) {
SNDERR("Field file not found");
snd_error(CORE, "Field file not found");
return err;
}
if ((err = snd_config_search(_file, "root", &root)) >= 0) {
err = snd_config_get_ascii(root, &rname);
if (err < 0) {
SNDERR("Field root is bad");
snd_error(CORE, "Field root is bad");
return err;
}
err = snd_config_make_compound(&root, rname, 0);
@ -4213,7 +4224,7 @@ static int config_file_load_user_all(snd_config_t *_root, snd_config_t *_file, i
*remain = '\0';
remain += 3;
}
err = config_file_load_user(root, name2, errors);
err = config_file_load_user(root, name2, errors, merge);
if (err < 0)
goto _err;
if (err == 0) /* first hit wins */
@ -4262,28 +4273,33 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t
{
snd_config_t *n;
snd_config_iterator_t i, next;
int err, idx = 0, errors = 1, hit;
int err, idx = 0, errors = 1, merge = 1, hit;
assert(root && dst);
if ((err = snd_config_search(config, "errors", &n)) >= 0) {
errors = snd_config_get_bool(n);
if (errors < 0) {
SNDERR("Invalid bool value in field errors");
snd_error(CORE, "Invalid bool value in field errors");
return errors;
}
}
/* special case, we know the card number (may be multiple times) */
if (private_data && snd_config_search(private_data, "integer", &n) >= 0) {
merge = 0;
}
if ((err = snd_config_search(config, "files", &n)) < 0) {
SNDERR("Unable to find field files in the pre-load section");
snd_error(CORE, "Unable to find field files in the pre-load section");
return -EINVAL;
}
if ((err = snd_config_expand(n, root, NULL, private_data, &n)) < 0) {
SNDERR("Unable to expand filenames in the pre-load section");
snd_error(CORE, "Unable to expand filenames in the pre-load section");
return err;
}
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid type for field filenames");
snd_error(CORE, "Invalid type for field filenames");
goto _err;
}
do {
hit = 0;
snd_config_for_each(i, next, n) {
@ -4292,12 +4308,12 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t
long i;
err = safe_strtol(id, &i);
if (err < 0) {
SNDERR("id of field %s is not and integer", id);
snd_error(CORE, "id of field %s is not and integer", id);
err = -EINVAL;
goto _err;
}
if (i == idx) {
err = config_file_load_user_all(root, n, errors);
err = config_file_load_user_all(root, n, errors, merge);
if (err < 0)
goto _err;
idx++;
@ -4359,18 +4375,18 @@ static int _snd_config_hook_table(snd_config_t *root, snd_config_t *config, snd_
if (snd_config_search(config, "table", &n) < 0)
return 0;
if ((err = snd_config_expand(n, root, NULL, private_data, &n)) < 0) {
SNDERR("Unable to expand table compound");
snd_error(CORE, "Unable to expand table compound");
return err;
}
if (snd_config_search(n, "id", &tn) < 0 ||
snd_config_get_string(tn, &id) < 0) {
SNDERR("Unable to find field table.id");
snd_error(CORE, "Unable to find field table.id");
snd_config_delete(n);
return -EINVAL;
}
if (snd_config_search(n, "value", &tn) < 0 ||
snd_config_get_type(tn) != SND_CONFIG_TYPE_STRING) {
SNDERR("Unable to find field table.value");
snd_error(CORE, "Unable to find field table.value");
snd_config_delete(n);
return -EINVAL;
}
@ -4406,23 +4422,18 @@ static int _snd_config_hook_table(snd_config_t *root, snd_config_t *config, snd_
int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config, snd_config_t **dst, snd_config_t *private_data ATTRIBUTE_UNUSED)
{
int card = -1, err;
snd_config_t *loaded; // trace loaded cards
err = snd_config_top(&loaded);
if (err < 0)
return err;
do {
err = snd_card_next(&card);
if (err < 0)
goto __fin_err;
return err;
if (card >= 0) {
snd_config_t *n, *m, *private_data = NULL;
snd_config_t *n, *private_data = NULL;
const char *driver;
char *fdriver = NULL;
bool load;
err = snd_determine_driver(card, &fdriver);
if (err < 0)
goto __fin_err;
return err;
if (snd_config_search(root, fdriver, &n) >= 0) {
if (snd_config_get_string(n, &driver) < 0) {
if (snd_config_get_type(n) == SND_CONFIG_TYPE_COMPOUND) {
@ -4443,19 +4454,6 @@ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config,
driver = fdriver;
}
__std:
load = true;
err = snd_config_imake_integer(&m, driver, 1);
if (err < 0)
goto __err;
err = snd_config_add(loaded, m);
if (err < 0) {
if (err == -EEXIST) {
snd_config_delete(m);
load = false;
} else {
goto __err;
}
}
private_data = _snd_config_hook_private_data(card, driver);
if (!private_data) {
err = -ENOMEM;
@ -4464,28 +4462,23 @@ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config,
err = _snd_config_hook_table(root, config, private_data);
if (err < 0)
goto __err;
if (load)
err = snd_config_hook_load(root, config, &n, private_data);
err = snd_config_hook_load(root, config, &n, private_data);
__err:
if (private_data)
snd_config_delete(private_data);
free(fdriver);
if (err < 0)
goto __fin_err;
return err;
}
} while (card >= 0);
snd_config_delete(loaded);
*dst = NULL;
return 0;
__fin_err:
snd_config_delete(loaded);
return err;
}
#ifndef DOC_HIDDEN
SND_DLSYM_BUILD_VERSION(snd_config_hook_load_for_all_cards, SND_CONFIG_DLSYM_VERSION_HOOK);
#endif
/**
/**
* \brief Updates a configuration tree by rereading the configuration files (if needed).
* \param[in,out] _top Address of the handle to the top-level node.
* \param[in,out] _update Address of a pointer to private update information.
@ -4521,7 +4514,7 @@ int snd_config_update_r(snd_config_t **_top, snd_config_update_t **_update, cons
snd_config_update_t *local;
snd_config_update_t *update;
snd_config_t *top;
assert(_top && _update);
top = *_top;
update = *_update;
@ -4577,7 +4570,7 @@ int snd_config_update_r(snd_config_t **_top, snd_config_update_t **_update, cons
lf->ino = st.st_ino;
lf->mtime = st.st_mtime;
} else {
SNDERR("Cannot access file %s", lf->name);
snd_error(CORE, "Cannot access file %s", lf->name);
free(lf->name);
memmove(&local->finfo[k], &local->finfo[k+1], sizeof(struct finfo) * (local->count - k - 1));
k--;
@ -4615,12 +4608,12 @@ int snd_config_update_r(snd_config_t **_top, snd_config_update_t **_update, cons
return err;
_reread:
*_top = NULL;
*_update = NULL;
if (update) {
snd_config_update_free(update);
update = NULL;
}
*_top = NULL;
*_update = NULL;
if (update) {
snd_config_update_free(update);
update = NULL;
}
if (top) {
snd_config_delete(top);
top = NULL;
@ -4637,17 +4630,17 @@ int snd_config_update_r(snd_config_t **_top, snd_config_update_t **_update, cons
err = snd_config_load(top, in);
snd_input_close(in);
if (err < 0) {
SNDERR("%s may be old or corrupted: consider to remove or fix it", local->finfo[k].name);
snd_error(CORE, "%s may be old or corrupted: consider to remove or fix it", local->finfo[k].name);
goto _end;
}
} else {
SNDERR("cannot access file %s", local->finfo[k].name);
snd_error(CORE, "cannot access file %s", local->finfo[k].name);
}
}
_skip:
err = snd_config_hooks(top, NULL);
if (err < 0) {
SNDERR("hooks failed, removing configuration");
snd_error(CORE, "hooks failed, removing configuration");
goto _end;
}
*_top = top;
@ -4655,7 +4648,7 @@ int snd_config_update_r(snd_config_t **_top, snd_config_update_t **_update, cons
return 1;
}
/**
/**
* \brief Updates #snd_config by rereading the global configuration files (if needed).
* \return 0 if #snd_config was up to date, 1 if #snd_config was
* updated, otherwise a negative error code.
@ -4751,7 +4744,7 @@ void snd_config_unref(snd_config_t *cfg)
snd_config_unlock();
}
/**
/**
* \brief Frees a private update structure.
* \param[in] update The private update structure to free.
* \return Zero if successful, otherwise a negative error code.
@ -4768,7 +4761,7 @@ int snd_config_update_free(snd_config_update_t *update)
return 0;
}
/**
/**
* \brief Frees the global configuration tree in #snd_config.
* \return Zero if successful, otherwise a negative error code.
*
@ -4888,7 +4881,7 @@ typedef int (*snd_config_walk_callback_t)(snd_config_t *src,
static int snd_config_walk(snd_config_t *src,
snd_config_t *root,
snd_config_t **dst,
snd_config_t **dst,
snd_config_walk_callback_t callback,
snd_config_expand_fcn_t fcn,
void *private_data)
@ -5134,7 +5127,7 @@ static int _snd_config_evaluate(snd_config_t *src,
return 1;
err = snd_config_get_string(c, &str);
if (err < 0) {
SNDERR("Invalid type for @func");
snd_error(CORE, "Invalid type for @func");
return err;
}
assert(str);
@ -5142,7 +5135,7 @@ static int _snd_config_evaluate(snd_config_t *src,
if (err >= 0) {
snd_config_iterator_t i, next;
if (snd_config_get_type(func_conf) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid type for func %s definition", str);
snd_error(CORE, "Invalid type for func %s definition", str);
err = -EINVAL;
goto _err;
}
@ -5154,7 +5147,7 @@ static int _snd_config_evaluate(snd_config_t *src,
if (strcmp(id, "lib") == 0) {
err = snd_config_get_string(n, &lib);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(CORE, "Invalid type for %s", id);
goto _err;
}
continue;
@ -5162,12 +5155,12 @@ static int _snd_config_evaluate(snd_config_t *src,
if (strcmp(id, "func") == 0) {
err = snd_config_get_string(n, &func_name);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(CORE, "Invalid type for %s", id);
goto _err;
}
continue;
}
SNDERR("Unknown field %s", id);
snd_error(CORE, "Unknown field %s", id);
}
}
if (!func_name) {
@ -5186,11 +5179,11 @@ static int _snd_config_evaluate(snd_config_t *src,
func = snd_dlsym(h, func_name, SND_DLSYM_VERSION(SND_CONFIG_DLSYM_VERSION_EVALUATE));
err = 0;
if (!h) {
SNDERR("Cannot open shared library %s (%s)", lib, errbuf);
snd_error(CORE, "Cannot open shared library %s (%s)", lib, errbuf);
err = -ENOENT;
goto _errbuf;
} else if (!func) {
SNDERR("symbol %s is not defined inside %s", func_name, lib);
snd_error(CORE, "symbol %s is not defined inside %s", func_name, lib);
snd_dlclose(h);
err = -ENXIO;
goto _errbuf;
@ -5202,7 +5195,7 @@ static int _snd_config_evaluate(snd_config_t *src,
snd_config_t *eval;
err = func(&eval, root, src, private_data);
if (err < 0)
SNDERR("function %s returned error: %s", func_name, snd_strerror(err));
snd_error(CORE, "function %s returned error: %s", func_name, snd_strerror(err));
snd_dlclose(h);
if (err >= 0 && eval)
err = snd_config_substitute(src, eval);
@ -5228,7 +5221,7 @@ static int _snd_config_evaluate(snd_config_t *src,
* replaces those nodes with the respective function results.
*/
int snd_config_evaluate(snd_config_t *config, snd_config_t *root,
snd_config_t *private_data, snd_config_t **result)
snd_config_t *private_data, snd_config_t **result)
{
/* FIXME: Only in place evaluation is currently implemented */
assert(result == NULL);
@ -5266,7 +5259,7 @@ static int load_defaults(snd_config_t *subs, snd_config_t *defs)
}
continue;
}
SNDERR("Unknown field %s", id);
snd_error(CORE, "Unknown field %s", id);
return -EINVAL;
}
}
@ -5372,7 +5365,7 @@ static int parse_string(const char **ptr, char **val)
int c = **ptr;
switch (c) {
case '\0':
SNDERR("Unterminated string");
snd_error(CORE, "Unterminated string");
return -EINVAL;
case '\\':
c = parse_char(ptr);
@ -5415,7 +5408,7 @@ static int parse_string(const char **ptr, char **val)
buf[idx++] = c;
}
}
/* Parse var=val or val */
static int parse_arg(const char **ptr, unsigned int *varlen, char **val)
@ -5509,13 +5502,13 @@ static int parse_args(snd_config_t *subs, const char *str, snd_config_t *defs)
const char *id = n->id;
err = snd_config_search(defs, id, &d);
if (err < 0) {
SNDERR("Unknown parameter %s", id);
snd_error(CORE, "Unknown parameter %s", id);
return err;
}
}
return 0;
}
while (1) {
char buf[256];
const char *var = buf;
@ -5538,11 +5531,11 @@ static int parse_args(snd_config_t *subs, const char *str, snd_config_t *defs)
}
err = snd_config_search_alias(defs, NULL, var, &def);
if (err < 0) {
SNDERR("Unknown parameter %s", var);
snd_error(CORE, "Unknown parameter %s", var);
goto _err;
}
if (snd_config_get_type(def) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Parameter %s definition is not correct", var);
snd_error(CORE, "Parameter %s definition is not correct", var);
err = -EINVAL;
goto _err;
}
@ -5554,7 +5547,7 @@ static int parse_args(snd_config_t *subs, const char *str, snd_config_t *defs)
err = snd_config_search(def, "type", &typ);
if (err < 0) {
_invalid_type:
SNDERR("Parameter %s definition is missing a valid type info", var);
snd_error(CORE, "Parameter %s definition is missing a valid type info", var);
goto _err;
}
err = snd_config_get_string(typ, &tmp);
@ -5567,7 +5560,7 @@ static int parse_args(snd_config_t *subs, const char *str, snd_config_t *defs)
goto _err;
err = safe_strtol(val, &v);
if (err < 0) {
SNDERR("Parameter %s must be an integer", var);
snd_error(CORE, "Parameter %s must be an integer", var);
goto _err;
}
err = snd_config_set_integer(sub, v);
@ -5580,7 +5573,7 @@ static int parse_args(snd_config_t *subs, const char *str, snd_config_t *defs)
goto _err;
err = safe_strtoll(val, &v);
if (err < 0) {
SNDERR("Parameter %s must be an integer", var);
snd_error(CORE, "Parameter %s must be an integer", var);
goto _err;
}
err = snd_config_set_integer64(sub, v);
@ -5593,7 +5586,7 @@ static int parse_args(snd_config_t *subs, const char *str, snd_config_t *defs)
goto _err;
err = safe_strtod(val, &v);
if (err < 0) {
SNDERR("Parameter %s must be a real", var);
snd_error(CORE, "Parameter %s must be a real", var);
goto _err;
}
err = snd_config_set_real(sub, v);
@ -5660,7 +5653,7 @@ int snd_config_expand_custom(snd_config_t *config, snd_config_t *root,
err = snd_config_walk(config, root, &res, _snd_config_expand, fcn, private_data);
if (err < 0) {
SNDERR("Expand error (walk): %s", snd_strerror(err));
snd_error(CORE, "Expand error (walk): %s", snd_strerror(err));
return err;
}
*result = res;
@ -5692,7 +5685,7 @@ int snd_config_expand(snd_config_t *config, snd_config_t *root, const char *args
err = snd_config_search(config, "@args", &defs);
if (err < 0) {
if (args != NULL) {
SNDERR("Unknown parameters %s", args);
snd_error(CORE, "Unknown parameters %s", args);
return -EINVAL;
}
err = snd_config_copy(&res, config);
@ -5704,35 +5697,35 @@ int snd_config_expand(snd_config_t *config, snd_config_t *root, const char *args
return err;
err = load_defaults(subs, defs);
if (err < 0) {
SNDERR("Load defaults error: %s", snd_strerror(err));
snd_error(CORE, "Load defaults error: %s", snd_strerror(err));
goto _end;
}
err = parse_args(subs, args, defs);
if (err < 0) {
SNDERR("Parse arguments error: %s", snd_strerror(err));
snd_error(CORE, "Parse arguments error: %s", snd_strerror(err));
goto _end;
}
err = snd_config_evaluate(subs, root, private_data, NULL);
if (err < 0) {
SNDERR("Args evaluate error: %s", snd_strerror(err));
snd_error(CORE, "Args evaluate error: %s", snd_strerror(err));
goto _end;
}
err = snd_config_walk(config, root, &res, _snd_config_expand, _snd_config_expand_vars, subs);
if (err < 0) {
SNDERR("Expand error (walk): %s", snd_strerror(err));
snd_error(CORE, "Expand error (walk): %s", snd_strerror(err));
goto _end;
}
}
err = snd_config_evaluate(res, root, private_data, NULL);
if (err < 0) {
SNDERR("Evaluate error: %s", snd_strerror(err));
snd_error(CORE, "Evaluate error: %s", snd_strerror(err));
snd_config_delete(res);
goto _end;
}
*result = res;
err = 1;
_end:
if (subs)
if (subs)
snd_config_delete(subs);
return err;
}
@ -5807,7 +5800,7 @@ int snd_config_check_hop(snd_config_t *conf)
{
if (conf) {
if (conf->hop >= SND_CONF_MAX_HOPS) {
SYSERR("Too many definition levels (looped?)\n");
snd_error(CORE, "Too many definition levels (looped?)\n");
return -EINVAL;
}
return conf->hop;

View file

@ -55,4 +55,5 @@ pistachio-card.pcm.default{
type hw
card $CARD
device $DEVICE
}
}

View file

@ -147,7 +147,7 @@ int _snd_eval_string(snd_config_t **dst, const char *s,
if (c == '\0')
break;
if (pos == END) {
SNDERR("unexpected expression tail '%s'", s);
snd_error(CORE, "unexpected expression tail '%s'", s);
return -EINVAL;
}
if (pos == OP) {
@ -160,7 +160,7 @@ int _snd_eval_string(snd_config_t **dst, const char *s,
case '|':
case '&': op = c; break;
default:
SNDERR("unknown operation '%c'", c);
snd_error(CORE, "unknown operation '%c'", c);
return -EINVAL;
}
pos = RIGHT;
@ -225,7 +225,7 @@ int _snd_eval_string(snd_config_t **dst, const char *s,
pos = op == LEFT ? OP : END;
}
if (pos != OP && pos != END) {
SNDERR("incomplete expression '%s'", save);
snd_error(CORE, "incomplete expression '%s'", save);
return -EINVAL;
}
@ -269,7 +269,7 @@ int snd_config_evaluate_string(snd_config_t **dst, const char *s,
if (s[1] == '[') {
err = _snd_eval_string(dst, s, fcn, private_data);
if (err < 0)
SNDERR("wrong expression '%s'", s);
snd_error(CORE, "wrong expression '%s'", s);
} else {
err = fcn(dst, s + 1, private_data);
}

View file

@ -5,7 +5,7 @@
* \author Abramo Bagnara <abramo@alsa-project.org>
* \author Jaroslav Kysela <perex@perex.cz>
* \date 2000-2001
*
*
* Configuration helper functions.
*
* See the \ref conffunc page for more details.
@ -127,14 +127,14 @@ int snd_config_get_bool(const snd_config_t *conf)
if (err >= 0) {
if (v < 0 || v > 1) {
_invalid_value:
SNDERR("Invalid value for %s", id);
snd_error(CORE, "Invalid value for %s", id);
return -EINVAL;
}
return v;
}
err = snd_config_get_string(conf, &str);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(CORE, "Invalid type for %s", id);
return -EINVAL;
}
err = snd_config_get_bool_ascii(str);
@ -157,12 +157,12 @@ int snd_config_get_card(const snd_config_t *conf)
if (snd_config_get_integer(conf, &v) < 0) {
if (snd_config_get_string(conf, &str)) {
if (snd_config_get_id(conf, &id) >= 0)
SNDERR("Invalid field %s", id);
snd_error(CORE, "Invalid field %s", id);
return -EINVAL;
}
err = snd_card_get_index(str);
if (err < 0) {
SNDERR("Cannot get card index for %s", str);
snd_error(CORE, "Cannot get card index for %s", str);
return err;
}
v = err;
@ -176,7 +176,7 @@ int snd_config_get_card(const snd_config_t *conf)
* \brief Gets the control interface index from the given ASCII string.
* \param ascii The string to be parsed.
* \return The control interface index if successful, otherwise a negative error code.
*/
*/
int snd_config_get_ctl_iface_ascii(const char *ascii)
{
long v;
@ -199,7 +199,7 @@ int snd_config_get_ctl_iface_ascii(const char *ascii)
* \brief Gets the control interface index from a configuration node.
* \param conf Handle to the configuration node to be parsed.
* \return The control interface index if successful, otherwise a negative error code.
*/
*/
int snd_config_get_ctl_iface(const snd_config_t *conf)
{
long v;
@ -213,14 +213,14 @@ int snd_config_get_ctl_iface(const snd_config_t *conf)
if (err >= 0) {
if (v < 0 || v > SND_CTL_ELEM_IFACE_LAST) {
_invalid_value:
SNDERR("Invalid value for %s", id);
snd_error(CORE, "Invalid value for %s", id);
return -EINVAL;
}
return v;
}
err = snd_config_get_string(conf, &str);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(CORE, "Invalid type for %s", id);
return -EINVAL;
}
err = snd_config_get_ctl_iface_ascii(str);
@ -251,7 +251,7 @@ int snd_config_get_ctl_iface(const snd_config_t *conf)
default 0
}
\endcode
*/
*/
int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
snd_config_t *private_data)
{
@ -260,30 +260,30 @@ int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
const char *res, *id;
char *def = NULL;
int idx = 0, err, hit;
err = snd_config_search(src, "vars", &n);
if (err < 0) {
SNDERR("field vars not found");
snd_error(CORE, "field vars not found");
goto __error;
}
err = snd_config_evaluate(n, root, private_data, NULL);
if (err < 0) {
SNDERR("error evaluating vars");
snd_error(CORE, "error evaluating vars");
goto __error;
}
err = snd_config_search(src, "default", &d);
if (err < 0) {
SNDERR("field default not found");
snd_error(CORE, "field default not found");
goto __error;
}
err = snd_config_evaluate(d, root, private_data, NULL);
if (err < 0) {
SNDERR("error evaluating default");
snd_error(CORE, "error evaluating default");
goto __error;
}
err = snd_config_get_ascii(d, &def);
if (err < 0) {
SNDERR("error getting field default");
snd_error(CORE, "error getting field default");
goto __error;
}
do {
@ -295,13 +295,13 @@ int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
if (snd_config_get_id(n, &id) < 0)
continue;
if (snd_config_get_type(n) != SND_CONFIG_TYPE_STRING) {
SNDERR("field %s is not a string", id);
snd_error(CORE, "field %s is not a string", id);
err = -EINVAL;
goto __error;
}
err = safe_strtol(id, &i);
if (err < 0) {
SNDERR("id of field %s is not an integer", id);
snd_error(CORE, "id of field %s is not an integer", id);
err = -EINVAL;
goto __error;
}
@ -309,7 +309,7 @@ int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
idx++;
err = snd_config_get_string(n, &ptr);
if (err < 0) {
SNDERR("invalid string for id %s", id);
snd_error(CORE, "invalid string for id %s", id);
err = -EINVAL;
goto __error;
}
@ -351,7 +351,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_getenv, SND_CONFIG_DLSYM_VERSION_EVALUATE);
default 0
}
\endcode
*/
*/
int snd_func_igetenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
snd_config_t *private_data)
{
@ -385,7 +385,7 @@ int snd_func_igetenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
#ifndef DOC_HIDDEN
SND_DLSYM_BUILD_VERSION(snd_func_igetenv, SND_CONFIG_DLSYM_VERSION_EVALUATE);
#endif
/**
* \brief Merges the given strings.
* \param dst The function puts the handle to the result configuration node
@ -402,7 +402,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_igetenv, SND_CONFIG_DLSYM_VERSION_EVALUATE);
strings [ "a1" "b2" "c3" ]
}
\endcode
*/
*/
int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
snd_config_t *private_data)
{
@ -411,15 +411,15 @@ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
const char *id;
char *res = NULL, *tmp;
int idx = 0, len = 0, len1, err, hit;
err = snd_config_search(src, "strings", &n);
if (err < 0) {
SNDERR("field strings not found");
snd_error(CORE, "field strings not found");
goto __error;
}
err = snd_config_evaluate(n, root, private_data, NULL);
if (err < 0) {
SNDERR("error evaluating strings");
snd_error(CORE, "error evaluating strings");
goto __error;
}
do {
@ -433,7 +433,7 @@ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
continue;
err = safe_strtol(id, &i);
if (err < 0) {
SNDERR("id of field %s is not an integer", id);
snd_error(CORE, "id of field %s is not an integer", id);
err = -EINVAL;
goto __error;
}
@ -441,7 +441,7 @@ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
idx++;
err = snd_config_get_ascii(n, &ptr);
if (err < 0) {
SNDERR("invalid ascii string for id %s", id);
snd_error(CORE, "invalid ascii string for id %s", id);
err = -EINVAL;
goto __error;
}
@ -462,7 +462,7 @@ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
}
} while (hit);
if (res == NULL) {
SNDERR("empty string is not accepted");
snd_error(CORE, "empty string is not accepted");
err = -EINVAL;
goto __error;
}
@ -490,15 +490,15 @@ static int snd_func_iops(snd_config_t **dst,
char *res = NULL;
long result = 0, val;
int idx = 0, err, hit;
err = snd_config_search(src, "integers", &n);
if (err < 0) {
SNDERR("field integers not found");
snd_error(CORE, "field integers not found");
goto __error;
}
err = snd_config_evaluate(n, root, private_data, NULL);
if (err < 0) {
SNDERR("error evaluating integers");
snd_error(CORE, "error evaluating integers");
goto __error;
}
do {
@ -511,7 +511,7 @@ static int snd_func_iops(snd_config_t **dst,
continue;
err = safe_strtol(id, &i);
if (err < 0) {
SNDERR("id of field %s is not an integer", id);
snd_error(CORE, "id of field %s is not an integer", id);
err = -EINVAL;
goto __error;
}
@ -519,7 +519,7 @@ static int snd_func_iops(snd_config_t **dst,
idx++;
err = snd_config_get_integer(n, &val);
if (err < 0) {
SNDERR("invalid integer for id %s", id);
snd_error(CORE, "invalid integer for id %s", id);
err = -EINVAL;
goto __error;
}
@ -556,9 +556,9 @@ static int snd_func_iops(snd_config_t **dst,
integers [ 2 3 5 ]
}
\endcode
*/
*/
int snd_func_iadd(snd_config_t **dst, snd_config_t *root,
snd_config_t *src, snd_config_t *private_data)
snd_config_t *src, snd_config_t *private_data)
{
return snd_func_iops(dst, root, src, private_data, 0);
}
@ -582,7 +582,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_iadd, SND_CONFIG_DLSYM_VERSION_EVALUATE);
integers [ 2 3 2 ]
}
\endcode
*/
*/
int snd_func_imul(snd_config_t **dst, snd_config_t *root,
snd_config_t *src, snd_config_t *private_data)
{
@ -607,13 +607,13 @@ SND_DLSYM_BUILD_VERSION(snd_func_imul, SND_CONFIG_DLSYM_VERSION_EVALUATE);
@func datadir
}
\endcode
*/
*/
int snd_func_datadir(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED,
snd_config_t *src, snd_config_t *private_data ATTRIBUTE_UNUSED)
{
int err;
const char *id;
err = snd_config_get_id(src, &id);
if (err < 0)
return err;
@ -660,7 +660,7 @@ static int _snd_func_private_data(snd_config_t **dst, snd_config_t *src,
err = snd_config_test_id(*private_data, id);
if (err) {
notfound:
SNDERR("field %s not found", id);
snd_error(CORE, "field %s not found", id);
return -EINVAL;
}
return 0;
@ -683,7 +683,7 @@ notfound:
@func private_string
}
\endcode
*/
*/
int snd_func_private_string(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED,
snd_config_t *src, snd_config_t *private_data)
{
@ -695,7 +695,7 @@ int snd_func_private_string(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNU
return err;
err = snd_config_get_string(private_data, &str);
if (err < 0) {
SNDERR("field string is not a string");
snd_error(CORE, "field string is not a string");
return err;
}
err = snd_config_get_id(src, &id);
@ -736,7 +736,7 @@ int snd_func_private_integer(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UN
return err;
err = snd_config_get_integer(private_data, &val);
if (err < 0) {
SNDERR("field integer is not a string");
snd_error(CORE, "field integer is not a string");
return err;
}
err = snd_config_get_id(src, &id);
@ -759,12 +759,12 @@ int snd_determine_driver(int card, char **driver)
assert(card >= 0 && card <= SND_MAX_CARDS);
err = open_ctl(card, &ctl);
if (err < 0) {
SNDERR("could not open control for card %i", card);
snd_error(CORE, "could not open control for card %i", card);
goto __error;
}
err = snd_ctl_card_info(ctl, &info);
if (err < 0) {
SNDERR("snd_ctl_card_info error: %s", snd_strerror(err));
snd_error(CORE, "snd_ctl_card_info error: %s", snd_strerror(err));
goto __error;
}
res = strdup(snd_ctl_card_info_get_driver(&info));
@ -797,7 +797,7 @@ int snd_determine_driver(int card, char **driver)
@func private_card_driver
}
\endcode
*/
*/
int snd_func_private_card_driver(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *src,
snd_config_t *private_data)
{
@ -808,12 +808,12 @@ int snd_func_private_card_driver(snd_config_t **dst, snd_config_t *root ATTRIBUT
err = snd_config_test_id(private_data, "card");
if (err) {
SNDERR("field card not found");
snd_error(CORE, "field card not found");
return -EINVAL;
}
err = snd_config_get_integer(private_data, &card);
if (err < 0) {
SNDERR("field card is not an integer");
snd_error(CORE, "field card is not an integer");
return err;
}
if ((err = snd_determine_driver(card, &driver)) < 0)
@ -834,25 +834,25 @@ static int parse_card(snd_config_t *root, snd_config_t *src,
snd_config_t *n;
char *str;
int card, err;
err = snd_config_search(src, "card", &n);
if (err < 0) {
SNDERR("field card not found");
snd_error(CORE, "field card not found");
return err;
}
err = snd_config_evaluate(n, root, private_data, NULL);
if (err < 0) {
SNDERR("error evaluating card");
snd_error(CORE, "error evaluating card");
return err;
}
err = snd_config_get_ascii(n, &str);
if (err < 0) {
SNDERR("field card is not an integer or a string");
snd_error(CORE, "field card is not an integer or a string");
return err;
}
card = snd_card_get_index(str);
if (card < 0)
SNDERR("cannot find card '%s'", str);
snd_error(CORE, "cannot find card '%s'", str);
free(str);
return card;
}
@ -873,13 +873,13 @@ static int parse_card(snd_config_t *root, snd_config_t *src,
card '0'
}
\endcode
*/
*/
int snd_func_card_inum(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
snd_config_t *private_data)
{
const char *id;
int card, err;
card = parse_card(root, src, private_data);
if (card < 0)
return card;
@ -908,13 +908,13 @@ SND_DLSYM_BUILD_VERSION(snd_func_card_inum, SND_CONFIG_DLSYM_VERSION_EVALUATE);
card 0
}
\endcode
*/
*/
int snd_func_card_driver(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
snd_config_t *private_data)
{
snd_config_t *val;
int card, err;
card = parse_card(root, src, private_data);
if (card < 0)
return card;
@ -945,7 +945,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_card_driver, SND_CONFIG_DLSYM_VERSION_EVALUATE)
card 0
}
\endcode
*/
*/
int snd_func_card_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
snd_config_t *private_data)
{
@ -953,18 +953,18 @@ int snd_func_card_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
snd_ctl_card_info_t info = {0};
const char *id;
int card, err;
card = parse_card(root, src, private_data);
if (card < 0)
return card;
err = open_ctl(card, &ctl);
if (err < 0) {
SNDERR("could not open control for card %i", card);
snd_error(CORE, "could not open control for card %i", card);
goto __error;
}
err = snd_ctl_card_info(ctl, &info);
if (err < 0) {
SNDERR("snd_ctl_card_info error: %s", snd_strerror(err));
snd_error(CORE, "snd_ctl_card_info error: %s", snd_strerror(err));
goto __error;
}
err = snd_config_get_id(src, &id);
@ -972,8 +972,8 @@ int snd_func_card_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
err = snd_config_imake_string(dst, id,
snd_ctl_card_info_get_id(&info));
__error:
if (ctl)
snd_ctl_close(ctl);
if (ctl)
snd_ctl_close(ctl);
return err;
}
#ifndef DOC_HIDDEN
@ -996,7 +996,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_card_id, SND_CONFIG_DLSYM_VERSION_EVALUATE);
card 0
}
\endcode
*/
*/
int snd_func_card_name(snd_config_t **dst, snd_config_t *root,
snd_config_t *src, snd_config_t *private_data)
{
@ -1004,18 +1004,18 @@ int snd_func_card_name(snd_config_t **dst, snd_config_t *root,
snd_ctl_card_info_t info = {0};
const char *id;
int card, err;
card = parse_card(root, src, private_data);
if (card < 0)
return card;
err = open_ctl(card, &ctl);
if (err < 0) {
SNDERR("could not open control for card %i", card);
snd_error(CORE, "could not open control for card %i", card);
goto __error;
}
err = snd_ctl_card_info(ctl, &info);
if (err < 0) {
SNDERR("snd_ctl_card_info error: %s", snd_strerror(err));
snd_error(CORE, "snd_ctl_card_info error: %s", snd_strerror(err));
goto __error;
}
err = snd_config_get_id(src, &id);
@ -1023,8 +1023,8 @@ int snd_func_card_name(snd_config_t **dst, snd_config_t *root,
err = snd_config_imake_safe_string(dst, id,
snd_ctl_card_info_get_name(&info));
__error:
if (ctl)
snd_ctl_close(ctl);
if (ctl)
snd_ctl_close(ctl);
return err;
}
#ifndef DOC_HIDDEN
@ -1033,7 +1033,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_card_name, SND_CONFIG_DLSYM_VERSION_EVALUATE);
#ifdef DOXYGEN
/* For consistency with the PCM Interface module, include documentation even
* when PCM module is not included in the build. */
* when PCM module is not included in the build. */
#ifndef BUILD_PCM
#define BUILD_PCM
#endif
@ -1060,7 +1060,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_card_name, SND_CONFIG_DLSYM_VERSION_EVALUATE);
subdevice 0 # optional
}
\endcode
*/
*/
int snd_func_pcm_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data)
{
snd_config_t *n;
@ -1069,47 +1069,47 @@ int snd_func_pcm_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, v
const char *id;
long card, device, subdevice = 0;
int err;
card = parse_card(root, src, private_data);
if (card < 0)
return card;
err = snd_config_search(src, "device", &n);
if (err < 0) {
SNDERR("field device not found");
snd_error(CORE, "field device not found");
goto __error;
}
err = snd_config_evaluate(n, root, private_data, NULL);
if (err < 0) {
SNDERR("error evaluating device");
snd_error(CORE, "error evaluating device");
goto __error;
}
err = snd_config_get_integer(n, &device);
if (err < 0) {
SNDERR("field device is not an integer");
snd_error(CORE, "field device is not an integer");
goto __error;
}
if (snd_config_search(src, "subdevice", &n) >= 0) {
err = snd_config_evaluate(n, root, private_data, NULL);
if (err < 0) {
SNDERR("error evaluating subdevice");
snd_error(CORE, "error evaluating subdevice");
goto __error;
}
err = snd_config_get_integer(n, &subdevice);
if (err < 0) {
SNDERR("field subdevice is not an integer");
snd_error(CORE, "field subdevice is not an integer");
goto __error;
}
}
err = open_ctl(card, &ctl);
if (err < 0) {
SNDERR("could not open control for card %li", card);
snd_error(CORE, "could not open control for card %li", card);
goto __error;
}
snd_pcm_info_set_device(&info, device);
snd_pcm_info_set_subdevice(&info, subdevice);
err = snd_ctl_pcm_info(ctl, &info);
if (err < 0) {
SNDERR("snd_ctl_pcm_info error: %s", snd_strerror(err));
snd_error(CORE, "snd_ctl_pcm_info error: %s", snd_strerror(err));
goto __error;
}
err = snd_config_get_id(src, &id);
@ -1117,8 +1117,8 @@ int snd_func_pcm_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, v
err = snd_config_imake_string(dst, id,
snd_pcm_info_get_id(&info));
__error:
if (ctl)
snd_ctl_close(ctl);
if (ctl)
snd_ctl_close(ctl);
return err;
}
#ifndef DOC_HIDDEN
@ -1144,7 +1144,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_pcm_id, SND_CONFIG_DLSYM_VERSION_EVALUATE);
index 0
}
\endcode
*/
*/
int snd_func_pcm_args_by_class(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data)
{
snd_config_t *n;
@ -1158,53 +1158,53 @@ int snd_func_pcm_args_by_class(snd_config_t **dst, snd_config_t *root, snd_confi
err = snd_config_search(src, "class", &n);
if (err < 0) {
SNDERR("field class not found");
snd_error(CORE, "field class not found");
goto __out;
}
err = snd_config_evaluate(n, root, private_data, NULL);
if (err < 0) {
SNDERR("error evaluating class");
snd_error(CORE, "error evaluating class");
goto __out;
}
err = snd_config_get_integer(n, &class);
if (err < 0) {
SNDERR("field class is not an integer");
snd_error(CORE, "field class is not an integer");
goto __out;
}
err = snd_config_search(src, "index", &n);
if (err < 0) {
SNDERR("field index not found");
snd_error(CORE, "field index not found");
goto __out;
}
err = snd_config_evaluate(n, root, private_data, NULL);
if (err < 0) {
SNDERR("error evaluating index");
snd_error(CORE, "error evaluating index");
goto __out;
}
err = snd_config_get_integer(n, &index);
if (err < 0) {
SNDERR("field index is not an integer");
snd_error(CORE, "field index is not an integer");
goto __out;
}
while(1) {
err = snd_card_next(&card);
if (err < 0) {
SNDERR("could not get next card");
snd_error(CORE, "could not get next card");
goto __out;
}
if (card < 0)
break;
err = open_ctl(card, &ctl);
if (err < 0) {
SNDERR("could not open control for card %i", card);
snd_error(CORE, "could not open control for card %i", card);
goto __out;
}
dev = -1;
while(1) {
err = snd_ctl_pcm_next_device(ctl, &dev);
if (err < 0) {
SNDERR("could not get next pcm for card %i", card);
snd_error(CORE, "could not get next pcm for card %i", card);
goto __out;
}
if (dev < 0)
@ -1217,14 +1217,14 @@ int snd_func_pcm_args_by_class(snd_config_t **dst, snd_config_t *root, snd_confi
index == idx++)
goto __out;
}
snd_ctl_close(ctl);
snd_ctl_close(ctl);
ctl = NULL;
}
err = -ENODEV;
__out:
if (ctl)
snd_ctl_close(ctl);
if (ctl)
snd_ctl_close(ctl);
if (err < 0)
return err;
if((err = snd_config_get_id(src, &id)) >= 0) {
@ -1254,7 +1254,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_pcm_args_by_class, SND_CONFIG_DLSYM_VERSION_EVA
@func private_pcm_subdevice
}
\endcode
*/
*/
int snd_func_private_pcm_subdevice(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED,
snd_config_t *src, snd_config_t *private_data)
{
@ -1268,18 +1268,18 @@ int snd_func_private_pcm_subdevice(snd_config_t **dst, snd_config_t *root ATTRIB
return snd_config_copy(dst, src);
err = snd_config_test_id(private_data, "pcm_handle");
if (err) {
SNDERR("field pcm_handle not found");
snd_error(CORE, "field pcm_handle not found");
return -EINVAL;
}
err = snd_config_get_pointer(private_data, &data);
pcm = (snd_pcm_t *)data;
if (err < 0) {
SNDERR("field pcm_handle is not a pointer");
snd_error(CORE, "field pcm_handle is not a pointer");
return err;
}
err = snd_pcm_info(pcm, &info);
if (err < 0) {
SNDERR("snd_ctl_pcm_info error: %s", snd_strerror(err));
snd_error(CORE, "snd_ctl_pcm_info error: %s", snd_strerror(err));
return err;
}
err = snd_config_get_id(src, &id);
@ -1314,24 +1314,24 @@ SND_DLSYM_BUILD_VERSION(snd_func_private_pcm_subdevice, SND_CONFIG_DLSYM_VERSION
name "id1.id2.id3"
}
\endcode
*/
*/
int snd_func_refer(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
snd_config_t *private_data)
{
snd_config_t *n;
const char *file = NULL, *name = NULL;
int err;
err = snd_config_search(src, "file", &n);
if (err >= 0) {
err = snd_config_evaluate(n, root, private_data, NULL);
if (err < 0) {
SNDERR("error evaluating file");
snd_error(CORE, "error evaluating file");
goto _end;
}
err = snd_config_get_string(n, &file);
if (err < 0) {
SNDERR("file is not a string");
snd_error(CORE, "file is not a string");
goto _end;
}
}
@ -1339,25 +1339,25 @@ int snd_func_refer(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
if (err >= 0) {
err = snd_config_evaluate(n, root, private_data, NULL);
if (err < 0) {
SNDERR("error evaluating name");
snd_error(CORE, "error evaluating name");
goto _end;
}
err = snd_config_get_string(n, &name);
if (err < 0) {
SNDERR("name is not a string");
snd_error(CORE, "name is not a string");
goto _end;
}
}
if (!name) {
err = -EINVAL;
SNDERR("name is not specified");
snd_error(CORE, "name is not specified");
goto _end;
}
if (file) {
snd_input_t *input;
err = snd_input_stdio_open(&input, file, "r");
if (err < 0) {
SNDERR("Unable to open file %s: %s", file, snd_strerror(err));
snd_error(CORE, "Unable to open file %s: %s", file, snd_strerror(err));
goto _end;
}
err = snd_config_load(root, input);
@ -1374,7 +1374,7 @@ int snd_func_refer(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
} else {
err = snd_config_search(src, "default", &n);
if (err < 0)
SNDERR("Unable to find definition '%s'", name);
snd_error(CORE, "Unable to find definition '%s'", name);
else {
const char *id;
err = snd_config_evaluate(n, root, private_data, NULL);

View file

@ -108,7 +108,7 @@ int snd_card_load(int card)
int snd_card_next(int *rcard)
{
int card;
if (rcard == NULL)
return -EINVAL;
card = *rcard;
@ -194,7 +194,7 @@ int snd_card_get_name(int card, char **name)
snd_ctl_t *handle;
snd_ctl_card_info_t info;
int err;
if (name == NULL)
return -EINVAL;
if ((err = snd_ctl_hw_open(&handle, NULL, card, 0)) < 0)
@ -224,7 +224,7 @@ int snd_card_get_longname(int card, char **name)
snd_ctl_t *handle;
snd_ctl_card_info_t info;
int err;
if (name == NULL)
return -EINVAL;
if ((err = snd_ctl_hw_open(&handle, NULL, card, 0)) < 0)

View file

@ -52,7 +52,7 @@ file. The format is:
\verbatim
index [ID ] Driver - name
longname
longname
\endverbatim
Note that the mixername and components are not listed.
@ -279,7 +279,7 @@ int snd_ctl_new(snd_ctl_t **ctlp, snd_ctl_type_t type, const char *name, int mod
*ctlp = ctl;
return 0;
}
/**
* \brief set async mode
@ -353,7 +353,7 @@ int snd_ctl_poll_descriptors_revents(snd_ctl_t *ctl, struct pollfd *pfds, unsign
return ctl->ops->poll_revents(ctl, pfds, nfds, revents);
if (nfds == 1) {
*revents = pfds->revents;
return 0;
return 0;
}
return -EINVAL;
}
@ -1039,7 +1039,7 @@ int snd_ctl_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *data)
static int snd_ctl_tlv_do(snd_ctl_t *ctl, int op_flag,
const snd_ctl_elem_id_t *id,
unsigned int *tlv, unsigned int tlv_size)
unsigned int *tlv, unsigned int tlv_size)
{
snd_ctl_elem_info_t *info = NULL;
int err;
@ -1060,8 +1060,8 @@ static int snd_ctl_tlv_do(snd_ctl_t *ctl, int op_flag,
}
err = ctl->ops->element_tlv(ctl, op_flag, id->numid, tlv, tlv_size);
__err:
if (info)
free(info);
if (info)
free(info);
return err;
}
@ -1367,7 +1367,7 @@ int snd_ctl_wait(snd_ctl_t *ctl, int timeout)
npfds = snd_ctl_poll_descriptors_count(ctl);
if (npfds <= 0 || npfds >= 16) {
SNDERR("Invalid poll_fds %d", npfds);
snd_error(CONTROL, "Invalid poll_fds %d", npfds);
return -EIO;
}
pfd = alloca(sizeof(*pfd) * npfds);
@ -1375,7 +1375,7 @@ int snd_ctl_wait(snd_ctl_t *ctl, int timeout)
if (err < 0)
return err;
if (err != npfds) {
SNDMSG("invalid poll descriptors %d", err);
snd_check(CONTROL, "invalid poll descriptors %d", err);
return -EIO;
}
for (;;) {
@ -1402,7 +1402,7 @@ int snd_ctl_wait(snd_ctl_t *ctl, int timeout)
* \param private_data Callback private data
* \return 0 otherwise a negative error code on failure
*/
int snd_async_add_ctl_handler(snd_async_handler_t **handler, snd_ctl_t *ctl,
int snd_async_add_ctl_handler(snd_async_handler_t **handler, snd_ctl_t *ctl,
snd_async_callback_t callback, void *private_data)
{
int err;
@ -1458,30 +1458,30 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
#endif
if (snd_config_get_type(ctl_conf) != SND_CONFIG_TYPE_COMPOUND) {
if (name)
SNDERR("Invalid type for CTL %s definition", name);
snd_error(CONTROL, "Invalid type for CTL %s definition", name);
else
SNDERR("Invalid type for CTL definition");
snd_error(CONTROL, "Invalid type for CTL definition");
return -EINVAL;
}
err = snd_config_search(ctl_conf, "type", &conf);
if (err < 0) {
SNDERR("type is not defined");
snd_error(CONTROL, "type is not defined");
return err;
}
err = snd_config_get_id(conf, &id);
if (err < 0) {
SNDERR("unable to get id");
snd_error(CONTROL, "unable to get id");
return err;
}
err = snd_config_get_string(conf, &str);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(CONTROL, "Invalid type for %s", id);
return err;
}
err = snd_config_search_definition(ctl_root, "ctl_type", str, &type_conf);
if (err >= 0) {
if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid type for CTL type %s definition", str);
snd_error(CONTROL, "Invalid type for CTL type %s definition", str);
err = -EINVAL;
goto _err;
}
@ -1495,7 +1495,7 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
if (strcmp(id, "lib") == 0) {
err = snd_config_get_string(n, &lib);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(CONTROL, "Invalid type for %s", id);
goto _err;
}
continue;
@ -1503,12 +1503,12 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
if (strcmp(id, "open") == 0) {
err = snd_config_get_string(n, &open_name);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(CONTROL, "Invalid type for %s", id);
goto _err;
}
continue;
}
SNDERR("Unknown field %s", id);
snd_error(CONTROL, "Unknown field %s", id);
err = -EINVAL;
goto _err;
}
@ -1572,7 +1572,7 @@ static int snd_ctl_open_noupdate(snd_ctl_t **ctlp, snd_config_t *root,
err = snd_config_search_definition(root, "ctl", name, &ctl_conf);
if (err < 0) {
SNDERR("Invalid CTL %s", name);
snd_error(CONTROL, "Invalid CTL %s", name);
return err;
}
if (snd_config_get_string(ctl_conf, &str) >= 0)
@ -1752,7 +1752,7 @@ int snd_ctl_elem_list_alloc_space(snd_ctl_elem_list_t *obj, unsigned int entries
}
obj->space = entries;
return 0;
}
}
/**
* \brief free previously allocated space for CTL element identifiers list

View file

@ -87,11 +87,11 @@ int _snd_ctl_empty_open(snd_ctl_t **handlep, const char *name ATTRIBUTE_UNUSED,
child = n;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(CONTROL, "Unknown field %s", id);
return -EINVAL;
}
if (!child) {
SNDERR("child is not defined");
snd_error(CONTROL, "child is not defined");
return -EINVAL;
}
return _snd_ctl_open_named_child(handlep, name, root, child, mode, conf);

View file

@ -42,7 +42,7 @@ const char *_snd_module_control_ext = "";
static int snd_ctl_ext_close(snd_ctl_t *handle)
{
snd_ctl_ext_t *ext = handle->private_data;
if (ext->callback->close)
ext->callback->close(ext);
return 0;
@ -458,7 +458,7 @@ static int snd_ctl_ext_poll_revents(snd_ctl_t *handle, struct pollfd *pfds, unsi
return ext->callback->poll_revents(ext, pfds, nfds, revents);
if (nfds == 1) {
*revents = pfds->revents;
return 0;
return 0;
}
return -EINVAL;
}
@ -529,7 +529,7 @@ usually you will call the external plugin API function
#snd_ctl_ext_create().
The control handle must be filled *phandle in return.
Then this function must return either a value 0 when succeeded, or a
negative value as the error code.
negative value as the error code.
Finally, add #SND_CTL_PLUGIN_SYMBOL() with the name of your
plugin as the argument at the end. This defines the proper versioned
@ -560,7 +560,7 @@ SND_CTL_PLUGIN_DEFINE_FUNC(myctl)
....
continue;
}
SNDERR("Unknown field %s", id);
snd_error(CONTROL, "Unknown field %s", id);
return -EINVAL;
}
@ -625,7 +625,7 @@ PCM.
\section ctl_ext_impl_cb Callback Functions of External Control Plugins
The callback functions in #snd_ctl_ext_callback_t define the real
behavior of the driver. There are many callbacks but many of them are optional.
behavior of the driver. There are many callbacks but many of them are optional.
The close callback is called when the PCM is closed. If the plugin
allocates private resources, this is the place to release them
@ -650,7 +650,7 @@ if you use get, read and write callbacks as follows.
If you need to create a record dynamically (e.g. via malloc) at each find_elem call,
the allocated record can be released with the optional free_key callback.
The get_attribute is a mandatory callback, which returns the attribute of the
The get_attribute is a mandatory callback, which returns the attribute of the
control element given via a key value (converted with find_elem callback).
It must fill the control element type (#snd_ctl_elem_type_t), the access type
(#snd_ctl_ext_access_t), and the count (element array size). The callback returns
@ -712,7 +712,7 @@ int snd_ctl_ext_create(snd_ctl_ext_t *ext, const char *name, int mode)
if (ext->version < SNDRV_PROTOCOL_VERSION(1, 0, 0) ||
ext->version > SND_CTL_EXT_VERSION) {
SNDERR("ctl_ext: Plugin version mismatch");
snd_error(CONTROL, "ctl_ext: Plugin version mismatch");
return -ENXIO;
}

View file

@ -71,7 +71,7 @@ static int snd_ctl_hw_nonblock(snd_ctl_t *handle, int nonblock)
long flags;
int fd = hw->fd;
if ((flags = fcntl(fd, F_GETFL)) < 0) {
SYSERR("F_GETFL failed");
snd_errornum(CONTROL, "F_GETFL failed");
return -errno;
}
if (nonblock)
@ -79,7 +79,7 @@ static int snd_ctl_hw_nonblock(snd_ctl_t *handle, int nonblock)
else
flags &= ~O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags) < 0) {
SYSERR("F_SETFL for O_NONBLOCK failed");
snd_errornum(CONTROL, "F_SETFL for O_NONBLOCK failed");
return -errno;
}
return 0;
@ -92,7 +92,7 @@ static int snd_ctl_hw_async(snd_ctl_t *ctl, int sig, pid_t pid)
int fd = hw->fd;
if ((flags = fcntl(fd, F_GETFL)) < 0) {
SYSERR("F_GETFL failed");
snd_errornum(CONTROL, "F_GETFL failed");
return -errno;
}
if (sig >= 0)
@ -100,17 +100,17 @@ static int snd_ctl_hw_async(snd_ctl_t *ctl, int sig, pid_t pid)
else
flags &= ~O_ASYNC;
if (fcntl(fd, F_SETFL, flags) < 0) {
SYSERR("F_SETFL for O_ASYNC failed");
snd_errornum(CONTROL, "F_SETFL for O_ASYNC failed");
return -errno;
}
if (sig < 0)
return 0;
if (fcntl(fd, F_SETSIG, (long)sig) < 0) {
SYSERR("F_SETSIG failed");
snd_errornum(CONTROL, "F_SETSIG failed");
return -errno;
}
if (fcntl(fd, F_SETOWN, (long)pid) < 0) {
SYSERR("F_SETOWN failed");
snd_errornum(CONTROL, "F_SETOWN failed");
return -errno;
}
return 0;
@ -120,7 +120,7 @@ static int snd_ctl_hw_subscribe_events(snd_ctl_t *handle, int subscribe)
{
snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS, &subscribe) < 0) {
SYSERR("SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS failed");
snd_errornum(CONTROL, "SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS failed");
return -errno;
}
return 0;
@ -130,7 +130,7 @@ static int snd_ctl_hw_card_info(snd_ctl_t *handle, snd_ctl_card_info_t *info)
{
snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_CARD_INFO, info) < 0) {
SYSERR("SNDRV_CTL_IOCTL_CARD_INFO failed");
snd_errornum(CONTROL, "SNDRV_CTL_IOCTL_CARD_INFO failed");
return -errno;
}
return 0;
@ -225,20 +225,20 @@ static int snd_ctl_hw_elem_tlv(snd_ctl_t *handle, int op_flag,
unsigned int inum;
snd_ctl_hw_t *hw = handle->private_data;
struct snd_ctl_tlv *xtlv;
/* we don't support TLV on protocol ver 2.0.3 or earlier */
if (hw->protocol < SNDRV_PROTOCOL_VERSION(2, 0, 4))
return -ENXIO;
switch (op_flag) {
case -1: inum = SNDRV_CTL_IOCTL_TLV_COMMAND; break;
case 0: inum = SNDRV_CTL_IOCTL_TLV_READ; break;
case 0: inum = SNDRV_CTL_IOCTL_TLV_READ; break;
case 1: inum = SNDRV_CTL_IOCTL_TLV_WRITE; break;
default: return -EINVAL;
}
xtlv = malloc(sizeof(struct snd_ctl_tlv) + tlv_size);
if (xtlv == NULL)
return -ENOMEM;
return -ENOMEM;
xtlv->numid = numid;
xtlv->length = tlv_size;
memcpy(xtlv->tlv, tlv, tlv_size);
@ -375,8 +375,9 @@ static int snd_ctl_hw_read(snd_ctl_t *handle, snd_ctl_event_t *event)
if (res <= 0)
return -errno;
if (CHECK_SANITY(res != sizeof(*event))) {
SNDMSG("snd_ctl_hw_read: read size error (req:%d, got:%d)",
sizeof(*event), res);
snd_check(CONTROL, "snd_ctl_hw_read: read size error (req:%d, got:%d)",
sizeof(*event), res);
return -EINVAL;
}
return 1;
@ -434,10 +435,10 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode)
snd_ctl_hw_t *hw;
int err;
*handle = NULL;
*handle = NULL;
if (CHECK_SANITY(card < 0 || card >= SND_MAX_CARDS)) {
SNDMSG("Invalid card index %d", card);
snd_check(CONTROL, "Invalid card index %d", card);
return -EINVAL;
}
sprintf(filename, SNDRV_FILE_CONTROL, card);

View file

@ -85,7 +85,7 @@ struct _snd_hctl_elem {
struct _snd_hctl {
snd_ctl_t *ctl;
struct list_head elems; /* list of all controls */
unsigned int alloc;
unsigned int alloc;
unsigned int count;
snd_hctl_elem_t **pelems;
snd_hctl_compare_t compare;

View file

@ -1242,27 +1242,27 @@ static int parse_remap(snd_ctl_remap_t *priv, snd_config_t *conf)
if (snd_config_get_id(n, &id) < 0)
continue;
if (snd_config_get_string(n, &str) < 0) {
SNDERR("expected string with the target control id!");
snd_error(CONTROL, "expected string with the target control id!");
return -EINVAL;
}
snd_ctl_elem_id_clear(&app);
err = snd_ctl_ascii_elem_id_parse(&app, str);
if (err < 0) {
SNDERR("unable to parse target id '%s'!", str);
snd_error(CONTROL, "unable to parse target id '%s'!", str);
return -EINVAL;
}
if (remap_find_id_app(priv, &app)) {
SNDERR("duplicate target id '%s'!", id);
snd_error(CONTROL, "duplicate target id '%s'!", id);
return -EINVAL;
}
snd_ctl_elem_id_clear(&child);
err = snd_ctl_ascii_elem_id_parse(&child, id);
if (err < 0) {
SNDERR("unable to parse source id '%s'!", id);
snd_error(CONTROL, "unable to parse source id '%s'!", id);
return -EINVAL;
}
if (remap_find_id_child(priv, &app)) {
SNDERR("duplicate source id '%s'!", id);
snd_error(CONTROL, "duplicate source id '%s'!", id);
return -EINVAL;
}
err = add_to_remap(priv, &child, &app);
@ -1321,7 +1321,7 @@ static int add_chn_to_map(struct snd_ctl_map_ctl *mctl, long idx, long src_idx,
long *map;
if (src_idx >= mctl->src_channels) {
SNDERR("Wrong channel mapping (extra source channel?)");
snd_error(CONTROL, "Wrong channel mapping (extra source channel?)");
return -EINVAL;
}
if (mctl->channel_map_alloc <= (size_t)idx) {
@ -1350,7 +1350,7 @@ static int add_chn_to_map_array(struct snd_ctl_map_ctl *mctl, const char *dst_id
snd_config_t *n = snd_config_iterator_entry(i);
long idx = -1, chn = -1;
if (safe_strtol(dst_id, &idx) || snd_config_get_integer(n, &chn)) {
SNDERR("Wrong channel mapping (%ld -> %ld)", idx, chn);
snd_error(CONTROL, "Wrong channel mapping (%ld -> %ld)", idx, chn);
return -EINVAL;
}
err = add_chn_to_map(mctl, idx, src_idx, chn);
@ -1383,7 +1383,7 @@ static int parse_map_vindex(struct snd_ctl_map_ctl *mctl, snd_config_t *conf)
err = add_chn_to_map_array(mctl, id, n);
} else {
if (safe_strtol(id, &idx) || snd_config_get_integer(n, &chn)) {
SNDERR("Wrong channel mapping (%ld -> %ld)", idx, chn);
snd_error(CONTROL, "Wrong channel mapping (%ld -> %ld)", idx, chn);
return -EINVAL;
}
err = add_chn_to_map(mctl, idx, 0, chn);
@ -1430,7 +1430,7 @@ static int parse_map1(snd_ctl_map_t *map, snd_config_t *conf)
snd_ctl_elem_id_clear(&cid);
err = snd_ctl_ascii_elem_id_parse(&cid, id);
if (err < 0) {
SNDERR("unable to parse control id '%s'!", id);
snd_error(CONTROL, "unable to parse control id '%s'!", id);
return -EINVAL;
}
err = add_ctl_to_map(map, &mctl, &cid);
@ -1461,7 +1461,7 @@ static int parse_map(snd_ctl_remap_t *priv, snd_config_t *conf)
snd_ctl_elem_id_clear(&eid);
err = snd_ctl_ascii_elem_id_parse(&eid, id);
if (err < 0) {
SNDERR("unable to parse id '%s'!", id);
snd_error(CONTROL, "unable to parse id '%s'!", id);
return -EINVAL;
}
err = new_map(priv, &map, &eid);
@ -1508,14 +1508,14 @@ static int parse_sync1(snd_ctl_remap_t *priv, unsigned int count, snd_config_t *
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
if (snd_config_get_string(n, &str) < 0) {
SNDERR("strings are expected in sync array");
snd_error(CONTROL, "strings are expected in sync array");
return -EINVAL;
}
eid = &sync->control_ids[index];
snd_ctl_elem_id_clear(eid);
err = snd_ctl_ascii_elem_id_parse(eid, str);
if (err < 0) {
SNDERR("unable to parse control id '%s'!", str);
snd_error(CONTROL, "unable to parse control id '%s'!", str);
return -EINVAL;
}
sync->control_items++;
@ -1542,12 +1542,12 @@ static int parse_sync_compound(snd_ctl_remap_t *priv, snd_config_t *conf)
continue;
if (strcmp(id, "switch") == 0) {
if (snd_config_get_string(n, &str) < 0) {
SNDERR("String is expected for switch");
snd_error(CONTROL, "String is expected for switch");
return -EINVAL;
}
err = snd_ctl_ascii_elem_id_parse(&eid, str);
if (err < 0) {
SNDERR("unable to parse id '%s'!", str);
snd_error(CONTROL, "unable to parse id '%s'!", str);
return -EINVAL;
}
eid_found = true;
@ -1555,7 +1555,7 @@ static int parse_sync_compound(snd_ctl_remap_t *priv, snd_config_t *conf)
if (strcmp(id, "controls") == 0) {
count = snd_config_is_array(n);
if (count <= 0) {
SNDERR("Array is expected for sync!");
snd_error(CONTROL, "Array is expected for sync!");
return -EINVAL;
}
err = parse_sync1(priv, count, n);
@ -1591,7 +1591,7 @@ static int parse_sync(snd_ctl_remap_t *priv, snd_config_t *conf)
} else {
count = snd_config_is_array(n);
if (count <= 0) {
SNDERR("Array is expected for sync!");
snd_error(CONTROL, "Array is expected for sync!");
return -EINVAL;
}
err = parse_sync1(priv, count, n);
@ -1817,11 +1817,11 @@ int _snd_ctl_remap_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd
child = n;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(CONTROL, "Unknown field %s", id);
return -EINVAL;
}
if (!child) {
SNDERR("child is not defined");
snd_error(CONTROL, "child is not defined");
return -EINVAL;
}
err = _snd_ctl_open_child(&cctl, root, child, mode, conf);

View file

@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
@ -60,7 +60,7 @@ static int snd_ctl_shm_action(snd_ctl_t *ctl)
if (err != 1)
return -EBADFD;
if (ctrl->cmd) {
SNDERR("Server has not done the cmd");
snd_error(CONTROL, "Server has not done the cmd");
return -EBADFD;
}
return ctrl->result;
@ -79,7 +79,7 @@ static int snd_ctl_shm_action_fd(snd_ctl_t *ctl, int *fd)
if (err != 1)
return -EBADFD;
if (ctrl->cmd) {
SNDERR("Server has not done the cmd");
snd_error(CONTROL, "Server has not done the cmd");
return -EBADFD;
}
return ctrl->result;
@ -420,7 +420,7 @@ static int make_local_socket(const char *filename)
sock = socket(PF_LOCAL, SOCK_STREAM, 0);
if (sock < 0)
return -errno;
addr->sun_family = AF_LOCAL;
memcpy(addr->sun_path, filename, l);
@ -448,7 +448,7 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname
result = make_local_socket(sockname);
if (result < 0) {
SNDERR("server for socket %s is not running", sockname);
snd_error(CONTROL, "server for socket %s is not running", sockname);
goto _err;
}
sock = result;
@ -463,23 +463,23 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname
req->namelen = snamelen;
err = write(sock, req, reqlen);
if (err < 0) {
SNDERR("write error");
snd_error(CONTROL, "write error");
result = -errno;
goto _err;
}
if ((size_t) err != reqlen) {
SNDERR("write size error");
snd_error(CONTROL, "write size error");
result = -EINVAL;
goto _err;
}
err = read(sock, &ans, sizeof(ans));
if (err < 0) {
SNDERR("read error");
snd_error(CONTROL, "read error");
result = -errno;
goto _err;
}
if (err != sizeof(ans)) {
SNDERR("read size error");
snd_error(CONTROL, "read size error");
result = -EINVAL;
goto _err;
}
@ -492,7 +492,7 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname
result = -errno;
goto _err;
}
shm = calloc(1, sizeof(snd_ctl_shm_t));
if (!shm) {
result = -ENOMEM;
@ -546,7 +546,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_c
if (strcmp(id, "server") == 0) {
err = snd_config_get_string(n, &server);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(CONTROL, "Invalid type for %s", id);
return -EINVAL;
}
continue;
@ -554,29 +554,29 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_c
if (strcmp(id, "ctl") == 0) {
err = snd_config_get_string(n, &ctl_name);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(CONTROL, "Invalid type for %s", id);
return -EINVAL;
}
continue;
}
SNDERR("Unknown field %s", id);
snd_error(CONTROL, "Unknown field %s", id);
return -EINVAL;
}
if (!ctl_name) {
SNDERR("ctl is not defined");
snd_error(CONTROL, "ctl is not defined");
return -EINVAL;
}
if (!server) {
SNDERR("server is not defined");
snd_error(CONTROL, "server is not defined");
return -EINVAL;
}
err = snd_config_search_definition(root, "server", server, &sconfig);
if (err < 0) {
SNDERR("Unknown server %s", server);
snd_error(CONTROL, "Unknown server %s", server);
return -EINVAL;
}
if (snd_config_get_type(sconfig) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid type for server %s definition", server);
snd_error(CONTROL, "Invalid type for server %s definition", server);
err = -EINVAL;
goto _err;
}
@ -592,7 +592,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_c
if (strcmp(id, "socket") == 0) {
err = snd_config_get_string(n, &sockname);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(CONTROL, "Invalid type for %s", id);
goto _err;
}
continue;
@ -600,18 +600,18 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_c
if (strcmp(id, "port") == 0) {
err = snd_config_get_integer(n, &port);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(CONTROL, "Invalid type for %s", id);
goto _err;
}
continue;
}
SNDERR("Unknown field %s", id);
snd_error(CONTROL, "Unknown field %s", id);
err = -EINVAL;
goto _err;
}
if (!sockname) {
SNDERR("socket is not defined");
snd_error(CONTROL, "socket is not defined");
goto _err;
}
err = snd_ctl_shm_open(handlep, name, sockname, ctl_name, mode);

View file

@ -31,7 +31,7 @@ static const char **snd_control_open_objects[] = {
&_snd_module_control_empty,
#include "ctl_symbols_list.c"
};
void *snd_control_open_symbols(void)
{
return snd_control_open_objects;

View file

@ -253,7 +253,7 @@ int __snd_ctl_ascii_elem_id_parse(snd_ctl_elem_id_t *dst, const char *str,
if (*str)
goto out;
}
}
}
err = 0;
out:
@ -277,12 +277,12 @@ int snd_ctl_ascii_elem_id_parse(snd_ctl_elem_id_t *dst, const char *str)
static int get_ctl_enum_item_index(snd_ctl_t *handle,
snd_ctl_elem_info_t *info,
const char **ptrp)
{
{
char *ptr = (char *)*ptrp;
int items, i, len;
const char *name;
char end;
items = snd_ctl_elem_info_get_items(info);
if (items <= 0)
return -1;
@ -362,7 +362,7 @@ int snd_ctl_ascii_value_parse(snd_ctl_t *handle,
if (count > get_ctl_type_max_elements(type))
count = get_ctl_type_max_elements(type);
for (idx = 0; idx < count && ptr && *ptr; idx++) {
if (*ptr == ',')
goto skip;

View file

@ -53,7 +53,7 @@ int __snd_pcm_info_eld_fixup(snd_pcm_info_t * info)
ret = snd_ctl_hw_open(&ctl, NULL, info->card, 0);
if (ret < 0) {
SYSMSG("Cannot open the associated CTL");
snd_checknum(CONTROL, "Cannot open the associated CTL");
return ret;
}
@ -66,7 +66,7 @@ int __snd_pcm_info_eld_fixup(snd_pcm_info_t * info)
if (ret == -ENOENT || cinfo.type != SND_CTL_ELEM_TYPE_BYTES || cinfo.count == 0)
return 0;
if (ret < 0) {
SYSMSG("Cannot read ELD");
snd_checknum(CONTROL, "Cannot read ELD");
return ret;
}
/* decode connected HDMI device name */
@ -78,7 +78,7 @@ int __snd_pcm_info_eld_fixup(snd_pcm_info_t * info)
/* no monitor name detected */
goto __present;
if (l > 16 || 20 + l > cinfo.count) {
SNDERR("ELD decode failed, using old HDMI output names");
snd_error(CONTROL, "ELD decode failed, using old HDMI output names");
return 0;
}
s = alloca(l + 1);

View file

@ -71,7 +71,7 @@ int snd_hctl_open(snd_hctl_t **hctlp, const char *name, int mode)
{
snd_ctl_t *ctl;
int err;
if ((err = snd_ctl_open(&ctl, name, mode)) < 0)
return err;
err = snd_hctl_open_ctl(hctlp, ctl);
@ -294,7 +294,7 @@ static int get_compare_weight(const snd_ctl_elem_id_t *id)
};
const char *name = (char *)id->name, *name1;
int res, res1;
if ((res = snd_hctl_compare_mixer_priority_lookup((const char **)&name, names, 1000000)) == NOT_FOUND)
return NOT_FOUND;
if (*name == '\0')
@ -346,7 +346,7 @@ static int _snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *id, in
static int snd_hctl_elem_add(snd_hctl_t *hctl, snd_hctl_elem_t *elem)
{
int dir;
int idx;
int idx;
elem->compare_weight = get_compare_weight(&elem->id);
if (hctl->count == hctl->alloc) {
snd_hctl_elem_t **h;
@ -677,10 +677,10 @@ int snd_hctl_wait(snd_hctl_t *hctl, int timeout)
struct pollfd *pfd;
unsigned short *revents;
int i, npfds, pollio, err, err_poll;
npfds = snd_hctl_poll_descriptors_count(hctl);
if (npfds <= 0 || npfds >= 16) {
SNDERR("Invalid poll_fds %d", npfds);
snd_error(CONTROL, "Invalid poll_fds %d", npfds);
return -EIO;
}
pfd = alloca(sizeof(*pfd) * npfds);
@ -689,7 +689,7 @@ int snd_hctl_wait(snd_hctl_t *hctl, int timeout)
if (err < 0)
return err;
if (err != npfds) {
SNDMSG("invalid poll descriptors %d", err);
snd_check(CONTROL, "invalid poll descriptors %d", err);
return -EIO;
}
do {
@ -781,7 +781,7 @@ int snd_hctl_handle_events(snd_hctl_t *hctl)
snd_ctl_event_t event;
int res;
unsigned int count = 0;
assert(hctl);
assert(hctl->ctl);
while ((res = snd_ctl_read(hctl->ctl, &event)) != 0 &&

View file

@ -37,7 +37,7 @@ struct hint_list {
const char *siface;
snd_ctl_elem_iface_t iface;
snd_ctl_t *ctl;
snd_ctl_card_info_t *info;
snd_ctl_card_info_t *info;
int card;
int device;
long device_input;
@ -104,7 +104,9 @@ static int hint_list_add_custom(struct hint_list *list,
return err;
}
static void zero_handler(const char *file ATTRIBUTE_UNUSED,
static void zero_handler(int prio ATTRIBUTE_UNUSED,
int interface ATTRIBUTE_UNUSED,
const char *file ATTRIBUTE_UNUSED,
int line ATTRIBUTE_UNUSED,
const char *function ATTRIBUTE_UNUSED,
int err ATTRIBUTE_UNUSED,
@ -171,7 +173,7 @@ static char *get_dev_name(struct hint_list *list)
{
char *str1, *str2, *res;
int device;
device = list->device_input >= 0 ? list->device_input : list->device;
if (get_dev_name1(list, &str1, device, 1) < 0)
return NULL;
@ -239,7 +241,7 @@ static int try_config(snd_config_t *config,
const char *base,
const char *name)
{
snd_local_error_handler_t eh;
snd_lib_log_handler_t eh;
snd_config_t *res = NULL, *cfg, *cfg1, *n;
snd_config_iterator_t i, next;
char *buf, *buf1 = NULL, *buf2;
@ -259,16 +261,16 @@ static int try_config(snd_config_t *config,
snd_config_get_string(cfg, &str) >= 0 &&
((strncmp(base, str, strlen(base)) == 0 &&
str[strlen(base)] == '.') || strchr(str, '.') == NULL))
goto __skip_add;
goto __skip_add;
if (list->card >= 0 && list->device >= 0)
sprintf(buf, "%s:CARD=%s,DEV=%i", name, snd_ctl_card_info_get_id(list->info), list->device);
else if (list->card >= 0)
sprintf(buf, "%s:CARD=%s", name, snd_ctl_card_info_get_id(list->info));
else
strcpy(buf, name);
eh = snd_lib_error_set_local(&zero_handler);
eh = snd_lib_log_set_local(&zero_handler);
err = snd_config_search_definition(config, base, buf, &res);
snd_lib_error_set_local(eh);
snd_lib_log_set_local(eh);
if (err < 0)
goto __skip_add;
cleanup_res = 1;
@ -292,22 +294,22 @@ static int try_config(snd_config_t *config,
cfg1 = res;
level = 0;
__hint:
level++;
level++;
if (snd_config_search(cfg1, "type", &cfg) >= 0 &&
snd_config_get_string(cfg, &str) >= 0 &&
strcmp(str, "hw") == 0) {
if (snd_config_search(cfg1, "device", &cfg) >= 0) {
if (snd_config_get_integer(cfg, &dev) < 0) {
SNDERR("(%s) device must be an integer", buf);
snd_error(CONTROL, "(%s) device must be an integer", buf);
err = -EINVAL;
goto __cleanup;
}
}
}
if (snd_config_search(cfg1, "hint", &cfg) >= 0) {
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("hint (%s) must be a compound", buf);
snd_error(CONTROL, "hint (%s) must be a compound", buf);
err = -EINVAL;
goto __cleanup;
}
@ -330,7 +332,7 @@ static int try_config(snd_config_t *config,
}
if (snd_config_search(cfg, "device", &n) >= 0) {
if (snd_config_get_integer(n, &dev) < 0) {
SNDERR("(%s) device must be an integer", buf);
snd_error(CONTROL, "(%s) device must be an integer", buf);
err = -EINVAL;
goto __cleanup;
}
@ -339,7 +341,7 @@ static int try_config(snd_config_t *config,
}
if (snd_config_search(cfg, "device_input", &n) >= 0) {
if (snd_config_get_integer(n, &list->device_input) < 0) {
SNDERR("(%s) device_input must be an integer", buf);
snd_error(CONTROL, "(%s) device_input must be an integer", buf);
err = -EINVAL;
goto __cleanup;
}
@ -349,7 +351,7 @@ static int try_config(snd_config_t *config,
}
if (snd_config_search(cfg, "device_output", &n) >= 0) {
if (snd_config_get_integer(n, &list->device_output) < 0) {
SNDERR("(%s) device_output must be an integer", buf);
snd_error(CONTROL, "(%s) device_output must be an integer", buf);
err = -EINVAL;
goto __cleanup;
}
@ -361,7 +363,7 @@ static int try_config(snd_config_t *config,
goto __skip_add;
if (snd_config_search(cfg1, "slave", &cfg) >= 0 &&
snd_config_search(cfg, base, &cfg1) >= 0)
goto __hint;
goto __hint;
snd_config_delete(res);
res = NULL;
cleanup_res = 0;
@ -369,9 +371,9 @@ static int try_config(snd_config_t *config,
goto __ok;
/* find, if all parameters have a default, */
/* otherwise filter this definition */
eh = snd_lib_error_set_local(&zero_handler);
eh = snd_lib_log_set_local(&zero_handler);
err = snd_config_search_alias_hooks(config, base, buf, &res);
snd_lib_error_set_local(eh);
snd_lib_log_set_local(eh);
if (err < 0)
goto __cleanup;
if (snd_config_search(res, "@args", &cfg) >= 0) {
@ -393,38 +395,38 @@ static int try_config(snd_config_t *config,
__ok:
err = 0;
__cleanup:
if (err >= 0) {
list->device = dev;
str = list->card >= 0 ? get_dev_name(list) : NULL;
if (str != NULL) {
level = (buf1 == NULL ? 0 : strlen(buf1)) + 1 + strlen(str);
buf2 = realloc((char *)str, level + 1);
if (buf2 != NULL) {
if (buf1 != NULL) {
str = strchr(buf2, '|');
if (str != NULL)
if (err >= 0) {
list->device = dev;
str = list->card >= 0 ? get_dev_name(list) : NULL;
if (str != NULL) {
level = (buf1 == NULL ? 0 : strlen(buf1)) + 1 + strlen(str);
buf2 = realloc((char *)str, level + 1);
if (buf2 != NULL) {
if (buf1 != NULL) {
str = strchr(buf2, '|');
if (str != NULL)
memmove(buf2 + (level - strlen(str)), str, strlen(str));
else
str = buf2 + strlen(buf2);
*(char *)str++ = '\n';
memcpy((char *)str, buf1, strlen(buf1));
buf2[level] = '\0';
*(char *)str++ = '\n';
memcpy((char *)str, buf1, strlen(buf1));
buf2[level] = '\0';
free(buf1);
}
buf1 = buf2;
} else {
free((char *)str);
}
} else if (list->device >= 0)
goto __skip_add;
err = hint_list_add(list, buf, buf1);
} else if (list->device >= 0)
goto __skip_add;
err = hint_list_add(list, buf, buf1);
}
__skip_add:
if (res && cleanup_res)
snd_config_delete(res);
snd_config_delete(res);
if (buf1)
free(buf1);
free(buf);
free(buf);
return err;
}
@ -453,7 +455,7 @@ static int add_card(snd_config_t *config, snd_config_t *rw_config, struct hint_l
char ctl_name[16];
snd_ctl_card_info_t info = {0};
int device, max_device = 0;
list->info = &info;
err = snd_config_search(config, list->siface, &conf);
if (err < 0)
@ -469,7 +471,7 @@ static int add_card(snd_config_t *config, snd_config_t *rw_config, struct hint_l
n = snd_config_iterator_entry(i);
if (snd_config_get_id(n, &str) < 0)
continue;
if (next_devices[list->iface] != NULL) {
list->card = card;
device = max_device = -1;
@ -508,7 +510,7 @@ static int add_card(snd_config_t *config, snd_config_t *rw_config, struct hint_l
}
err = 0;
__error:
snd_ctl_close(list->ctl);
snd_ctl_close(list->ctl);
return err;
}
@ -663,9 +665,9 @@ int snd_device_name_hint(int card, const char *iface, void ***hints)
if (!err && !list.list)
err = hint_list_add(&list, NULL, NULL);
if (err < 0)
snd_device_name_free_hint((void **)list.list);
snd_device_name_free_hint((void **)list.list);
else
*hints = (void **)list.list;
*hints = (void **)list.list;
free(list.cardname);
if (local_config_rw)
snd_config_delete(local_config_rw);
@ -724,7 +726,7 @@ char *snd_device_name_get_hint(const void *hint, const char *id)
return NULL;
hint1 = delim + 1;
continue;
}
}
if (delim == NULL)
return strdup(hint1 + 4);
size = delim - hint1 - 4;

View file

@ -93,13 +93,13 @@ int snd_sctl_install(snd_sctl_t *h)
if (elem->lock) {
err = snd_ctl_elem_lock(h->ctl, elem->id);
if (err < 0) {
SNDERR("Cannot lock ctl elem");
snd_error(CONTROL, "Cannot lock ctl elem");
return err;
}
}
err = snd_ctl_elem_read(h->ctl, elem->old);
if (err < 0) {
SNDERR("Cannot read ctl elem");
snd_error(CONTROL, "Cannot read ctl elem");
return err;
}
count = snd_ctl_elem_info_get_count(elem->info);
@ -166,7 +166,7 @@ int snd_sctl_install(snd_sctl_t *h)
}
err = snd_ctl_elem_write(h->ctl, elem->val);
if (err < 0) {
SNDERR("Cannot write ctl elem");
snd_error(CONTROL, "Cannot write ctl elem");
return err;
}
}
@ -188,7 +188,7 @@ int snd_sctl_remove(snd_sctl_t *h)
if (elem->lock) {
err = snd_ctl_elem_unlock(h->ctl, elem->id);
if (err < 0) {
SNDERR("Cannot unlock ctl elem");
snd_error(CONTROL, "Cannot unlock ctl elem");
return err;
}
}
@ -205,7 +205,7 @@ int snd_sctl_remove(snd_sctl_t *h)
if (elem->preserve && snd_ctl_elem_value_compare(elem->val, elem->old)) {
err = snd_ctl_elem_write(h->ctl, elem->old);
if (err < 0) {
SNDERR("Cannot restore ctl elem");
snd_error(CONTROL, "Cannot restore ctl elem");
return err;
}
}
@ -235,7 +235,7 @@ static int snd_config_get_ctl_elem_enumerated(snd_config_t *n, snd_ctl_t *ctl,
snd_ctl_elem_info_set_item(info, idx);
err = snd_ctl_elem_info(ctl, info);
if (err < 0) {
SNDERR("Cannot obtain info for CTL elem");
snd_error(CONTROL, "Cannot obtain info for CTL elem");
return err;
}
if (strcmp(str, snd_ctl_elem_info_get_item_name(info)) == 0)
@ -293,7 +293,7 @@ static int snd_config_get_ctl_elem_value(snd_config_t *conf,
case SND_CTL_ELEM_TYPE_IEC958:
break;
default:
SNDERR("Unknown control type: %d", type);
snd_error(CONTROL, "Unknown control type: %d", type);
return -EINVAL;
}
}
@ -311,7 +311,7 @@ static int snd_config_get_ctl_elem_value(snd_config_t *conf,
unsigned int idx = 0;
if (len % 2 != 0 || len > count * 2) {
_bad_content:
SNDERR("bad value content");
snd_error(CONTROL, "bad value content");
return -EINVAL;
}
while (*buf) {
@ -340,7 +340,7 @@ static int snd_config_get_ctl_elem_value(snd_config_t *conf,
break;
}
if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("bad value type");
snd_error(CONTROL, "bad value type");
return -EINVAL;
}
@ -351,7 +351,7 @@ static int snd_config_get_ctl_elem_value(snd_config_t *conf,
continue;
err = safe_strtol(id, &idx);
if (err < 0 || idx < 0 || (unsigned int) idx >= count) {
SNDERR("bad value index");
snd_error(CONTROL, "bad value index");
return -EINVAL;
}
switch (type) {
@ -424,11 +424,11 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
if (strcmp(id, "iface") == 0 || strcmp(id, "interface") == 0) {
const char *ptr;
if ((err = snd_config_get_string(n, &ptr)) < 0) {
SNDERR("field %s is not a string", id);
snd_error(CONTROL, "field %s is not a string", id);
goto _err;
}
if ((err = snd_config_get_ctl_iface_ascii(ptr)) < 0) {
SNDERR("Invalid value for '%s'", id);
snd_error(CONTROL, "Invalid value for '%s'", id);
goto _err;
}
iface = err;
@ -436,28 +436,28 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
}
if (strcmp(id, "name") == 0) {
if ((err = snd_config_get_string(n, &name)) < 0) {
SNDERR("field %s is not a string", id);
snd_error(CONTROL, "field %s is not a string", id);
goto _err;
}
continue;
}
if (strcmp(id, "index") == 0) {
if ((err = snd_config_get_integer(n, &index)) < 0) {
SNDERR("field %s is not an integer", id);
snd_error(CONTROL, "field %s is not an integer", id);
goto _err;
}
continue;
}
if (strcmp(id, "device") == 0) {
if ((err = snd_config_get_integer(n, &device)) < 0) {
SNDERR("field %s is not an integer", id);
snd_error(CONTROL, "field %s is not an integer", id);
goto _err;
}
continue;
}
if (strcmp(id, "subdevice") == 0) {
if ((err = snd_config_get_integer(n, &subdevice)) < 0) {
SNDERR("field %s is not an integer", id);
snd_error(CONTROL, "field %s is not an integer", id);
goto _err;
}
continue;
@ -498,16 +498,16 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
skip_rest = err;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(CONTROL, "Unknown field %s", id);
return -EINVAL;
}
if (name == NULL) {
SNDERR("Missing control name");
snd_error(CONTROL, "Missing control name");
err = -EINVAL;
goto _err;
}
if (value == NULL) {
SNDERR("Missing control value");
snd_error(CONTROL, "Missing control value");
err = -EINVAL;
goto _err;
}
@ -544,7 +544,7 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
err = snd_ctl_elem_info(h->ctl, elem->info);
if (err < 0) {
if (! optional)
SNDERR("Cannot obtain info for CTL elem (%s,'%s',%li,%li,%li): %s", snd_ctl_elem_iface_name(iface), name, index, device, subdevice, snd_strerror(err));
snd_error(CONTROL, "Cannot obtain info for CTL elem (%s,'%s',%li,%li,%li): %s", snd_ctl_elem_iface_name(iface), name, index, device, subdevice, snd_strerror(err));
goto _err;
} else {
if (skip_rest)
@ -564,14 +564,14 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
if (err < 0)
goto _err;
}
err = snd_config_get_ctl_elem_value(value, h->ctl, elem->val, elem->mask, elem->info);
if (err < 0)
goto _err;
list_add_tail(&elem->list, &h->elems);
_err:
if (err < 0 && elem) {
if (err < 0 && elem) {
if (elem->id)
snd_ctl_elem_id_free(elem->id);
if (elem->info)

View file

@ -69,7 +69,7 @@ int snd_tlv_parse_dB_info(unsigned int *tlv,
/* Validate that it is possible to read the type and size
* without reading past the end of the buffer. */
if (tlv_size < MIN_TLV_STREAM_LEN) {
SNDERR("TLV stream too short");
snd_error(CONTROL, "TLV stream too short");
return -EINVAL;
}
@ -78,7 +78,7 @@ int snd_tlv_parse_dB_info(unsigned int *tlv,
size = tlv[SNDRV_CTL_TLVO_LEN];
tlv_size -= 2 * sizeof(int);
if (size > tlv_size) {
SNDERR("TLV size error");
snd_error(CONTROL, "TLV size error");
return -EINVAL;
}
switch (type) {
@ -110,11 +110,11 @@ int snd_tlv_parse_dB_info(unsigned int *tlv,
else
minsize = 2 * sizeof(int);
if (size < minsize) {
SNDERR("Invalid dB_scale TLV size");
snd_error(CONTROL, "Invalid dB_scale TLV size");
return -EINVAL;
}
if (size > MAX_TLV_RANGE_SIZE) {
SNDERR("Too big dB_scale TLV size: %d", size);
snd_error(CONTROL, "Too big dB_scale TLV size: %d", size);
return -EINVAL;
}
*db_tlvp = tlv;
@ -246,16 +246,17 @@ int snd_tlv_convert_to_dB(unsigned int *tlv, long rangemin, long rangemax,
int mindb, maxdb;
mindb = tlv[SNDRV_CTL_TLVO_DB_MINMAX_MIN];
maxdb = tlv[SNDRV_CTL_TLVO_DB_MINMAX_MAX];
if (volume <= rangemin || rangemax <= rangemin) {
if (type == SND_CTL_TLVT_DB_MINMAX_MUTE)
*db_gain = SND_CTL_TLV_DB_GAIN_MUTE;
else
*db_gain = mindb;
} else if (volume >= rangemax)
*db_gain = maxdb;
if (rangemax <= rangemin)
*db_gain = mindb;
else
*db_gain = (maxdb - mindb) * (volume - rangemin) /
(rangemax - rangemin) + mindb;
if (*db_gain < mindb)
*db_gain = mindb;
if (*db_gain > maxdb)
*db_gain = maxdb;
if (type == SND_CTL_TLVT_DB_MINMAX_MUTE && *db_gain == mindb)
*db_gain = SND_CTL_TLV_DB_GAIN_MUTE;
return 0;
}
#ifndef HAVE_SOFT_FLOAT

View file

@ -211,7 +211,7 @@ static int snd_dlsym_verify(void *handle, const char *name, const char *version)
#ifdef HAVE_LIBDL
int res;
char *vname;
if (handle == NULL)
return -EINVAL;
vname = alloca(1 + strlen(name) + strlen(version) + 1);
@ -223,7 +223,7 @@ static int snd_dlsym_verify(void *handle, const char *name, const char *version)
res = dlsym(handle, vname) == NULL ? -ENOENT : 0;
// printf("dlsym verify: %i, vname = '%s'\n", res, vname);
if (res < 0)
SNDERR("unable to verify version for symbol %s", name);
snd_error(CORE, "unable to verify version for symbol %s", name);
return res;
#else
return 0;
@ -332,21 +332,24 @@ snd_dlobj_cache_get0(const char *lib, const char *name,
errbuf[0] = '\0';
dlobj = INTERNAL(snd_dlopen)(lib, RTLD_NOW,
verbose ? errbuf : 0,
verbose ? sizeof(errbuf) : 0);
verbose ? errbuf : 0,
verbose ? sizeof(errbuf) : 0);
if (dlobj == NULL) {
if (verbose)
SNDERR("Cannot open shared library %s (%s)",
lib ? lib : "[builtin]",
errbuf);
snd_error(CORE, "Cannot open shared library %s (%s)",
lib ? lib : "[builtin]",
errbuf);
return NULL;
}
func = snd_dlsym(dlobj, name, version);
if (func == NULL) {
if (verbose)
SNDERR("symbol %s is not defined inside %s",
name, lib ? lib : "[builtin]");
snd_error(CORE, "symbol %s is not defined inside %s",
name, lib ? lib : "[builtin]");
goto __err;
}
c = malloc(sizeof(*c));

View file

@ -68,47 +68,319 @@ const char *snd_strerror(int errnum)
#endif
#endif
static TLS_PFX snd_lib_log_handler_t local_log = NULL;
static TLS_PFX snd_local_error_handler_t local_error = NULL;
/**
* \brief Install local error handler
* \param func The local error handler function
* \retval Previous local error handler function
* \brief Install local log handler
* \param func The local log handler function
* \retval Previous local log handler function
*/
snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func)
snd_lib_log_handler_t snd_lib_log_set_local(snd_lib_log_handler_t func)
{
snd_local_error_handler_t old = local_error;
local_error = func;
snd_lib_log_handler_t old = local_log;
local_log = func;
return old;
}
/**
* \brief The default error handler function.
* Array of log priority level names.
*/
static const char *snd_log_prio_names[SND_LOG_LAST + 1] = {
[0] = NULL,
[SND_LOG_ERROR] = "error",
[SND_LOG_WARN] = "warning",
[SND_LOG_INFO] = "info",
[SND_LOG_DEBUG] = "debug",
[SND_LOG_TRACE] = "trace",
};
/**
* Array of interface names.
*/
static const char *snd_ilog_interface_names[SND_ILOG_LAST + 1] = {
[0] = NULL,
[SND_ILOG_CORE] = "core",
[SND_ILOG_CONFIG] = "config",
[SND_ILOG_CONTROL] = "control",
[SND_ILOG_HWDEP] = "hwdep",
[SND_ILOG_TIMER] = "timer",
[SND_ILOG_RAWMIDI] = "rawmidi",
[SND_ILOG_PCM] = "pcm",
[SND_ILOG_MIXER] = "mixer",
[SND_ILOG_SEQUENCER] = "sequencer",
[SND_ILOG_UCM] = "ucm",
[SND_ILOG_TOPOLOGY] = "topology",
[SND_ILOG_ASERVER] = "aserver",
};
/**
* \brief Function to convert log priority level to text.
* \param prio Priority value (SND_LOG_*).
* \return The textual representation of the priority level, or NULL if invalid.
*/
const char *snd_lib_log_priority(int prio)
{
if (prio >= 0 && prio <= SND_LOG_TRACE)
return snd_log_prio_names[prio];
return NULL;
}
/**
* \brief Function to convert interface code to text.
* \param interface Interface (SND_ILOG_*).
* \return The textual representation of the interface code, or NULL if invalid.
*/
const char *snd_lib_log_interface(int interface)
{
if (interface >= 0 && interface <= SND_ILOG_TOPOLOGY)
return snd_ilog_interface_names[interface];
return NULL;
}
/**
* \brief Structure to hold parsed debug configuration.
*/
static struct {
const char *configstr;
int global_level;
int interface_levels[SND_ILOG_LAST + 1];
int parsed;
} debug_config;
/**
* \brief Parse the LIBASOUND_DEBUG environment variable.
*
* Format: [<level>][,<interface1>:<level1>][,<interface2>:<level2>,...]
*
* Examples:
* "debug" - Set global level to debug
* "3" - Set global level to 3 (info)
* "info,pcm:debug" - Set global to info, pcm to debug
* "error,mixer:5,pcm:4" - Set global to error, mixer to 5 (trace), pcm to 4 (debug)
*/
static void parse_libasound_debug(const char *configstr)
{
const char *env;
char *str, *token, *saveptr;
int i;
if (debug_config.parsed && debug_config.configstr == configstr)
return;
debug_config.parsed = 1;
debug_config.global_level = 0;
debug_config.configstr = configstr;
for (i = 0; i <= SND_ILOG_LAST; i++)
debug_config.interface_levels[i] = 0;
if (configstr == NULL) {
env = getenv("LIBASOUND_DEBUG");
if (!env || !*env)
return;
} else {
env = configstr;
}
str = strdup(env);
if (!str)
return;
token = strtok_r(str, ",", &saveptr);
while (token) {
char *colon = strchr(token, ':');
if (colon) {
/* interface:level format */
*colon = '\0';
const char *interface_name = token;
const char *level_str = colon + 1;
int interface_num = -1;
int level = -1;
/* Try to find interface by name */
for (i = 1; i <= SND_ILOG_LAST; i++) {
if (snd_ilog_interface_names[i] &&
strcmp(snd_ilog_interface_names[i], interface_name) == 0) {
interface_num = i;
break;
}
}
/* If not found by name, try direct number */
if (interface_num < 0) {
char *endptr;
long val = strtol(interface_name, &endptr, 10);
if (*endptr == '\0' && val >= 0 && val <= SND_ILOG_LAST)
interface_num = val;
}
/* Parse level */
for (i = 1; i <= SND_LOG_LAST; i++) {
if (snd_log_prio_names[i] &&
strcmp(snd_log_prio_names[i], level_str) == 0) {
level = i;
break;
}
}
/* If not found by name, try direct number */
if (level < 0) {
char *endptr;
long val = strtol(level_str, &endptr, 10);
if (*endptr == '\0' && val >= 0 && val <= SND_LOG_LAST)
level = val;
}
/* Store the interface-specific level */
if (interface_num > 0 && level > 0)
debug_config.interface_levels[interface_num] = level;
} else {
/* Global level only */
int level = -1;
/* Try to find level by name */
for (i = 1; i <= SND_LOG_LAST; i++) {
if (snd_log_prio_names[i] &&
strcmp(snd_log_prio_names[i], token) == 0) {
level = i;
break;
}
}
/* If not found by name, try direct number */
if (level < 0) {
char *endptr;
long val = strtol(token, &endptr, 10);
if (*endptr == '\0' && val >= 0 && val <= SND_LOG_LAST)
level = val;
}
if (level > 0)
debug_config.global_level = level;
}
token = strtok_r(NULL, ",", &saveptr);
}
free(str);
}
/**
* \brief Check if a log message should be shown based on LIBASOUND_DEBUG.
* \param prio Priority value (SND_LOG_*).
* \param interface Interface (SND_ILOG_*).
* \param configstr Configuration string (usually LIBASOUND_DEBUG environment variable)
* \return 1 if the message should be shown, 0 otherwise.
*/
int snd_lib_log_filter(int prio, int interface, const char *configstr)
{
unsigned int level;
parse_libasound_debug(configstr);
if (interface > 0 && interface <= SND_ILOG_LAST && debug_config.interface_levels[interface] > 0) {
level = debug_config.interface_levels[interface];
} else {
level = debug_config.global_level; }
if (level == 0)
level = SND_LOG_ERROR;
/* Show message if its priority is less than or equal to the configured level */
return prio <= (int)level;
}
/**
* \brief The default log handler function.
* \param prio Priority value (SND_LOG_*).
* \param interface Interface (SND_ILOG_*).
* \param file The filename where the error was hit.
* \param line The line number.
* \param function The function name.
* \param err The error code.
* \param errcode The error code.
* \param fmt The message (including the format characters).
* \param ... Optional arguments.
*
* If a local error function has been installed for the current thread by
* \ref snd_lib_error_set_local, it is called. Otherwise, prints the error
* \ref snd_lib_log_set_local, it is called. Otherwise, prints the error
* message including location to \c stderr.
*/
static void snd_lib_error_default(const char *file, int line, const char *function, int err, const char *fmt, ...)
static void snd_lib_vlog_default(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg)
{
const char *text1, *text2;
if (local_log) {
local_log(prio, interface, file, line, function, errcode, fmt, arg);
return;
}
if (local_error && prio == SND_LOG_ERROR) {
local_error(file, line, function, errcode, fmt, arg);
return;
}
if (!snd_lib_log_filter(prio, interface, NULL))
return;
fprintf(stderr, "ALSA lib %s:%i:(%s) ", file, line, function);
text1 = snd_lib_log_priority(prio);
text2 = snd_lib_log_interface(interface);
if (text1 || text2)
fprintf(stderr, "[%s.%s] ", text1 ? text1 : "", text2 ? text2 : "");
vfprintf(stderr, fmt, arg);
if (errcode)
fprintf(stderr, ": %s", snd_strerror(errcode));
putc('\n', stderr);
}
/**
* \brief Root log handler function.
* \param prio Priority value (SND_LOG_*).
* \param interface Interface (SND_ILOG_*).
* \param file The filename where the error was hit.
* \param line The line number.
* \param function The function name.
* \param errcode The error code.
* \param fmt The message (including the format characters).
* \param ... Optional arguments.
*/
void snd_lib_log(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...)
{
va_list arg;
va_start(arg, fmt);
if (local_error) {
local_error(file, line, function, err, fmt, arg);
va_end(arg);
return;
}
fprintf(stderr, "ALSA lib %s:%i:(%s) ", file, line, function);
vfprintf(stderr, fmt, arg);
if (err)
fprintf(stderr, ": %s", snd_strerror(err));
putc('\n', stderr);
snd_lib_vlog(prio, interface, file, line, function, errcode, fmt, arg);
va_end(arg);
}
/**
* \brief The check point function.
* \param interface Interface (SND_ILOG_*).
* \param file The filename where the error was hit.
* \param line The line number.
* \param function The function name.
* \param errcode The error code.
* \param fmt The message (including the format characters).
* \param ... Optional arguments.
*
* The error message is passed with error priority level to snd_lib_vlog handler.
*/
void snd_lib_check(int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...)
{
const char *verbose;
va_list arg;
va_start(arg, fmt);
verbose = getenv("LIBASOUND_DEBUG");
if (! verbose || ! *verbose)
goto finish;
snd_lib_vlog(SND_LOG_ERROR, interface, file, line, function, errcode, fmt, arg);
#ifdef ALSA_DEBUG_ASSERT
verbose = getenv("LIBASOUND_DEBUG_ASSERT");
if (verbose && *verbose)
assert(0);
#endif
finish:
va_end(arg);
}
@ -117,11 +389,75 @@ static void snd_lib_error_default(const char *file, int line, const char *functi
* Pointer to the error handler function.
* For internal use only.
*/
snd_lib_log_handler_t snd_lib_vlog = snd_lib_vlog_default;
/**
* \brief Sets the log handler.
* \param handler The pointer to the new log handler function.
* \retval Previous log handler function
*
* This function sets a new log handler, or (if \c handler is \c NULL)
* the default one which prints the error messages to \c stderr.
*/
snd_lib_log_handler_t snd_lib_log_set_handler(snd_lib_log_handler_t handler)
{
snd_lib_log_handler_t old = snd_lib_vlog;
snd_lib_vlog = handler == NULL ? snd_lib_vlog_default : handler;
return old;
}
/**
* \brief Install local error handler
* \param func The local error handler function
* \retval Previous local error handler function
* \deprecated Since 1.2.15
*/
snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func)
{
snd_local_error_handler_t old = local_error;
local_error = func;
return old;
}
#ifndef DOC_HIDDEN
link_warning(snd_lib_error_set_local, "Warning: snd_lib_error_set_local is deprecated, use snd_lib_log_set_local");
#endif
/**
* \brief The default error handler function.
* \param file The filename where the error was hit.
* \param line The line number.
* \param function The function name.
* \param errcode The error code.
* \param fmt The message (including the format characters).
* \param ... Optional arguments.
* \deprecated Since 1.2.15
*
* Use snd_lib_vlog handler to print error message for anonymous interface.
*/
static void snd_lib_error_default(const char *file, int line, const char *function, int errcode, const char *fmt, ...)
{
va_list arg;
va_start(arg, fmt);
snd_lib_vlog(SND_LOG_ERROR, 0, file, line, function, errcode, fmt, arg);
va_end(arg);
}
/**
* \ingroup Error
* \deprecated Since 1.2.15
* Pointer to the error handler function.
* For internal use only.
*/
snd_lib_error_handler_t snd_lib_error = snd_lib_error_default;
#ifndef DOC_HIDDEN
link_warning(snd_lib_error, "Warning: snd_lib_error is deprecated, use snd_log interface");
#endif
/**
* \brief Sets the error handler.
* \param handler The pointer to the new error handler function.
* \deprecated Since 1.2.15
*
* This function sets a new error handler, or (if \c handler is \c NULL)
* the default one which prints the error messages to \c stderr.
@ -129,10 +465,6 @@ snd_lib_error_handler_t snd_lib_error = snd_lib_error_default;
int snd_lib_error_set_handler(snd_lib_error_handler_t handler)
{
snd_lib_error = handler == NULL ? snd_lib_error_default : handler;
#ifndef NDEBUG
if (snd_lib_error != snd_lib_error_default)
snd_err_msg = snd_lib_error;
#endif
return 0;
}
@ -145,39 +477,6 @@ const char *snd_asoundlib_version(void)
return SND_LIB_VERSION_STR;
}
#ifndef NDEBUG
/*
* internal error handling
*/
static void snd_err_msg_default(const char *file, int line, const char *function, int err, const char *fmt, ...)
{
va_list arg;
const char *verbose;
verbose = getenv("LIBASOUND_DEBUG");
if (! verbose || ! *verbose)
return;
va_start(arg, fmt);
fprintf(stderr, "ALSA lib %s:%i:(%s) ", file, line, function);
vfprintf(stderr, fmt, arg);
if (err)
fprintf(stderr, ": %s", snd_strerror(err));
putc('\n', stderr);
va_end(arg);
#ifdef ALSA_DEBUG_ASSERT
verbose = getenv("LIBASOUND_DEBUG_ASSERT");
if (verbose && *verbose)
assert(0);
#endif
}
/**
* The ALSA error message handler
*/
snd_lib_error_handler_t snd_err_msg = snd_err_msg_default;
#endif
/**
* \brief Copy a C-string into a sized buffer
* \param dst Where to copy the string to

View file

@ -54,30 +54,30 @@ static int snd_hwdep_open_conf(snd_hwdep_t **hwdep,
void *h = NULL;
if (snd_config_get_type(hwdep_conf) != SND_CONFIG_TYPE_COMPOUND) {
if (name)
SNDERR("Invalid type for HWDEP %s definition", name);
snd_error(HWDEP, "Invalid type for HWDEP %s definition", name);
else
SNDERR("Invalid type for HWDEP definition");
snd_error(HWDEP, "Invalid type for HWDEP definition");
return -EINVAL;
}
err = snd_config_search(hwdep_conf, "type", &conf);
if (err < 0) {
SNDERR("type is not defined");
snd_error(HWDEP, "type is not defined");
return err;
}
err = snd_config_get_id(conf, &id);
if (err < 0) {
SNDERR("unable to get id");
snd_error(HWDEP, "unable to get id");
return err;
}
err = snd_config_get_string(conf, &str);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(HWDEP, "Invalid type for %s", id);
return err;
}
err = snd_config_search_definition(hwdep_root, "hwdep_type", str, &type_conf);
if (err >= 0) {
if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid type for HWDEP type %s definition", str);
snd_error(HWDEP, "Invalid type for HWDEP type %s definition", str);
err = -EINVAL;
goto _err;
}
@ -91,7 +91,7 @@ static int snd_hwdep_open_conf(snd_hwdep_t **hwdep,
if (strcmp(id, "lib") == 0) {
err = snd_config_get_string(n, &lib);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(HWDEP, "Invalid type for %s", id);
goto _err;
}
continue;
@ -99,12 +99,12 @@ static int snd_hwdep_open_conf(snd_hwdep_t **hwdep,
if (strcmp(id, "open") == 0) {
err = snd_config_get_string(n, &open_name);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(HWDEP, "Invalid type for %s", id);
goto _err;
}
continue;
}
SNDERR("Unknown field %s", id);
snd_error(HWDEP, "Unknown field %s", id);
err = -EINVAL;
goto _err;
}
@ -121,10 +121,10 @@ static int snd_hwdep_open_conf(snd_hwdep_t **hwdep,
open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_HWDEP_DLSYM_VERSION));
err = 0;
if (!h) {
SNDERR("Cannot open shared library %s (%s)", lib, errbuf);
snd_error(HWDEP, "Cannot open shared library %s (%s)", lib, errbuf);
err = -ENOENT;
} else if (!open_func) {
SNDERR("symbol %s is not defined inside %s", open_name, lib);
snd_error(HWDEP, "symbol %s is not defined inside %s", open_name, lib);
snd_dlclose(h);
err = -ENXIO;
}
@ -148,7 +148,7 @@ static int snd_hwdep_open_noupdate(snd_hwdep_t **hwdep, snd_config_t *root, cons
snd_config_t *hwdep_conf;
err = snd_config_search_definition(root, "hwdep", name, &hwdep_conf);
if (err < 0) {
SNDERR("Unknown HwDep %s", name);
snd_error(HWDEP, "Unknown HwDep %s", name);
return err;
}
err = snd_hwdep_open_conf(hwdep, name, root, hwdep_conf, mode);
@ -209,7 +209,7 @@ int snd_hwdep_open_lconf(snd_hwdep_t **hwdep, const char *name,
int snd_hwdep_close(snd_hwdep_t *hwdep)
{
int err;
assert(hwdep);
assert(hwdep);
err = hwdep->ops->close(hwdep);
if (hwdep->dl_handle)
snd_dlclose(hwdep->dl_handle);
@ -296,14 +296,14 @@ int snd_hwdep_poll_descriptors(snd_hwdep_t *hwdep, struct pollfd *pfds, unsigned
*/
int snd_hwdep_poll_descriptors_revents(snd_hwdep_t *hwdep, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
{
assert(hwdep && pfds && revents);
if (nfds == 1) {
*revents = pfds->revents;
return 0;
}
return -EINVAL;
}
assert(hwdep && pfds && revents);
if (nfds == 1) {
*revents = pfds->revents;
return 0;
}
return -EINVAL;
}
/**
* \brief set nonblock mode
* \param hwdep HwDep handle

View file

@ -111,7 +111,7 @@ int snd_hwdep_hw_open(snd_hwdep_t **handle, const char *name, int card, int devi
assert(handle);
*handle = NULL;
if (card < 0 || card >= SND_MAX_CARDS)
return -EINVAL;
sprintf(filename, SNDRV_FILE_HWDEP, card, device);
@ -172,7 +172,7 @@ int _snd_hwdep_hw_open(snd_hwdep_t **hwdep, char *name,
return err;
continue;
}
SNDERR("Unexpected field %s", id);
snd_error(HWDEP, "Unexpected field %s", id);
return -EINVAL;
}
if (card < 0)

View file

@ -25,7 +25,7 @@ extern const char *_snd_module_hwdep_hw;
static const char **snd_hwdep_open_objects[] = {
&_snd_module_hwdep_hw
};
void *snd_hwdep_open_symbols(void)
{
return snd_hwdep_open_objects;

View file

@ -95,7 +95,7 @@ char *snd_input_gets(snd_input_t *input, char *str, size_t size)
{
return (input->ops->gets)(input, str, size);
}
/**
* \brief Reads a character from an input handle (like \c fgetc(3)).
* \param input The input handle.
@ -144,7 +144,7 @@ static char *snd_input_stdio_gets(snd_input_t *input, char *str, size_t size)
snd_input_stdio_t *stdio = input->private_data;
return fgets(str, (int) size, stdio->fp);
}
static int snd_input_stdio_getc(snd_input_t *input)
{
snd_input_stdio_t *stdio = input->private_data;
@ -197,7 +197,7 @@ int snd_input_stdio_attach(snd_input_t **inputp, FILE *fp, int _close)
*inputp = input;
return 0;
}
/**
* \brief Creates a new input object reading from a file.
* \param inputp The functions puts the pointer to the new input object
@ -262,7 +262,7 @@ static char *snd_input_buffer_gets(snd_input_t *input, char *str, size_t size)
*str = '\0';
return str;
}
static int snd_input_buffer_getc(snd_input_t *input)
{
snd_input_buffer_t *buffer = input->private_data;
@ -334,4 +334,4 @@ int snd_input_buffer_open(snd_input_t **inputp, const char *buf, ssize_t size)
*inputp = input;
return 0;
}

View file

@ -752,7 +752,7 @@ int snd_mixer_poll_descriptors_revents(snd_mixer_t *mixer, struct pollfd *pfds,
{
unsigned int idx;
unsigned short res;
assert(mixer && pfds && revents);
assert(mixer && pfds && revents);
if (nfds == 0)
return -EINVAL;
res = 0;
@ -781,7 +781,7 @@ int snd_mixer_wait(snd_mixer_t *mixer, int timeout)
pfds = alloca(count * sizeof(*pfds));
if (!pfds)
return -ENOMEM;
err = snd_mixer_poll_descriptors(mixer, pfds,
err = snd_mixer_poll_descriptors(mixer, pfds,
(unsigned int) count);
assert(err == count);
}

View file

@ -46,7 +46,7 @@ struct _snd_mixer_class {
struct list_head list;
snd_mixer_t *mixer;
snd_mixer_event_t event;
void *private_data;
void *private_data;
void (*private_free)(snd_mixer_class_t *class);
snd_mixer_compare_t compare;
};

View file

@ -122,7 +122,7 @@ int snd_mixer_selem_compare(const snd_mixer_elem_t *c1, const snd_mixer_elem_t *
return s1->id->index - s2->id->index;
}
#endif
/**
* \brief Find a mixer simple element
* \param mixer Mixer handle
@ -304,7 +304,7 @@ int snd_mixer_selem_get_playback_dB_range(snd_mixer_elem_t *elem,
* \param min minimum volume value
* \param max maximum volume value
*/
int snd_mixer_selem_set_playback_volume_range(snd_mixer_elem_t *elem,
int snd_mixer_selem_set_playback_volume_range(snd_mixer_elem_t *elem,
long min, long max)
{
CHECK_BASIC(elem);
@ -610,7 +610,7 @@ int snd_mixer_selem_get_capture_dB_range(snd_mixer_elem_t *elem,
* \param min minimum volume value
* \param max maximum volume value
*/
int snd_mixer_selem_set_capture_volume_range(snd_mixer_elem_t *elem,
int snd_mixer_selem_set_capture_volume_range(snd_mixer_elem_t *elem,
long min, long max)
{
CHECK_BASIC(elem);

View file

@ -82,20 +82,20 @@ static int try_open(snd_mixer_class_t *class, const char *lib)
strcat(xlib, lib);
h = INTERNAL(snd_dlopen)(xlib, RTLD_NOW, errbuf, sizeof(errbuf));
if (h == NULL) {
SNDERR("Unable to open library '%s' (%s)", xlib, errbuf);
snd_error(MIXER, "Unable to open library '%s' (%s)", xlib, errbuf);
free(xlib);
return -ENXIO;
}
priv->dlhandle = h;
event_func = snd_dlsym(h, "alsa_mixer_simple_event", NULL);
if (event_func == NULL) {
SNDERR("Symbol 'alsa_mixer_simple_event' was not found in '%s'", xlib);
snd_error(MIXER, "Symbol 'alsa_mixer_simple_event' was not found in '%s'", xlib);
err = -ENXIO;
}
if (err == 0) {
init_func = snd_dlsym(h, "alsa_mixer_simple_init", NULL);
if (init_func == NULL) {
SNDERR("Symbol 'alsa_mixer_simple_init' was not found in '%s'", xlib);
snd_error(MIXER, "Symbol 'alsa_mixer_simple_init' was not found in '%s'", xlib);
err = -ENXIO;
}
}
@ -129,20 +129,20 @@ static int try_open_full(snd_mixer_class_t *class, snd_mixer_t *mixer,
/* note python modules requires RTLD_GLOBAL */
h = INTERNAL(snd_dlopen)(xlib, RTLD_NOW|RTLD_GLOBAL, errbuf, sizeof(errbuf));
if (h == NULL) {
SNDERR("Unable to open library '%s'", xlib);
snd_error(MIXER, "Unable to open library '%s'", xlib);
free(xlib);
return -ENXIO;
}
priv->dlhandle = h;
event_func = snd_dlsym(h, "alsa_mixer_simple_event", NULL);
if (event_func == NULL) {
SNDERR("Symbol 'alsa_mixer_simple_event' was not found in '%s'", xlib);
snd_error(MIXER, "Symbol 'alsa_mixer_simple_event' was not found in '%s'", xlib);
err = -ENXIO;
}
if (err == 0) {
init_func = snd_dlsym(h, "alsa_mixer_simple_finit", NULL);
if (init_func == NULL) {
SNDERR("Symbol 'alsa_mixer_simple_finit' was not found in '%s'", xlib);
snd_error(MIXER, "Symbol 'alsa_mixer_simple_finit' was not found in '%s'", xlib);
err = -ENXIO;
}
}
@ -243,7 +243,7 @@ static int find_module(snd_mixer_class_t *class, snd_config_t *top)
static void private_free(snd_mixer_class_t *class)
{
class_priv_t *priv = snd_mixer_class_get_private(class);
if (priv->private_free)
priv->private_free(class);
if (priv->dlhandle)
@ -308,13 +308,13 @@ int snd_mixer_simple_basic_register(snd_mixer_t *mixer,
if (err >= 0) {
err = snd_input_stdio_open(&input, file, "r");
if (err < 0) {
SNDERR("unable to open simple mixer configuration file '%s'", file);
snd_error(MIXER, "unable to open simple mixer configuration file '%s'", file);
goto __error;
}
err = snd_config_load(top, input);
snd_input_close(input);
if (err < 0) {
SNDERR("%s may be old or corrupted: consider to remove or fix it", file);
snd_error(MIXER, "%s may be old or corrupted: consider to remove or fix it", file);
goto __error;
}
err = find_full(class, mixer, top, priv->device);
@ -324,7 +324,7 @@ int snd_mixer_simple_basic_register(snd_mixer_t *mixer,
if (err >= 0) {
err = snd_ctl_open(&priv->ctl, priv->device, 0);
if (err < 0) {
SNDERR("unable to open control device '%s': %s", priv->device, snd_strerror(err));
snd_error(MIXER, "unable to open control device '%s': %s", priv->device, snd_strerror(err));
goto __error;
}
err = snd_hctl_open_ctl(&priv->hctl, priv->ctl);
@ -350,7 +350,7 @@ int snd_mixer_simple_basic_register(snd_mixer_t *mixer,
__error:
if (top)
snd_config_delete(top);
if (class)
if (class)
snd_mixer_class_free(class);
return err;
}

View file

@ -649,7 +649,7 @@ static int selem_write_main(snd_mixer_elem_t *elem)
static int selem_write(snd_mixer_elem_t *elem)
{
int err;
err = selem_write_main(elem);
if (err < 0)
selem_read(elem);
@ -883,7 +883,7 @@ static int simple_update(snd_mixer_elem_t *melem)
simple->str[SM_CAPT].max = cmax != LONG_MIN ? cmax : 0;
}
return 0;
}
}
#ifndef DOC_HIDDEN
static const struct suf {
@ -961,7 +961,7 @@ static int base_len(const char *name, selem_ctl_type_t *type)
/*
* Simple Mixer Operations
*/
static int _snd_mixer_selem_set_volume(snd_mixer_elem_t *elem, int dir, snd_mixer_selem_channel_id_t channel, long value)
{
selem_none_t *s = snd_mixer_elem_get_private(elem);
@ -971,7 +971,7 @@ static int _snd_mixer_selem_set_volume(snd_mixer_elem_t *elem, int dir, snd_mixe
return 0;
if (value < s->str[dir].min || value > s->str[dir].max)
return 0;
if (s->selem.caps &
if (s->selem.caps &
(dir == SM_PLAY ? SM_CAP_PVOLUME_JOIN : SM_CAP_CVOLUME_JOIN))
channel = 0;
if (value != s->str[dir].vol[channel]) {
@ -986,7 +986,7 @@ static int _snd_mixer_selem_set_switch(snd_mixer_elem_t *elem, int dir, snd_mixe
selem_none_t *s = snd_mixer_elem_get_private(elem);
if ((unsigned int) channel >= s->str[dir].channels)
return 0;
if (s->selem.caps &
if (s->selem.caps &
(dir == SM_PLAY ? SM_CAP_PSWITCH_JOIN : SM_CAP_CSWITCH_JOIN))
channel = 0;
if (value) {
@ -1006,7 +1006,7 @@ static int _snd_mixer_selem_set_switch(snd_mixer_elem_t *elem, int dir, snd_mixe
static int is_ops(snd_mixer_elem_t *elem, int dir, int cmd, int val)
{
selem_none_t *s = snd_mixer_elem_get_private(elem);
switch (cmd) {
case SM_OPS_IS_ACTIVE: {
@ -1034,7 +1034,7 @@ static int is_ops(snd_mixer_elem_t *elem, int dir, int cmd, int val)
if (s->selem.caps & (SM_CAP_CENUM | SM_CAP_PENUM) )
return 1;
return 0;
case SM_OPS_IS_ENUMCNT:
/* Both */
if ( (s->selem.caps & (SM_CAP_CENUM | SM_CAP_PENUM)) == (SM_CAP_CENUM | SM_CAP_PENUM) ) {
@ -1054,7 +1054,7 @@ static int is_ops(snd_mixer_elem_t *elem, int dir, int cmd, int val)
}
}
return 1;
}
@ -1174,7 +1174,7 @@ static int get_dB_range(snd_hctl_elem_t *ctl, struct selem_str *rec,
return snd_tlv_get_dB_range(rec->db_info, rec->min, rec->max, min, max);
}
static int get_dB_range_ops(snd_mixer_elem_t *elem, int dir,
long *min, long *max)
{
@ -1215,9 +1215,9 @@ static int ask_vol_dB_ops(snd_mixer_elem_t *elem,
}
static int get_dB_ops(snd_mixer_elem_t *elem,
int dir,
snd_mixer_selem_channel_id_t channel,
long *value)
int dir,
snd_mixer_selem_channel_id_t channel,
long *value)
{
selem_none_t *s = snd_mixer_elem_get_private(elem);
selem_ctl_t *c;
@ -1264,7 +1264,7 @@ static int set_volume_ops(snd_mixer_elem_t *elem, int dir,
}
static int ask_dB_vol_ops(snd_mixer_elem_t *elem, int dir,
long dbValue, long *value, int xdir)
long dbValue, long *value, int xdir)
{
selem_none_t *s = snd_mixer_elem_get_private(elem);
selem_ctl_t *c;
@ -1446,7 +1446,7 @@ static int simple_add1(snd_mixer_class_t *class, const char *name,
if (ctype == SND_CTL_ELEM_TYPE_ENUMERATED)
type = CTL_GLOBAL_ENUM;
else if (ctype != SND_CTL_ELEM_TYPE_BOOLEAN &&
ctype != SND_CTL_ELEM_TYPE_INTEGER)
ctype != SND_CTL_ELEM_TYPE_INTEGER)
return 0;
break;
case CTL_GLOBAL_ROUTE:
@ -1552,9 +1552,11 @@ static int simple_add1(snd_mixer_class_t *class, const char *name,
snd_mixer_selem_id_free(id);
}
if (simple->ctls[type].elem) {
SNDERR("helem (%s,'%s',%u,%u,%u) appears twice or more",
snd_ctl_elem_iface_name(
snd_hctl_elem_get_interface(helem)),
snd_error(MIXER, "helem (%s,'%s',%u,%u,%u) appears twice or more",
snd_ctl_elem_iface_name(
snd_hctl_elem_get_interface(helem)),
snd_hctl_elem_get_name(helem),
snd_hctl_elem_get_index(helem),
snd_hctl_elem_get_device(helem),

View file

@ -35,7 +35,7 @@
#include <limits.h>
#include <sys/stat.h>
/**
/**
* \brief This function is unimplemented.
* \deprecated Since 1.0.14
*/

View file

@ -100,7 +100,7 @@ int snd_output_puts(snd_output_t *output, const char *str)
{
return output->ops->puts(output, str);
}
/**
* \brief Writes a character to an output handle (like \c putc(3)).
* \param output The output handle.
@ -152,7 +152,7 @@ static int snd_output_stdio_puts(snd_output_t *output, const char *str)
snd_output_stdio_t *stdio = output->private_data;
return fputs(str, stdio->fp);
}
static int snd_output_stdio_putc(snd_output_t *output, int c)
{
snd_output_stdio_t *stdio = output->private_data;
@ -206,7 +206,7 @@ int snd_output_stdio_attach(snd_output_t **outputp, FILE *fp, int _close)
*outputp = output;
return 0;
}
/**
* \brief Creates a new output object writing to a file.
* \param outputp The function puts the pointer to the new output object
@ -307,7 +307,7 @@ static int snd_output_buffer_puts(snd_output_t *output, const char *str)
buffer->size += size;
return size;
}
static int snd_output_buffer_putc(snd_output_t *output, int c)
{
snd_output_buffer_t *buffer = output->private_data;

View file

@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#define SND_INTERVAL_C
#define SND_INTERVAL_INLINE
@ -32,7 +32,7 @@ static inline void div64_32(uint64_t *n, uint32_t d, uint32_t *rem)
*n /= d;
}
static inline unsigned int div32(unsigned int a, unsigned int b,
static inline unsigned int div32(unsigned int a, unsigned int b,
unsigned int *r)
{
if (b == 0) {
@ -378,7 +378,7 @@ void snd_interval_print(const snd_interval_t *i, snd_output_t *out)
{
if (snd_interval_empty(i))
snd_output_printf(out, "NONE");
else if (i->min == 0 && i->openmin == 0 &&
else if (i->min == 0 && i->openmin == 0 &&
i->max == UINT_MAX && i->openmax == 0)
snd_output_printf(out, "ALL");
else if (snd_interval_single(i) && i->integer)

View file

@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
typedef struct _snd_interval snd_interval_t;
#ifdef SND_INTERVAL_INLINE
@ -62,9 +62,9 @@ void snd_interval_add(const snd_interval_t *a, const snd_interval_t *b, snd_inte
void snd_interval_sub(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c);
void snd_interval_mul(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c);
void snd_interval_div(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c);
void snd_interval_muldiv(const snd_interval_t *a, const snd_interval_t *b,
void snd_interval_muldiv(const snd_interval_t *a, const snd_interval_t *b,
const snd_interval_t *c, snd_interval_t *d);
void snd_interval_muldivk(const snd_interval_t *a, const snd_interval_t *b,
void snd_interval_muldivk(const snd_interval_t *a, const snd_interval_t *b,
unsigned int k, snd_interval_t *c);
void snd_interval_mulkdiv(const snd_interval_t *a, unsigned int k,
const snd_interval_t *b, snd_interval_t *c);

View file

@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#define INTERVAL_INLINE static inline
INTERVAL_INLINE void snd_interval_any(snd_interval_t *i)
@ -50,7 +50,7 @@ INTERVAL_INLINE int snd_interval_empty(const snd_interval_t *i)
INTERVAL_INLINE int snd_interval_single(const snd_interval_t *i)
{
assert(!snd_interval_empty(i));
return (i->min == i->max ||
return (i->min == i->max ||
(i->min + 1 == i->max && (i->openmin || i->openmax)));
}
@ -146,8 +146,8 @@ INTERVAL_INLINE int snd_interval_always_eq(const snd_interval_t *i1, const snd_i
INTERVAL_INLINE int snd_interval_never_eq(const snd_interval_t *i1, const snd_interval_t *i2)
{
return (i1->max < i2->min ||
return (i1->max < i2->min ||
(i1->max == i2->min &&
(i1->openmax || i1->openmin)) ||
i1->min > i2->max ||

View file

@ -3,17 +3,17 @@
Linux Audio Developer's Simple Plugin API Version 1.1[LGPL].
Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis,
Stefan Westerfeld.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
This library 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 GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -32,7 +32,7 @@ extern "C" {
/*****************************************************************************/
/* Overview:
/* Overview:
There is a large number of synthesis packages in use or development
on the Linux platform at this time. This API (`The Linux Audio
@ -76,7 +76,7 @@ extern "C" {
/* Fundamental data type passed in and out of plugin. This data type
is used to communicate audio samples and control values. It is
assumed that the plugin will work sensibly given any numeric input
value although it may have a preferred range (see hints below).
value although it may have a preferred range (see hints below).
For audio it is generally assumed that 1.0f is the `0dB' reference
amplitude and is a `normal' signal level. */
@ -85,8 +85,8 @@ typedef float LADSPA_Data;
/*****************************************************************************/
/* Special Plugin Properties:
/* Special Plugin Properties:
Optional features of the plugin type are encapsulated in the
LADSPA_Properties type. This is assembled by ORing individual
properties together. */
@ -122,7 +122,7 @@ typedef int LADSPA_Properties;
(3) The plugin will not access files, devices, pipes, sockets, IPC
or any other mechanism that might result in process or thread
blocking.
(4) The plugin will take an amount of time to execute a run() or
run_adding() call approximately of form (A+B*SampleCount) where A
and B depend on the machine and host in use. This amount of time
@ -137,7 +137,7 @@ typedef int LADSPA_Properties;
/*****************************************************************************/
/* Plugin Ports:
/* Plugin Ports:
Plugins have `ports' that are inputs or outputs for audio or
data. Ports can communicate arrays of LADSPA_Data (for audio
@ -172,23 +172,23 @@ typedef int LADSPA_PortDescriptor;
/*****************************************************************************/
/* Plugin Port Range Hints:
/* Plugin Port Range Hints:
The host may wish to provide a representation of data entering or
leaving a plugin (e.g. to generate a GUI automatically). To make
this more meaningful, the plugin should provide `hints' to the host
describing the usual values taken by the data.
Note that these are only hints. The host may ignore them and the
plugin must not assume that data supplied to it is meaningful. If
the plugin receives invalid input data it is expected to continue
to run without failure and, where possible, produce a sensible
output (e.g. a high-pass filter given a negative cutoff frequency
might switch to an all-pass mode).
Hints are meaningful for all input and output ports but hints for
input control ports are expected to be particularly useful.
More hint information is encapsulated in the
LADSPA_PortRangeHintDescriptor type which is assembled by ORing
individual hint types together. Hints may require further
@ -316,23 +316,23 @@ typedef int LADSPA_PortRangeHintDescriptor;
#define LADSPA_IS_HINT_HAS_DEFAULT(x) ((x) & LADSPA_HINT_DEFAULT_MASK)
#define LADSPA_IS_HINT_DEFAULT_MINIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_MINIMUM)
== LADSPA_HINT_DEFAULT_MINIMUM)
#define LADSPA_IS_HINT_DEFAULT_LOW(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_LOW)
== LADSPA_HINT_DEFAULT_LOW)
#define LADSPA_IS_HINT_DEFAULT_MIDDLE(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_MIDDLE)
== LADSPA_HINT_DEFAULT_MIDDLE)
#define LADSPA_IS_HINT_DEFAULT_HIGH(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_HIGH)
== LADSPA_HINT_DEFAULT_HIGH)
#define LADSPA_IS_HINT_DEFAULT_MAXIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_MAXIMUM)
== LADSPA_HINT_DEFAULT_MAXIMUM)
#define LADSPA_IS_HINT_DEFAULT_0(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_0)
== LADSPA_HINT_DEFAULT_0)
#define LADSPA_IS_HINT_DEFAULT_1(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_1)
== LADSPA_HINT_DEFAULT_1)
#define LADSPA_IS_HINT_DEFAULT_100(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_100)
== LADSPA_HINT_DEFAULT_100)
#define LADSPA_IS_HINT_DEFAULT_440(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_440)
== LADSPA_HINT_DEFAULT_440)
typedef struct _LADSPA_PortRangeHint {
@ -353,7 +353,7 @@ typedef struct _LADSPA_PortRangeHint {
/*****************************************************************************/
/* Plugin Handles:
/* Plugin Handles:
This plugin handle indicates a particular instance of the plugin
concerned. It is valid to compare this to NULL (0 for C++) but
@ -364,13 +364,13 @@ typedef void * LADSPA_Handle;
/*****************************************************************************/
/* Descriptor for a Type of Plugin:
/* Descriptor for a Type of Plugin:
This structure is used to describe a plugin type. It provides a
number of functions to examine the type, instantiate it, link it to
buffers and workspaces and to run it. */
typedef struct _LADSPA_Descriptor {
typedef struct _LADSPA_Descriptor {
/* This numeric identifier indicates the plugin type
uniquely. Plugin programmers may reserve ranges of IDs from a
@ -430,12 +430,12 @@ typedef struct _LADSPA_Descriptor {
instantiation function accepts a sample rate as a parameter. The
plugin descriptor from which this instantiate function was found
must also be passed. This function must return NULL if
instantiation fails.
instantiation fails.
Note that instance initialisation should generally occur in
activate() rather than here. */
LADSPA_Handle (*instantiate)(const struct _LADSPA_Descriptor * Descriptor,
unsigned long SampleRate);
unsigned long SampleRate);
/* This member is a function pointer that connects a port on an
instantiated plugin to a memory location at which a block of data
@ -464,8 +464,8 @@ typedef struct _LADSPA_Descriptor {
However, overlapped buffers or use of a single buffer for both
audio and control data may result in unexpected behaviour. */
void (*connect_port)(LADSPA_Handle Instance,
unsigned long Port,
LADSPA_Data * DataLocation);
unsigned long Port,
LADSPA_Data * DataLocation);
/* This member is a function pointer that initialises a plugin
instance and activates it for use. This is separated from
@ -503,7 +503,7 @@ typedef struct _LADSPA_Descriptor {
then there are various things that the plugin should not do
within the run() or run_adding() functions (see above). */
void (*run)(LADSPA_Handle Instance,
unsigned long SampleCount);
unsigned long SampleCount);
/* This method is a function pointer that runs an instance of a
plugin for a block. This has identical behaviour to run() except
@ -519,7 +519,7 @@ typedef struct _LADSPA_Descriptor {
this function pointer must be set to NULL. When it is provided,
the function set_run_adding_gain() must be provided also. */
void (*run_adding)(LADSPA_Handle Instance,
unsigned long SampleCount);
unsigned long SampleCount);
/* This method is a function pointer that sets the output gain for
use when run_adding() is called (see above). If this function is
@ -531,7 +531,7 @@ typedef struct _LADSPA_Descriptor {
run_adding() function is provided. When it is absent this
function pointer must be set to NULL. */
void (*set_run_adding_gain)(LADSPA_Handle Instance,
LADSPA_Data Gain);
LADSPA_Data Gain);
/* This is the counterpart to activate() (see above). If there is
nothing for deactivate() to do then the plugin writer may provide
@ -551,7 +551,7 @@ typedef struct _LADSPA_Descriptor {
/* Once an instance of a plugin has been finished with it can be
deleted using the following function. The instance handle passed
ceases to be valid after this call.
If activate() was called for a plugin instance then a
corresponding call to deactivate() must be made before cleanup()
is called. */
@ -589,7 +589,7 @@ typedef struct _LADSPA_Descriptor {
const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index);
/* Datatype corresponding to the ladspa_descriptor() function. */
typedef const LADSPA_Descriptor *
typedef const LADSPA_Descriptor *
(*LADSPA_Descriptor_Function)(unsigned long Index);
/**********************************************************************/

View file

@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#define SND_MASK_C
#define SND_MASK_INLINE

View file

@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
typedef struct _snd_mask snd_mask_t;
#define SND_MASK_MAX 64

View file

@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <strings.h>
#include <sys/types.h>
@ -32,36 +32,36 @@
MASK_INLINE unsigned int ld2(uint32_t v)
{
unsigned r = 0;
unsigned r = 0;
if (v >= 0x10000) {
v >>= 16;
r += 16;
}
if (v >= 0x100) {
v >>= 8;
r += 8;
}
if (v >= 0x10) {
v >>= 4;
r += 4;
}
if (v >= 4) {
v >>= 2;
r += 2;
}
if (v >= 2)
r++;
return r;
if (v >= 0x10000) {
v >>= 16;
r += 16;
}
if (v >= 0x100) {
v >>= 8;
r += 8;
}
if (v >= 0x10) {
v >>= 4;
r += 4;
}
if (v >= 4) {
v >>= 2;
r += 2;
}
if (v >= 2)
r++;
return r;
}
MASK_INLINE unsigned int hweight32(uint32_t v)
{
v = (v & 0x55555555) + ((v >> 1) & 0x55555555);
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
v = (v & 0x0F0F0F0F) + ((v >> 4) & 0x0F0F0F0F);
v = (v & 0x00FF00FF) + ((v >> 8) & 0x00FF00FF);
return (v & 0x0000FFFF) + ((v >> 16) & 0x0000FFFF);
v = (v & 0x55555555) + ((v >> 1) & 0x55555555);
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
v = (v & 0x0F0F0F0F) + ((v >> 4) & 0x0F0F0F0F);
v = (v & 0x00FF00FF) + ((v >> 8) & 0x00FF00FF);
return (v & 0x0000FFFF) + ((v >> 16) & 0x0000FFFF);
}
MASK_INLINE size_t snd_mask_sizeof(void)

File diff suppressed because it is too large Load diff

View file

@ -32,7 +32,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/*
These routines convert 16 bit linear PCM samples to 4 bit ADPCM code
and vice versa. The ADPCM code used is the Intel/DVI ADPCM code which
@ -376,7 +376,7 @@ static int snd_pcm_adpcm_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_
return err;
return 0;
}
static int snd_pcm_adpcm_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
@ -477,7 +477,7 @@ snd_pcm_adpcm_write_areas(snd_pcm_t *pcm,
if (size > *slave_sizep)
size = *slave_sizep;
adpcm->func(slave_areas, slave_offset,
areas, offset,
areas, offset,
pcm->channels, size,
adpcm->getput_idx, adpcm->states);
*slave_sizep = size;
@ -496,7 +496,7 @@ snd_pcm_adpcm_read_areas(snd_pcm_t *pcm,
snd_pcm_adpcm_t *adpcm = pcm->private_data;
if (size > *slave_sizep)
size = *slave_sizep;
adpcm->func(areas, offset,
adpcm->func(areas, offset,
slave_areas, slave_offset,
pcm->channels, size,
adpcm->getput_idx, adpcm->states);
@ -507,7 +507,7 @@ snd_pcm_adpcm_read_areas(snd_pcm_t *pcm,
static void snd_pcm_adpcm_dump(snd_pcm_t *pcm, snd_output_t *out)
{
snd_pcm_adpcm_t *adpcm = pcm->private_data;
snd_output_printf(out, "Ima-ADPCM conversion PCM (%s)\n",
snd_output_printf(out, "Ima-ADPCM conversion PCM (%s)\n",
snd_pcm_format_name(adpcm->sformat));
if (pcm->setup) {
snd_output_printf(out, "Its setup is:\n");
@ -596,15 +596,15 @@ format and rate must match for both of them.
\code
pcm.name {
type adpcm # Ima-ADPCM conversion PCM
slave STR # Slave name
# or
slave { # Slave definition
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
format STR # Slave format
}
type adpcm # Ima-ADPCM conversion PCM
slave STR # Slave name
# or
slave { # Slave definition
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
format STR # Slave format
}
}
\endcode
@ -631,7 +631,7 @@ pcm.name {
* changed in future.
*/
int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *root, snd_config_t *conf,
snd_config_t *root, snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
snd_config_iterator_t i, next;
@ -650,11 +650,11 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
slave = n;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(PCM, "Unknown field %s", id);
return -EINVAL;
}
if (!slave) {
SNDERR("slave is not defined");
snd_error(PCM, "slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, 1,
@ -663,8 +663,8 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
return err;
if (snd_pcm_format_linear(sformat) != 1 &&
sformat != SND_PCM_FORMAT_IMA_ADPCM) {
snd_config_delete(sconf);
SNDERR("invalid slave format");
snd_config_delete(sconf);
snd_error(PCM, "invalid slave format");
return -EINVAL;
}
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode, conf);

View file

@ -25,7 +25,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "pcm_local.h"
#include "bswap.h"
#include "pcm_plugin.h"
@ -232,7 +232,7 @@ static int snd_pcm_alaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT,
&format_mask);
} else {
err = _snd_pcm_hw_params_set_format(params,
err = _snd_pcm_hw_params_set_format(params,
SND_PCM_FORMAT_A_LAW);
}
if (err < 0)
@ -273,7 +273,7 @@ static int snd_pcm_alaw_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_p
return err;
return 0;
}
static int snd_pcm_alaw_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
@ -317,7 +317,7 @@ static int snd_pcm_alaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
err = INTERNAL(snd_pcm_hw_params_get_format)(params, &format);
if (err < 0)
return err;
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
if (alaw->sformat == SND_PCM_FORMAT_A_LAW) {
alaw->getput_idx = snd_pcm_linear_get_index(format, SND_PCM_FORMAT_S16);
@ -351,7 +351,7 @@ snd_pcm_alaw_write_areas(snd_pcm_t *pcm,
if (size > *slave_sizep)
size = *slave_sizep;
alaw->func(slave_areas, slave_offset,
areas, offset,
areas, offset,
pcm->channels, size,
alaw->getput_idx);
*slave_sizep = size;
@ -370,7 +370,7 @@ snd_pcm_alaw_read_areas(snd_pcm_t *pcm,
snd_pcm_alaw_t *alaw = pcm->private_data;
if (size > *slave_sizep)
size = *slave_sizep;
alaw->func(areas, offset,
alaw->func(areas, offset,
slave_areas, slave_offset,
pcm->channels, size,
alaw->getput_idx);
@ -381,7 +381,7 @@ snd_pcm_alaw_read_areas(snd_pcm_t *pcm,
static void snd_pcm_alaw_dump(snd_pcm_t *pcm, snd_output_t *out)
{
snd_pcm_alaw_t *alaw = pcm->private_data;
snd_output_printf(out, "A-Law conversion PCM (%s)\n",
snd_output_printf(out, "A-Law conversion PCM (%s)\n",
snd_pcm_format_name(alaw->sformat));
if (pcm->setup) {
snd_output_printf(out, "Its setup is:\n");
@ -420,7 +420,7 @@ static const snd_pcm_ops_t snd_pcm_alaw_ops = {
* \warning Using of this function might be dangerous in the sense
* of compatibility reasons. The prototype might be freely
* changed in future.
*/
*/
int snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *pcm;
@ -471,15 +471,15 @@ format and rate must match for both of them.
\code
pcm.name {
type alaw # A-Law conversion PCM
slave STR # Slave name
# or
slave { # Slave definition
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
format STR # Slave format
}
type alaw # A-Law conversion PCM
slave STR # Slave name
# or
slave { # Slave definition
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
format STR # Slave format
}
}
\endcode
@ -506,7 +506,7 @@ pcm.name {
* changed in future.
*/
int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *root, snd_config_t *conf,
snd_config_t *root, snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
snd_config_iterator_t i, next;
@ -525,11 +525,11 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
slave = n;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(PCM, "Unknown field %s", id);
return -EINVAL;
}
if (!slave) {
SNDERR("slave is not defined");
snd_error(PCM, "slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, 1,
@ -538,8 +538,8 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
return err;
if (snd_pcm_format_linear(sformat) != 1 &&
sformat != SND_PCM_FORMAT_A_LAW) {
snd_config_delete(sconf);
SNDERR("invalid slave format");
snd_config_delete(sconf);
snd_error(PCM, "invalid slave format");
return -EINVAL;
}
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode, conf);

View file

@ -22,21 +22,21 @@ Slave PCMs can be defined asymmetrically for both directions.
\code
pcm.name {
type asym # Asym PCM
playback STR # Playback slave name
# or
playback { # Playback slave definition
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
}
capture STR # Capture slave name
# or
capture { # Capture slave definition
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
}
type asym # Asym PCM
playback STR # Playback slave name
# or
playback { # Playback slave definition
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
}
capture STR # Capture slave name
# or
capture { # Capture slave definition
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
}
}
\endcode
@ -98,12 +98,13 @@ int _snd_pcm_asym_open(snd_pcm_t **pcmp, const char *name ATTRIBUTE_UNUSED,
slave = n;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(PCM, "Unknown field %s", id);
return -EINVAL;
}
if (! slave) {
SNDERR("%s slave is not defined",
stream == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture");
snd_error(PCM, "%s slave is not defined",
stream == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, 0);

View file

@ -25,7 +25,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "pcm_local.h"
#include "pcm_plugin.h"
#include "bswap.h"
@ -73,7 +73,7 @@ static int snd_pcm_copy_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_p
return err;
return 0;
}
static int snd_pcm_copy_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
@ -133,7 +133,7 @@ snd_pcm_copy_read_areas(snd_pcm_t *pcm,
{
if (size > *slave_sizep)
size = *slave_sizep;
snd_pcm_areas_copy(areas, offset,
snd_pcm_areas_copy(areas, offset,
slave_areas, slave_offset,
pcm->channels, size, pcm->format);
*slave_sizep = size;
@ -222,7 +222,7 @@ int snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int
\section pcm_plugins_copy Plugin: copy
This plugin copies samples from master copy PCM to given slave PCM.
The channel count, format and rate must match for both of them.
The channel count, format and rate must match for both of them.
\code
pcm.name {
@ -260,7 +260,7 @@ pcm.name {
* changed in future.
*/
int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *root, snd_config_t *conf,
snd_config_t *root, snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
snd_config_iterator_t i, next;
@ -278,11 +278,11 @@ int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name,
slave = n;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(PCM, "Unknown field %s", id);
return -EINVAL;
}
if (!slave) {
SNDERR("slave is not defined");
snd_error(PCM, "slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, 0);

View file

@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
@ -44,7 +44,7 @@
/*
*
*/
#if !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__ANDROID__)
union semun {
int val; /* Value for SETVAL */
@ -55,7 +55,7 @@ union semun {
#endif
};
#endif
/*
* FIXME:
* add possibility to use futexes here
@ -96,14 +96,14 @@ static unsigned int snd_pcm_direct_magic(snd_pcm_direct_t *dmix)
}
/*
* global shared memory area
* global shared memory area
*/
int snd_pcm_direct_shm_create_or_connect(snd_pcm_direct_t *dmix)
{
struct shmid_ds buf;
int tmpid, err, first_instance = 0;
retryget:
dmix->shmid = shmget(dmix->ipc_key, sizeof(snd_pcm_direct_share_t),
dmix->ipc_perm);
@ -120,7 +120,7 @@ retryget:
if ((tmpid = shmget(dmix->ipc_key, 0, dmix->ipc_perm)) != -1)
if (!shmctl(tmpid, IPC_STAT, &buf))
if (!buf.shm_nattch)
/* no users so destroy the segment */
/* no users so destroy the segment */
if (!shmctl(tmpid, IPC_RMID, NULL))
goto retryget;
return err;
@ -212,7 +212,7 @@ static int make_local_socket(const char *filename, int server, mode_t ipc_perm,
sock = socket(PF_LOCAL, SOCK_STREAM, 0);
if (sock < 0) {
int result = -errno;
SYSERR("socket failed");
snd_errornum(PCM, "socket failed");
return result;
}
@ -221,17 +221,17 @@ static int make_local_socket(const char *filename, int server, mode_t ipc_perm,
memset(addr, 0, size); /* make valgrind happy */
addr->sun_family = AF_LOCAL;
memcpy(addr->sun_path, filename, l);
if (server) {
if (bind(sock, (struct sockaddr *) addr, size) < 0) {
int result = -errno;
SYSERR("bind failed: %s", filename);
snd_errornum(PCM, "bind failed: %s", filename);
close(sock);
return result;
} else {
if (chmod(filename, ipc_perm) < 0) {
int result = -errno;
SYSERR("chmod failed: %s", filename);
snd_errornum(PCM, "chmod failed: %s", filename);
close(sock);
unlink(filename);
return result;
@ -239,7 +239,7 @@ static int make_local_socket(const char *filename, int server, mode_t ipc_perm,
if (chown(filename, -1, ipc_gid) < 0) {
#if 0 /* it's not fatal */
int result = -errno;
SYSERR("chown failed: %s", filename);
snd_errornum(PCM, "chown failed: %s", filename);
close(sock);
unlink(filename);
return result;
@ -249,7 +249,7 @@ static int make_local_socket(const char *filename, int server, mode_t ipc_perm,
} else {
if (connect(sock, (struct sockaddr *) addr, size) < 0) {
int result = -errno;
SYSERR("connect failed: %s", filename);
snd_errornum(PCM, "connect failed: %s", filename);
close(sock);
return result;
}
@ -309,7 +309,7 @@ static int _snd_send_fd(int sock, void *data, size_t len, int fd)
msghdr.msg_name = NULL;
msghdr.msg_namelen = 0;
msghdr.msg_iov = &vec;
msghdr.msg_iovlen = 1;
msghdr.msg_iovlen = 1;
msghdr.msg_control = cmsg;
msghdr.msg_controllen = cmsg_len;
msghdr.msg_flags = 0;
@ -342,7 +342,7 @@ static void server_job(snd_pcm_direct_t *dmix)
if (i != dmix->server_fd && i != dmix->hw_fd)
close(i);
}
/* detach from parent */
setsid();
@ -431,7 +431,7 @@ int snd_pcm_direct_server_create(snd_pcm_direct_t *dmix)
ret = get_tmp_name(dmix->shmptr->socket_name, sizeof(dmix->shmptr->socket_name));
if (ret < 0)
return ret;
ret = make_local_socket(dmix->shmptr->socket_name, 1, dmix->ipc_perm, dmix->ipc_gid);
if (ret < 0)
return ret;
@ -442,7 +442,7 @@ int snd_pcm_direct_server_create(snd_pcm_direct_t *dmix)
close(dmix->server_fd);
return ret;
}
ret = fork();
if (ret < 0) {
close(dmix->server_fd);
@ -585,7 +585,7 @@ int snd_pcm_direct_slave_recover(snd_pcm_direct_t *direct)
semerr = snd_pcm_direct_semaphore_down(direct,
DIRECT_IPC_SEM_CLIENT);
if (semerr < 0) {
SNDERR("SEMDOWN FAILED with err %d", semerr);
snd_error(PCM, "SEMDOWN FAILED with err %d", semerr);
return semerr;
}
@ -595,7 +595,7 @@ int snd_pcm_direct_slave_recover(snd_pcm_direct_t *direct)
semerr = snd_pcm_direct_semaphore_up(direct,
DIRECT_IPC_SEM_CLIENT);
if (semerr < 0) {
SNDERR("SEMUP FAILED with err %d", semerr);
snd_error(PCM, "SEMUP FAILED with err %d", semerr);
return semerr;
}
return 0;
@ -621,11 +621,11 @@ int snd_pcm_direct_slave_recover(snd_pcm_direct_t *direct)
ret = snd_pcm_prepare(direct->spcm);
if (ret < 0) {
SNDERR("recover: unable to prepare slave");
snd_error(PCM, "recover: unable to prepare slave");
semerr = snd_pcm_direct_semaphore_up(direct,
DIRECT_IPC_SEM_CLIENT);
if (semerr < 0) {
SNDERR("SEMUP FAILED with err %d", semerr);
snd_error(PCM, "SEMUP FAILED with err %d", semerr);
return semerr;
}
return ret;
@ -641,11 +641,11 @@ int snd_pcm_direct_slave_recover(snd_pcm_direct_t *direct)
ret = snd_pcm_start(direct->spcm);
if (ret < 0) {
SNDERR("recover: unable to start slave");
snd_error(PCM, "recover: unable to start slave");
semerr = snd_pcm_direct_semaphore_up(direct,
DIRECT_IPC_SEM_CLIENT);
if (semerr < 0) {
SNDERR("SEMUP FAILED with err %d", semerr);
snd_error(PCM, "SEMUP FAILED with err %d", semerr);
return semerr;
}
return ret;
@ -653,7 +653,7 @@ int snd_pcm_direct_slave_recover(snd_pcm_direct_t *direct)
semerr = snd_pcm_direct_semaphore_up(direct,
DIRECT_IPC_SEM_CLIENT);
if (semerr < 0) {
SNDERR("SEMUP FAILED with err %d", semerr);
snd_error(PCM, "SEMUP FAILED with err %d", semerr);
return semerr;
}
return 0;
@ -727,7 +727,7 @@ int snd_pcm_direct_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds,
unsigned int space)
{
if (pcm->poll_fd < 0) {
SNDMSG("poll_fd < 0");
snd_check(PCM, "poll_fd < 0");
return -EIO;
}
if (space >= 1 && pfds) {
@ -845,7 +845,7 @@ static int hw_param_interval_refine_one(snd_pcm_hw_params_t *params,
return 0;
i = hw_param_interval(params, var);
if (snd_interval_empty(i)) {
SNDERR("dshare interval %i empty?", (int)var);
snd_error(PCM, "dshare interval %i empty?", (int)var);
return -EINVAL;
}
if (snd_interval_refine(i, src))
@ -894,7 +894,7 @@ static int snd_interval_step(struct snd_interval *i, unsigned int min,
int snd_pcm_direct_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
snd_pcm_direct_t *dshare = pcm->private_data;
static const snd_mask_t access = { .bits = {
static const snd_mask_t access = { .bits = {
(1<<SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) |
(1<<SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED) |
(1<<SNDRV_PCM_ACCESS_RW_INTERLEAVED) |
@ -910,7 +910,7 @@ int snd_pcm_direct_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
#endif
if (params->rmask & (1<<SND_PCM_HW_PARAM_ACCESS)) {
if (snd_mask_empty(hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS))) {
SNDERR("dshare access mask empty?");
snd_error(PCM, "dshare access mask empty?");
return -EINVAL;
}
if (snd_mask_refine(hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS), &access))
@ -918,7 +918,7 @@ int snd_pcm_direct_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
}
if (params->rmask & (1<<SND_PCM_HW_PARAM_FORMAT)) {
if (snd_mask_empty(hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT))) {
SNDERR("dshare format mask empty?");
snd_error(PCM, "dshare format mask empty?");
return -EINVAL;
}
if (snd_mask_refine_set(hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT),
@ -928,7 +928,7 @@ int snd_pcm_direct_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
//snd_mask_none(hw_param_mask(params, SND_PCM_HW_PARAM_SUBFORMAT));
if (params->rmask & (1<<SND_PCM_HW_PARAM_CHANNELS)) {
if (snd_interval_empty(hw_param_interval(params, SND_PCM_HW_PARAM_CHANNELS))) {
SNDERR("dshare channels mask empty?");
snd_error(PCM, "dshare channels mask empty?");
return -EINVAL;
}
err = snd_interval_refine_set(hw_param_interval(params, SND_PCM_HW_PARAM_CHANNELS), dshare->channels);
@ -1057,14 +1057,14 @@ int snd_pcm_direct_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
int snd_pcm_direct_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info)
{
return snd_pcm_channel_info_shm(pcm, info, -1);
return snd_pcm_channel_info_shm(pcm, info, -1);
}
int snd_pcm_direct_mmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
{
return 0;
}
int snd_pcm_direct_munmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
{
return 0;
@ -1202,13 +1202,13 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
int loops = 10;
__again:
if (loops-- <= 0) {
SNDERR("unable to find a valid configuration for slave");
return -EINVAL;
}
if (loops-- <= 0) {
snd_error(PCM, "unable to find a valid configuration for slave");
return -EINVAL;
}
ret = snd_pcm_hw_params_any(spcm, &hw_params);
if (ret < 0) {
SNDERR("snd_pcm_hw_params_any failed");
snd_error(PCM, "snd_pcm_hw_params_any failed");
return ret;
}
ret = snd_pcm_hw_params_set_access(spcm, &hw_params,
@ -1217,7 +1217,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
ret = snd_pcm_hw_params_set_access(spcm, &hw_params,
SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
if (ret < 0) {
SNDERR("slave plugin does not support mmap interleaved or mmap noninterleaved access");
snd_error(PCM, "slave plugin does not support mmap interleaved or mmap noninterleaved access");
return ret;
}
}
@ -1254,7 +1254,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
&hw_params, &format);
}
if (ret < 0) {
SNDERR("requested or auto-format is not available");
snd_error(PCM, "requested or auto-format is not available");
return ret;
}
params->format = format;
@ -1262,13 +1262,13 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
ret = INTERNAL(snd_pcm_hw_params_set_channels_near)(spcm, &hw_params,
(unsigned int *)&params->channels);
if (ret < 0) {
SNDERR("requested count of channels is not available");
snd_error(PCM, "requested count of channels is not available");
return ret;
}
ret = INTERNAL(snd_pcm_hw_params_set_rate_near)(spcm, &hw_params,
(unsigned int *)&params->rate, 0);
if (ret < 0) {
SNDERR("requested rate is not available");
snd_error(PCM, "requested rate is not available");
return ret;
}
@ -1277,14 +1277,14 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
ret = INTERNAL(snd_pcm_hw_params_set_buffer_time_near)(spcm,
&hw_params, (unsigned int *)&params->buffer_time, 0);
if (ret < 0) {
SNDERR("unable to set buffer time");
snd_error(PCM, "unable to set buffer time");
return ret;
}
} else if (params->buffer_size > 0) {
ret = INTERNAL(snd_pcm_hw_params_set_buffer_size_near)(spcm,
&hw_params, (snd_pcm_uframes_t *)&params->buffer_size);
if (ret < 0) {
SNDERR("unable to set buffer size");
snd_error(PCM, "unable to set buffer size");
return ret;
}
} else {
@ -1295,7 +1295,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
ret = INTERNAL(snd_pcm_hw_params_set_period_time_near)(spcm,
&hw_params, (unsigned int *)&params->period_time, 0);
if (ret < 0) {
SNDERR("unable to set period_time");
snd_error(PCM, "unable to set period_time");
return ret;
}
} else if (params->period_size > 0) {
@ -1303,17 +1303,17 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
&hw_params, (snd_pcm_uframes_t *)&params->period_size,
0);
if (ret < 0) {
SNDERR("unable to set period_size");
snd_error(PCM, "unable to set period_size");
return ret;
}
}
}
if (buffer_is_not_initialized && params->periods > 0) {
unsigned int periods = params->periods;
ret = INTERNAL(snd_pcm_hw_params_set_periods_near)(spcm,
&hw_params, &params->periods, 0);
if (ret < 0) {
SNDERR("unable to set requested periods");
snd_error(PCM, "unable to set requested periods");
return ret;
}
if (params->periods == 1) {
@ -1325,14 +1325,14 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
params->period_size /= 2;
goto __again;
}
SNDERR("unable to use stream with periods == 1");
snd_error(PCM, "unable to use stream with periods == 1");
return ret;
}
}
ret = snd_pcm_hw_params(spcm, &hw_params);
if (ret < 0) {
SNDERR("unable to install hw params");
snd_error(PCM, "unable to install hw params");
return ret;
}
@ -1356,18 +1356,18 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
ret = snd_pcm_sw_params_current(spcm, &sw_params);
if (ret < 0) {
SNDERR("unable to get current sw_params");
snd_error(PCM, "unable to get current sw_params");
return ret;
}
ret = snd_pcm_sw_params_get_boundary(&sw_params, &boundary);
if (ret < 0) {
SNDERR("unable to get boundary");
snd_error(PCM, "unable to get boundary");
return ret;
}
ret = snd_pcm_sw_params_set_stop_threshold(spcm, &sw_params, boundary);
if (ret < 0) {
SNDERR("unable to set stop threshold");
snd_error(PCM, "unable to set stop threshold");
return ret;
}
@ -1378,7 +1378,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
ret = snd_pcm_sw_params_set_tstamp_mode(spcm, &sw_params,
SND_PCM_TSTAMP_ENABLE);
if (ret < 0) {
SNDERR("unable to tstamp mode MMAP");
snd_error(PCM, "unable to tstamp mode MMAP");
return ret;
}
@ -1386,7 +1386,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
ret = snd_pcm_sw_params_set_tstamp_type(spcm, &sw_params,
dmix->tstamp_type);
if (ret < 0) {
SNDERR("unable to set tstamp type");
snd_error(PCM, "unable to set tstamp type");
return ret;
}
}
@ -1397,12 +1397,12 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
ret = snd_pcm_sw_params_set_silence_threshold(spcm, &sw_params, 0);
if (ret < 0) {
SNDERR("unable to set silence threshold");
snd_error(PCM, "unable to set silence threshold");
return ret;
}
ret = snd_pcm_sw_params_set_silence_size(spcm, &sw_params, boundary);
if (ret < 0) {
SNDERR("unable to set silence threshold (please upgrade to 0.9.0rc8+ driver)");
snd_error(PCM, "unable to set silence threshold (please upgrade to 0.9.0rc8+ driver)");
return ret;
}
@ -1410,7 +1410,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
ret = snd_pcm_sw_params(spcm, &sw_params);
if (ret < 0) {
SNDERR("unable to install sw params (please upgrade to 0.9.0rc8+ driver)");
snd_error(PCM, "unable to install sw params (please upgrade to 0.9.0rc8+ driver)");
return ret;
}
@ -1420,20 +1420,20 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
snd_pcm_areas_silence(dst_areas, 0, spcm->channels,
spcm->buffer_size, spcm->format);
}
ret = snd_pcm_start(spcm);
if (ret < 0) {
SNDERR("unable to start PCM stream");
snd_error(PCM, "unable to start PCM stream");
return ret;
}
if (snd_pcm_poll_descriptors_count(spcm) != 1) {
SNDERR("unable to use hardware pcm with fd more than one!!!");
snd_error(PCM, "unable to use hardware pcm with fd more than one!!!");
return ret;
}
snd_pcm_poll_descriptors(spcm, &fd, 1);
dmix->hw_fd = fd.fd;
save_slave_setting(dmix, spcm);
/* Currently, we assume that each dmix client has the same
@ -1476,7 +1476,7 @@ int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix)
dmix->timer_ticks = 1;
ret = snd_pcm_info(dmix->spcm, &info);
if (ret < 0) {
SNDERR("unable to info for slave pcm");
snd_error(PCM, "unable to info for slave pcm");
return ret;
}
sprintf(name, "hw:CLASS=%i,SCLASS=0,CARD=%i,DEV=%i,SUBDEV=%i",
@ -1491,13 +1491,13 @@ int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix)
ret = snd_timer_open(&dmix->timer, name,
SND_TIMER_OPEN_NONBLOCK);
if (ret < 0) {
SNDERR("unable to open timer '%s'", name);
snd_error(PCM, "unable to open timer '%s'", name);
return ret;
}
}
if (snd_timer_poll_descriptors_count(dmix->timer) != 1) {
SNDERR("unable to use timer '%s' with more than one fd!", name);
snd_error(PCM, "unable to use timer '%s' with more than one fd!", name);
return ret;
}
snd_timer_poll_descriptors(dmix->timer, &dmix->timer_fd, 1);
@ -1598,10 +1598,10 @@ int snd_pcm_direct_open_secondary_client(snd_pcm_t **spcmp, snd_pcm_direct_t *dm
ret = snd_pcm_hw_open_fd(spcmp, client_name, dmix->hw_fd, 0);
if (ret < 0) {
SNDERR("unable to open hardware");
snd_error(PCM, "unable to open hardware");
return ret;
}
spcm = *spcmp;
spcm->donot_close = 1;
spcm->setup = 1;
@ -1616,7 +1616,7 @@ int snd_pcm_direct_open_secondary_client(snd_pcm_t **spcmp, snd_pcm_direct_t *dm
ret = snd_pcm_mmap(spcm);
if (ret < 0) {
SNDERR("unable to mmap channels");
snd_error(PCM, "unable to mmap channels");
return ret;
}
return 0;
@ -1643,7 +1643,7 @@ int snd_pcm_direct_initialize_secondary_slave(snd_pcm_direct_t *dmix,
ret = snd_pcm_mmap(spcm);
if (ret < 0) {
SNDERR("unable to mmap channels");
snd_error(PCM, "unable to mmap channels");
return ret;
}
return 0;
@ -1666,7 +1666,7 @@ int snd_pcm_direct_set_timer_params(snd_pcm_direct_t *dmix)
}
ret = snd_timer_params(dmix->timer, &params);
if (ret < 0) {
SNDERR("unable to set timer parameters");
snd_error(PCM, "unable to set timer parameters");
return ret;
}
return 0;
@ -1729,7 +1729,7 @@ int snd_pcm_direct_parse_bindings(snd_pcm_direct_t *dmix,
if (cfg == NULL)
return 0;
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("invalid type for bindings");
snd_error(PCM, "invalid type for bindings");
return -EINVAL;
}
snd_config_for_each(i, next, cfg) {
@ -1740,7 +1740,7 @@ int snd_pcm_direct_parse_bindings(snd_pcm_direct_t *dmix,
continue;
err = safe_strtol(id, &cchannel);
if (err < 0 || cchannel < 0) {
SNDERR("invalid client channel in binding: %s", id);
snd_error(PCM, "invalid client channel in binding: %s", id);
return -EINVAL;
}
if ((unsigned)cchannel >= count)
@ -1749,7 +1749,7 @@ int snd_pcm_direct_parse_bindings(snd_pcm_direct_t *dmix,
if (count == 0)
return 0;
if (count > 1024) {
SNDERR("client channel out of range");
snd_error(PCM, "client channel out of range");
return -EINVAL;
}
bindings = malloc(count * sizeof(unsigned int));
@ -1765,13 +1765,14 @@ int snd_pcm_direct_parse_bindings(snd_pcm_direct_t *dmix,
continue;
safe_strtol(id, &cchannel);
if (snd_config_get_integer(n, &schannel) < 0) {
SNDERR("unable to get slave channel (should be integer type) in binding: %s", id);
snd_error(PCM, "unable to get slave channel (should be integer type) in binding: %s", id);
free(bindings);
return -EINVAL;
}
if (schannel < 0 || schannel >= params->channels) {
SNDERR("invalid slave channel number %ld in binding to %ld",
schannel, cchannel);
snd_error(PCM, "invalid slave channel number %ld in binding to %ld",
schannel, cchannel);
free(bindings);
return -EINVAL;
}
@ -1785,7 +1786,7 @@ int snd_pcm_direct_parse_bindings(snd_pcm_direct_t *dmix,
if (chn == chn1)
continue;
if (bindings[chn] == dmix->bindings[chn1]) {
SNDERR("unable to route channels %d,%d to same destination %d", chn, chn1, bindings[chn]);
snd_error(PCM, "unable to route channels %d,%d to same destination %d", chn, chn1, bindings[chn]);
free(bindings);
return -EINVAL;
}
@ -1814,12 +1815,12 @@ static int _snd_pcm_direct_get_slave_ipc_offset(snd_config_t *root,
if (snd_config_get_string(sconf, &str) >= 0) {
if (hop > SND_CONF_MAX_HOPS) {
SNDERR("Too many definition levels (looped?)");
snd_error(PCM, "Too many definition levels (looped?)");
return -EINVAL;
}
err = snd_config_search_definition(root, "pcm", str, &pcm_conf);
if (err < 0) {
SNDERR("Unknown slave PCM %s", str);
snd_error(PCM, "Unknown slave PCM %s", str);
return err;
}
err = _snd_pcm_direct_get_slave_ipc_offset(root, pcm_conf,
@ -1869,11 +1870,11 @@ static int _snd_pcm_direct_get_slave_ipc_offset(snd_config_t *root,
if (strcmp(id, "type") == 0) {
err = snd_config_get_string(n, &str);
if (err < 0) {
SNDERR("Invalid value for PCM type definition");
snd_error(PCM, "Invalid value for PCM type definition");
return -EINVAL;
}
if (strcmp(str, "hw")) {
SNDERR("Invalid type '%s' for slave PCM", str);
snd_error(PCM, "Invalid type '%s' for slave PCM", str);
return -EINVAL;
}
continue;
@ -1888,7 +1889,7 @@ static int _snd_pcm_direct_get_slave_ipc_offset(snd_config_t *root,
if (strcmp(id, "device") == 0) {
err = snd_config_get_integer(n, &device);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
return err;
}
continue;
@ -1896,7 +1897,7 @@ static int _snd_pcm_direct_get_slave_ipc_offset(snd_config_t *root,
if (strcmp(id, "subdevice") == 0) {
err = snd_config_get_integer(n, &subdevice);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
return err;
}
continue;
@ -1959,7 +1960,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
long key;
err = snd_config_get_integer(n, &key);
if (err < 0) {
SNDERR("The field ipc_key must be an integer type");
snd_error(PCM, "The field ipc_key must be an integer type");
return err;
}
@ -1970,11 +1971,11 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
long perm;
err = snd_config_get_integer(n, &perm);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
return err;
}
if ((perm & ~0777) != 0) {
SNDERR("The field ipc_perm must be a valid file permission");
snd_error(PCM, "The field ipc_perm must be a valid file permission");
return -EINVAL;
}
rec->ipc_perm = perm;
@ -1984,7 +1985,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
const char *str;
err = snd_config_get_string(n, &str);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
return -EINVAL;
}
if (strcmp(str, "no") == 0 || strcmp(str, "off") == 0)
@ -1996,7 +1997,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
else if (strcmp(str, "auto") == 0)
rec->hw_ptr_alignment = SND_PCM_HW_PTR_ALIGNMENT_AUTO;
else {
SNDERR("The field hw_ptr_alignment is invalid : %s", str);
snd_error(PCM, "The field hw_ptr_alignment is invalid : %s", str);
return -EINVAL;
}
@ -2006,7 +2007,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
const char *str;
err = snd_config_get_string(n, &str);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
return -EINVAL;
}
if (strcmp(str, "default") == 0)
@ -2018,7 +2019,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
else if (strcmp(str, "monotonic_raw") == 0)
rec->tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW;
else {
SNDERR("The field tstamp_type is invalid : %s", str);
snd_error(PCM, "The field tstamp_type is invalid : %s", str);
return -EINVAL;
}
continue;
@ -2028,7 +2029,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
char *endp;
err = snd_config_get_ascii(n, &group);
if (err < 0) {
SNDERR("The field ipc_gid must be a valid group");
snd_error(PCM, "The field ipc_gid must be a valid group");
return err;
}
if (! *group) {
@ -2045,7 +2046,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
return -ENOMEM;
int st = getgrnam_r(group, &grp, buffer, len, &pgrp);
if (st != 0 || !pgrp) {
SNDERR("The field ipc_gid must be a valid group (create group %s)", group);
snd_error(PCM, "The field ipc_gid must be a valid group (create group %s)", group);
free(buffer);
return -EINVAL;
}
@ -2059,7 +2060,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
}
if (strcmp(id, "ipc_key_add_uid") == 0) {
if ((err = snd_config_get_bool(n)) < 0) {
SNDERR("The field ipc_key_add_uid must be a boolean type");
snd_error(PCM, "The field ipc_key_add_uid must be a boolean type");
return err;
}
ipc_key_add_uid = err;
@ -2102,15 +2103,15 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
rec->direct_memory_access = err;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(PCM, "Unknown field %s", id);
return -EINVAL;
}
if (!rec->slave) {
SNDERR("slave is not defined");
snd_error(PCM, "slave is not defined");
return -EINVAL;
}
if (!rec->ipc_key) {
SNDERR("Unique IPC key is not defined");
snd_error(PCM, "Unique IPC key is not defined");
return -EINVAL;
}
if (ipc_key_add_uid)
@ -2175,7 +2176,7 @@ int _snd_pcm_direct_new(snd_pcm_t **pcmp, snd_pcm_direct_t **_dmix, int type,
while (1) {
ret = snd_pcm_direct_semaphore_create_or_connect(dmix);
if (ret < 0) {
SNDERR("unable to create IPC semaphore");
snd_error(PCM, "unable to create IPC semaphore");
goto _err_nosem_free;
}
ret = snd_pcm_direct_semaphore_down(dmix, DIRECT_IPC_SEM_CLIENT);
@ -2190,7 +2191,7 @@ int _snd_pcm_direct_new(snd_pcm_t **pcmp, snd_pcm_direct_t **_dmix, int type,
ret = snd_pcm_direct_shm_create_or_connect(dmix);
if (ret < 0) {
SNDERR("unable to create IPC shm instance");
snd_error(PCM, "unable to create IPC shm instance");
snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT);
goto _err_nosem_free;
} else {

View file

@ -19,7 +19,7 @@
*
*/
#include "pcm_local.h"
#include "pcm_local.h"
#include "../timer/timer_local.h"
#define DIRECT_IPC_SEMS 1
@ -103,8 +103,8 @@ typedef struct {
unsigned int period_step;
unsigned int sleep_min; /* not used */
unsigned int avail_min;
unsigned int start_threshold;
unsigned int stop_threshold;
unsigned int start_threshold;
unsigned int stop_threshold;
unsigned int silence_threshold;
unsigned int silence_size;
unsigned int recoveries; /* no of executed recoveries on slave*/
@ -308,7 +308,7 @@ static inline int snd_pcm_direct_semaphore_up(snd_pcm_direct_t *dmix, int sem_nu
static inline int snd_pcm_direct_semaphore_final(snd_pcm_direct_t *dmix, int sem_num)
{
if (dmix->locked[sem_num] != 1) {
SNDMSG("invalid semaphore count to finalize %d: %d", sem_num, dmix->locked[sem_num]);
snd_check(PCM, "invalid semaphore count to finalize %d: %d", sem_num, dmix->locked[sem_num]);
return -EBUSY;
}
return snd_pcm_direct_semaphore_up(dmix, sem_num);

View file

@ -25,7 +25,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
@ -63,7 +63,7 @@ const char *_snd_module_pcm_dmix = "";
static int shm_sum_discard(snd_pcm_direct_t *dmix);
/*
* sum ring buffer shared memory area
* sum ring buffer shared memory area
*/
static int shm_sum_create_or_connect(snd_pcm_direct_t *dmix)
{
@ -73,7 +73,7 @@ static int shm_sum_create_or_connect(snd_pcm_direct_t *dmix)
size = dmix->shmptr->s.channels *
dmix->shmptr->s.buffer_size *
sizeof(signed int);
sizeof(signed int);
retryshm:
dmix->u.dmix.shmid_sum = shmget(dmix->ipc_key + 1, size,
IPC_CREAT | dmix->ipc_perm);
@ -82,7 +82,7 @@ retryshm:
if (errno == EINVAL)
if ((tmpid = shmget(dmix->ipc_key + 1, 0, dmix->ipc_perm)) != -1)
if (!shmctl(tmpid, IPC_STAT, &buf))
if (!buf.shm_nattch)
if (!buf.shm_nattch)
/* no users so destroy the segment */
if (!shmctl(tmpid, IPC_RMID, NULL))
goto retryshm;
@ -95,7 +95,7 @@ retryshm:
}
if (dmix->ipc_gid >= 0) {
buf.shm_perm.gid = dmix->ipc_gid;
shmctl(dmix->u.dmix.shmid_sum, IPC_SET, &buf);
shmctl(dmix->u.dmix.shmid_sum, IPC_SET, &buf);
}
dmix->u.dmix.sum_buffer = shmat(dmix->u.dmix.shmid_sum, 0, 0);
if (dmix->u.dmix.sum_buffer == (void *) -1) {
@ -162,7 +162,7 @@ static void mix_areas(snd_pcm_direct_t *dmix,
unsigned int src_step, dst_step;
unsigned int chn, dchn, channels, sample_size;
mix_areas_t *do_mix_areas;
channels = dmix->channels;
switch (dmix->shmptr->s.format) {
case SND_PCM_FORMAT_S16_LE:
@ -230,7 +230,7 @@ static void remix_areas(snd_pcm_direct_t *dmix,
unsigned int src_step, dst_step;
unsigned int chn, dchn, channels, sample_size;
mix_areas_t *do_remix_areas;
channels = dmix->channels;
switch (dmix->shmptr->s.format) {
case SND_PCM_FORMAT_S16_LE:
@ -315,7 +315,7 @@ static void snd_pcm_dmix_sync_area(snd_pcm_t *pcm)
snd_pcm_uframes_t slave_hw_ptr, slave_appl_ptr, slave_size;
snd_pcm_uframes_t appl_ptr, size, transfer;
const snd_pcm_channel_area_t *src_areas, *dst_areas;
/* calculate the size to transfer */
/* check the available size in the local buffer
* last_appl_ptr keeps the last updated position
@ -391,7 +391,7 @@ static int snd_pcm_dmix_sync_ptr0(snd_pcm_t *pcm, snd_pcm_uframes_t slave_hw_ptr
snd_pcm_direct_t *dmix = pcm->private_data;
snd_pcm_uframes_t old_slave_hw_ptr, avail;
snd_pcm_sframes_t diff;
old_slave_hw_ptr = dmix->slave_hw_ptr;
dmix->slave_hw_ptr = slave_hw_ptr;
diff = pcm_frame_diff(slave_hw_ptr, old_slave_hw_ptr, dmix->slave_boundary);
@ -483,7 +483,7 @@ static int snd_pcm_dmix_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
{
snd_pcm_direct_t *dmix = pcm->private_data;
int err;
switch(dmix->state) {
case SNDRV_PCM_STATE_DRAINING:
case SNDRV_PCM_STATE_RUNNING:
@ -554,7 +554,7 @@ static int snd_pcm_dmix_start(snd_pcm_t *pcm)
snd_pcm_direct_t *dmix = pcm->private_data;
snd_pcm_sframes_t avail;
int err;
if (dmix->state != SND_PCM_STATE_PREPARED)
return -EBADFD;
avail = snd_pcm_mmap_playback_hw_avail(pcm);
@ -784,11 +784,11 @@ static int snd_pcm_dmix_close(snd_pcm_t *pcm)
snd_timer_close(dmix->timer);
snd_pcm_direct_semaphore_down(dmix, DIRECT_IPC_SEM_CLIENT);
snd_pcm_close(dmix->spcm);
if (dmix->server)
snd_pcm_direct_server_discard(dmix);
if (dmix->client)
snd_pcm_direct_client_discard(dmix);
shm_sum_discard(dmix);
if (dmix->server)
snd_pcm_direct_server_discard(dmix);
if (dmix->client)
snd_pcm_direct_client_discard(dmix);
shm_sum_discard(dmix);
if (snd_pcm_direct_shm_discard(dmix)) {
if (snd_pcm_direct_semaphore_discard(dmix))
snd_pcm_direct_semaphore_final(dmix, DIRECT_IPC_SEM_CLIENT);
@ -837,7 +837,7 @@ static snd_pcm_sframes_t snd_pcm_dmix_avail_update(snd_pcm_t *pcm)
{
snd_pcm_direct_t *dmix = pcm->private_data;
int err;
if (dmix->state == SND_PCM_STATE_RUNNING ||
dmix->state == SND_PCM_STATE_DRAINING) {
if ((err = snd_pcm_dmix_sync_ptr(pcm)) < 0)
@ -856,7 +856,7 @@ static int snd_pcm_dmix_htimestamp(snd_pcm_t *pcm,
snd_pcm_direct_t *dmix = pcm->private_data;
snd_pcm_uframes_t avail1;
int ok = 0;
while (1) {
if (dmix->state == SND_PCM_STATE_RUNNING ||
dmix->state == SND_PCM_STATE_DRAINING)
@ -970,7 +970,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
assert(pcmp);
if (stream != SND_PCM_STREAM_PLAYBACK) {
SNDERR("The dmix plugin supports only playback stream");
snd_error(PCM, "The dmix plugin supports only playback stream");
return -EINVAL;
}
@ -997,19 +997,19 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
ret = snd_pcm_open_slave(&spcm, root, sconf, stream,
mode | SND_PCM_NONBLOCK, NULL);
if (ret < 0) {
SNDERR("unable to open slave");
snd_error(PCM, "unable to open slave");
goto _err;
}
if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) {
SNDERR("dmix plugin can be only connected to hw plugin");
snd_error(PCM, "dmix plugin can be only connected to hw plugin");
ret = -EINVAL;
goto _err;
}
ret = snd_pcm_direct_initialize_slave(dmix, spcm, params);
if (ret < 0) {
SNDERR("unable to initialize slave");
snd_error(PCM, "unable to initialize slave");
goto _err;
}
@ -1017,10 +1017,10 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
if (dmix->shmptr->use_server) {
dmix->server_free = dmix_server_free;
ret = snd_pcm_direct_server_create(dmix);
if (ret < 0) {
SNDERR("unable to create server");
snd_error(PCM, "unable to create server");
goto _err;
}
}
@ -1032,10 +1032,10 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT);
ret = snd_pcm_direct_client_connect(dmix);
if (ret < 0) {
SNDERR("unable to connect client");
snd_error(PCM, "unable to connect client");
goto _err_nosem;
}
snd_pcm_direct_semaphore_down(dmix, DIRECT_IPC_SEM_CLIENT);
ret = snd_pcm_direct_open_secondary_client(&spcm, dmix, "dmix_client");
if (ret < 0)
@ -1054,18 +1054,18 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
first_instance = 1;
goto retry;
}
SNDERR("unable to open slave");
snd_error(PCM, "unable to open slave");
goto _err;
}
if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) {
SNDERR("dmix plugin can be only connected to hw plugin");
snd_error(PCM, "dmix plugin can be only connected to hw plugin");
ret = -EINVAL;
goto _err;
}
ret = snd_pcm_direct_initialize_secondary_slave(dmix, spcm, params);
if (ret < 0) {
SNDERR("unable to initialize slave");
snd_error(PCM, "unable to initialize slave");
goto _err;
}
}
@ -1075,25 +1075,25 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
ret = shm_sum_create_or_connect(dmix);
if (ret < 0) {
SNDERR("unable to initialize sum ring buffer");
snd_error(PCM, "unable to initialize sum ring buffer");
goto _err;
}
ret = snd_pcm_direct_initialize_poll_fd(dmix);
if (ret < 0) {
SNDERR("unable to initialize poll_fd");
snd_error(PCM, "unable to initialize poll_fd");
goto _err;
}
mix_select_callbacks(dmix);
pcm->poll_fd = dmix->poll_fd;
pcm->poll_events = POLLIN; /* it's different than other plugins */
pcm->tstamp_type = spcm->tstamp_type;
pcm->mmap_rw = 1;
snd_pcm_set_hw_ptr(pcm, &dmix->hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &dmix->appl_ptr, -1, 0);
if (dmix->channels == UINT_MAX)
dmix->channels = dmix->shmptr->s.channels;
@ -1101,7 +1101,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
*pcmp = pcm;
return 0;
_err:
if (dmix->timer)
snd_timer_close(dmix->timer);
@ -1317,7 +1317,7 @@ int _snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
if (err < 0)
return err;
/* set a reasonable default */
/* set a reasonable default */
if (psize == -1 && params.period_time == -1)
params.period_time = 125000; /* 0.125 seconds */
@ -1325,7 +1325,7 @@ int _snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
params.format = SND_PCM_FORMAT_UNKNOWN;
else if (!(dmix_supported_format & (1ULL << params.format))) {
/* sorry, limited features */
SNDERR("Unsupported format");
snd_error(PCM, "Unsupported format");
snd_config_delete(sconf);
return -EINVAL;
}

View file

@ -289,12 +289,12 @@ static void generic_mix_areas_16_swap(unsigned int size,
}
static void generic_remix_areas_16_swap(unsigned int size,
volatile signed short *dst,
signed short *src,
volatile signed int *sum,
size_t dst_step,
size_t src_step,
size_t sum_step)
volatile signed short *dst,
signed short *src,
volatile signed int *sum,
size_t dst_step,
size_t src_step,
size_t sum_step)
{
register signed int sample;
@ -354,12 +354,12 @@ static void generic_mix_areas_32_swap(unsigned int size,
}
static void generic_remix_areas_32_swap(unsigned int size,
volatile signed int *dst,
signed int *src,
volatile signed int *sum,
size_t dst_step,
size_t src_step,
size_t sum_step)
volatile signed int *dst,
signed int *src,
volatile signed int *sum,
size_t dst_step,
size_t src_step,
size_t sum_step)
{
register signed int sample;

View file

@ -55,7 +55,7 @@
#undef LOCK_PREFIX
#undef XADD
#undef XSUB
#define MIX_AREAS_16 remix_areas_16_smp
#define MIX_AREAS_16_MMX remix_areas_16_smp_mmx
#define MIX_AREAS_32 remix_areas_32_smp
@ -73,7 +73,7 @@
#undef LOCK_PREFIX
#undef XADD
#undef XSUB
#define i386_dmix_supported_format \
((1ULL << SND_PCM_FORMAT_S16_LE) |\
(1ULL << SND_PCM_FORMAT_S32_LE) |\
@ -100,7 +100,7 @@ static void mix_select_callbacks(snd_pcm_direct_t *dmix)
if (!smp) {
FILE *in;
char line[255];
/* try to determine the capabilities of the CPU */
in = fopen("/proc/cpuinfo", "r");
if (in) {
@ -117,7 +117,7 @@ static void mix_select_callbacks(snd_pcm_direct_t *dmix)
fclose(in);
}
}
if (mmx) {
dmix->u.dmix.mix_areas_16 = smp > 1 ? mix_areas_16_smp_mmx : mix_areas_16_mmx;
dmix->u.dmix.remix_areas_16 = smp > 1 ? remix_areas_16_smp_mmx : remix_areas_16_mmx;

View file

@ -244,7 +244,7 @@ static void MIX_AREAS_16_MMX(unsigned int size,
"\tdecl %[size]\n"
"\tjnz 1b\n"
"\temms\n"
"5:"
"5:"
#ifdef BOUNDED_EBX
"\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */
#endif

View file

@ -43,7 +43,7 @@
#undef LOCK_PREFIX
#undef XADD
#undef XSUB
#define MIX_AREAS_16 remix_areas_16_smp
#define MIX_AREAS_32 remix_areas_32_smp
#define MIX_AREAS_24 remix_areas_24_smp
@ -57,7 +57,7 @@
#undef LOCK_PREFIX
#undef XADD
#undef XSUB
#define x86_64_dmix_supported_format \
((1ULL << SND_PCM_FORMAT_S16_LE) |\
(1ULL << SND_PCM_FORMAT_S32_LE) |\
@ -69,7 +69,7 @@
static void mix_select_callbacks(snd_pcm_direct_t *dmix)
{
static int smp = 0;
if (!dmix->direct_memory_access) {
generic_mix_select_callbacks(dmix);
return;

View file

@ -137,7 +137,7 @@ static void MIX_AREAS_16(unsigned int size,
#ifdef BOUNDED_RBX
, [old_rbx] "=m" (old_rbx)
#endif
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
[dst_step] "im" (dst_step), [src_step] "im" (src_step),
[sum_step] "im" (sum_step)
: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
@ -279,7 +279,7 @@ static void MIX_AREAS_32(unsigned int size,
#ifdef BOUNDED_RBX
, [old_rbx] "=m" (old_rbx)
#endif
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
[dst_step] "im" (dst_step), [src_step] "im" (src_step),
[sum_step] "im" (sum_step)
: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
@ -403,7 +403,7 @@ static void MIX_AREAS_24(unsigned int size,
#ifdef BOUNDED_RBX
, [old_rbx] "=m" (old_rbx)
#endif
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
[dst_step] "im" (dst_step), [src_step] "im" (src_step),
[sum_step] "im" (sum_step)
: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"

View file

@ -25,7 +25,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
@ -111,7 +111,7 @@ static void snd_pcm_dshare_sync_area(snd_pcm_t *pcm)
snd_pcm_uframes_t slave_hw_ptr, slave_appl_ptr, slave_size;
snd_pcm_uframes_t appl_ptr, size;
const snd_pcm_channel_area_t *src_areas, *dst_areas;
/* calculate the size to transfer */
size = pcm_frame_diff(dshare->appl_ptr, dshare->last_appl_ptr, pcm->boundary);
if (! size)
@ -259,7 +259,7 @@ static int snd_pcm_dshare_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
{
snd_pcm_direct_t *dshare = pcm->private_data;
int err;
switch (dshare->state) {
case SNDRV_PCM_STATE_DRAINING:
case SNDRV_PCM_STATE_RUNNING:
@ -328,7 +328,7 @@ static int snd_pcm_dshare_start(snd_pcm_t *pcm)
snd_pcm_direct_t *dshare = pcm->private_data;
snd_pcm_sframes_t avail;
int err;
if (dshare->state != SND_PCM_STATE_PREPARED)
return -EBADFD;
avail = snd_pcm_mmap_playback_hw_avail(pcm);
@ -484,10 +484,10 @@ static int snd_pcm_dshare_close(snd_pcm_t *pcm)
snd_pcm_direct_semaphore_down(dshare, DIRECT_IPC_SEM_CLIENT);
dshare->shmptr->u.dshare.chn_mask &= ~dshare->u.dshare.chn_mask;
snd_pcm_close(dshare->spcm);
if (dshare->server)
snd_pcm_direct_server_discard(dshare);
if (dshare->client)
snd_pcm_direct_client_discard(dshare);
if (dshare->server)
snd_pcm_direct_server_discard(dshare);
if (dshare->client)
snd_pcm_direct_client_discard(dshare);
if (snd_pcm_direct_shm_discard(dshare)) {
if (snd_pcm_direct_semaphore_discard(dshare))
snd_pcm_direct_semaphore_final(dshare, DIRECT_IPC_SEM_CLIENT);
@ -537,7 +537,7 @@ static snd_pcm_sframes_t snd_pcm_dshare_avail_update(snd_pcm_t *pcm)
{
snd_pcm_direct_t *dshare = pcm->private_data;
int err;
if (dshare->state == SND_PCM_STATE_RUNNING ||
dshare->state == SND_PCM_STATE_DRAINING) {
if ((err = snd_pcm_dshare_sync_ptr(pcm)) < 0)
@ -556,7 +556,7 @@ static int snd_pcm_dshare_htimestamp(snd_pcm_t *pcm,
snd_pcm_direct_t *dshare = pcm->private_data;
snd_pcm_uframes_t avail1;
int ok = 0;
while (1) {
if (dshare->state == SND_PCM_STATE_RUNNING ||
dshare->state == SND_PCM_STATE_DRAINING)
@ -667,7 +667,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
assert(pcmp);
if (stream != SND_PCM_STREAM_PLAYBACK) {
SNDERR("The dshare plugin supports only playback stream");
snd_error(PCM, "The dshare plugin supports only playback stream");
return -EINVAL;
}
@ -698,27 +698,27 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
ret = snd_pcm_open_slave(&spcm, root, sconf, stream,
mode | SND_PCM_NONBLOCK, NULL);
if (ret < 0) {
SNDERR("unable to open slave");
snd_error(PCM, "unable to open slave");
goto _err;
}
if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) {
SNDERR("dshare plugin can be only connected to hw plugin");
snd_error(PCM, "dshare plugin can be only connected to hw plugin");
goto _err;
}
ret = snd_pcm_direct_initialize_slave(dshare, spcm, params);
if (ret < 0) {
SNDERR("unable to initialize slave");
snd_error(PCM, "unable to initialize slave");
goto _err;
}
dshare->spcm = spcm;
if (dshare->shmptr->use_server) {
ret = snd_pcm_direct_server_create(dshare);
if (ret < 0) {
SNDERR("unable to create server");
snd_error(PCM, "unable to create server");
goto _err;
}
}
@ -730,10 +730,10 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_direct_semaphore_up(dshare, DIRECT_IPC_SEM_CLIENT);
ret = snd_pcm_direct_client_connect(dshare);
if (ret < 0) {
SNDERR("unable to connect client");
snd_error(PCM, "unable to connect client");
goto _err_nosem;
}
snd_pcm_direct_semaphore_down(dshare, DIRECT_IPC_SEM_CLIENT);
ret = snd_pcm_direct_open_secondary_client(&spcm, dshare, "dshare_client");
if (ret < 0)
@ -753,18 +753,18 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
first_instance = 1;
goto retry;
}
SNDERR("unable to open slave");
snd_error(PCM, "unable to open slave");
goto _err;
}
if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) {
SNDERR("dshare plugin can be only connected to hw plugin");
snd_error(PCM, "dshare plugin can be only connected to hw plugin");
ret = -EINVAL;
goto _err;
}
ret = snd_pcm_direct_initialize_secondary_slave(dshare, spcm, params);
if (ret < 0) {
SNDERR("unable to initialize slave");
snd_error(PCM, "unable to initialize slave");
goto _err;
}
}
@ -778,16 +778,16 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
dshare->u.dshare.chn_mask |= (1ULL << dchn);
}
if (dshare->shmptr->u.dshare.chn_mask & dshare->u.dshare.chn_mask) {
SNDERR("destination channel specified in bindings is already used");
snd_error(PCM, "destination channel specified in bindings is already used");
dshare->u.dshare.chn_mask = 0;
ret = -EINVAL;
goto _err;
}
dshare->shmptr->u.dshare.chn_mask |= dshare->u.dshare.chn_mask;
ret = snd_pcm_direct_initialize_poll_fd(dshare);
if (ret < 0) {
SNDERR("unable to initialize poll_fd");
snd_error(PCM, "unable to initialize poll_fd");
goto _err;
}
@ -797,12 +797,12 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
pcm->mmap_rw = 1;
snd_pcm_set_hw_ptr(pcm, &dshare->hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &dshare->appl_ptr, -1, 0);
snd_pcm_direct_semaphore_up(dshare, DIRECT_IPC_SEM_CLIENT);
*pcmp = pcm;
return 0;
_err:
if (dshare->shmptr != (void *) -1)
dshare->shmptr->u.dshare.chn_mask &= ~dshare->u.dshare.chn_mask;

View file

@ -25,7 +25,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
@ -106,7 +106,7 @@ static void snd_pcm_dsnoop_sync_area(snd_pcm_t *pcm, snd_pcm_uframes_t slave_hw_
snd_pcm_uframes_t hw_ptr = dsnoop->hw_ptr;
snd_pcm_uframes_t transfer;
const snd_pcm_channel_area_t *src_areas, *dst_areas;
/* add sample areas here */
dst_areas = snd_pcm_mmap_areas(pcm);
src_areas = snd_pcm_mmap_areas(dsnoop->spcm);
@ -119,7 +119,7 @@ static void snd_pcm_dsnoop_sync_area(snd_pcm_t *pcm, snd_pcm_uframes_t slave_hw_
size -= transfer;
snoop_areas(dsnoop, src_areas, dst_areas, slave_hw_ptr, hw_ptr, transfer);
slave_hw_ptr += transfer;
slave_hw_ptr %= dsnoop->slave_buffer_size;
slave_hw_ptr %= dsnoop->slave_buffer_size;
hw_ptr += transfer;
hw_ptr %= pcm->buffer_size;
}
@ -206,7 +206,7 @@ static int snd_pcm_dsnoop_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
{
snd_pcm_direct_t *dsnoop = pcm->private_data;
int err;
switch(dsnoop->state) {
case SNDRV_PCM_STATE_DRAINING:
case SNDRV_PCM_STATE_RUNNING:
@ -373,10 +373,10 @@ static int snd_pcm_dsnoop_close(snd_pcm_t *pcm)
snd_timer_close(dsnoop->timer);
snd_pcm_direct_semaphore_down(dsnoop, DIRECT_IPC_SEM_CLIENT);
snd_pcm_close(dsnoop->spcm);
if (dsnoop->server)
snd_pcm_direct_server_discard(dsnoop);
if (dsnoop->client)
snd_pcm_direct_client_discard(dsnoop);
if (dsnoop->server)
snd_pcm_direct_server_discard(dsnoop);
if (dsnoop->client)
snd_pcm_direct_client_discard(dsnoop);
if (snd_pcm_direct_shm_discard(dsnoop)) {
if (snd_pcm_direct_semaphore_discard(dsnoop))
snd_pcm_direct_semaphore_final(dsnoop, DIRECT_IPC_SEM_CLIENT);
@ -414,7 +414,7 @@ static snd_pcm_sframes_t snd_pcm_dsnoop_avail_update(snd_pcm_t *pcm)
{
snd_pcm_direct_t *dsnoop = pcm->private_data;
int err;
if (dsnoop->state == SND_PCM_STATE_RUNNING) {
err = snd_pcm_dsnoop_sync_ptr(pcm);
if (err < 0)
@ -433,7 +433,7 @@ static int snd_pcm_dsnoop_htimestamp(snd_pcm_t *pcm,
snd_pcm_direct_t *dsnoop = pcm->private_data;
snd_pcm_uframes_t avail1;
int ok = 0;
while (1) {
if (dsnoop->state == SND_PCM_STATE_RUNNING ||
dsnoop->state == SND_PCM_STATE_DRAINING)
@ -538,7 +538,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
assert(pcmp);
if (stream != SND_PCM_STREAM_CAPTURE) {
SNDERR("The dsnoop plugin supports only capture stream");
snd_error(PCM, "The dsnoop plugin supports only capture stream");
return -EINVAL;
}
@ -564,27 +564,27 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
ret = snd_pcm_open_slave(&spcm, root, sconf, stream,
mode | SND_PCM_NONBLOCK, NULL);
if (ret < 0) {
SNDERR("unable to open slave");
snd_error(PCM, "unable to open slave");
goto _err;
}
if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) {
SNDERR("dsnoop plugin can be only connected to hw plugin");
snd_error(PCM, "dsnoop plugin can be only connected to hw plugin");
goto _err;
}
ret = snd_pcm_direct_initialize_slave(dsnoop, spcm, params);
if (ret < 0) {
SNDERR("unable to initialize slave");
snd_error(PCM, "unable to initialize slave");
goto _err;
}
dsnoop->spcm = spcm;
if (dsnoop->shmptr->use_server) {
ret = snd_pcm_direct_server_create(dsnoop);
if (ret < 0) {
SNDERR("unable to create server");
snd_error(PCM, "unable to create server");
goto _err;
}
}
@ -596,10 +596,10 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_direct_semaphore_up(dsnoop, DIRECT_IPC_SEM_CLIENT);
ret = snd_pcm_direct_client_connect(dsnoop);
if (ret < 0) {
SNDERR("unable to connect client");
snd_error(PCM, "unable to connect client");
goto _err_nosem;
}
snd_pcm_direct_semaphore_down(dsnoop, DIRECT_IPC_SEM_CLIENT);
ret = snd_pcm_direct_open_secondary_client(&spcm, dsnoop, "dsnoop_client");
@ -619,18 +619,18 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
first_instance = 1;
goto retry;
}
SNDERR("unable to open slave");
snd_error(PCM, "unable to open slave");
goto _err;
}
if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) {
SNDERR("dsnoop plugin can be only connected to hw plugin");
snd_error(PCM, "dsnoop plugin can be only connected to hw plugin");
ret = -EINVAL;
goto _err;
}
ret = snd_pcm_direct_initialize_secondary_slave(dsnoop, spcm, params);
if (ret < 0) {
SNDERR("unable to initialize slave");
snd_error(PCM, "unable to initialize slave");
goto _err;
}
}
@ -640,7 +640,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
ret = snd_pcm_direct_initialize_poll_fd(dsnoop);
if (ret < 0) {
SNDERR("unable to initialize poll_fd");
snd_error(PCM, "unable to initialize poll_fd");
goto _err;
}
@ -650,17 +650,17 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
pcm->mmap_rw = 1;
snd_pcm_set_hw_ptr(pcm, &dsnoop->hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &dsnoop->appl_ptr, -1, 0);
if (dsnoop->channels == UINT_MAX)
dsnoop->channels = dsnoop->shmptr->s.channels;
snd_pcm_direct_semaphore_up(dsnoop, DIRECT_IPC_SEM_CLIENT);
*pcmp = pcm;
return 0;
_err:
if (dsnoop->timer)
if (dsnoop->timer)
snd_timer_close(dsnoop->timer);
if (dsnoop->server)
snd_pcm_direct_server_discard(dsnoop);
@ -804,7 +804,7 @@ int _snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
if (err < 0)
return err;
/* set a reasonable default */
/* set a reasonable default */
if (psize == -1 && params.period_time == -1)
params.period_time = 125000; /* 0.125 seconds */

View file

@ -25,7 +25,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "pcm_local.h"
#include "pcm_plugin.h"
@ -77,8 +77,8 @@ pcm.name {
* changed in future.
*/
int _snd_pcm_empty_open(snd_pcm_t **pcmp, const char *name ATTRIBUTE_UNUSED,
snd_config_t *root, snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
snd_config_t *root, snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
snd_config_t *slave = NULL, *sconf;
snd_config_iterator_t i, next;
@ -95,11 +95,11 @@ int _snd_pcm_empty_open(snd_pcm_t **pcmp, const char *name ATTRIBUTE_UNUSED,
slave = n;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(PCM, "Unknown field %s", id);
return -EINVAL;
}
if (!slave) {
SNDERR("slave is not defined");
snd_error(PCM, "slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, 0);

View file

@ -25,7 +25,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "pcm_local.h"
#include "pcm_plugin.h"
#include "pcm_extplug.h"
@ -264,7 +264,7 @@ static int snd_pcm_extplug_hw_refine_schange(snd_pcm_t *pcm,
return _snd_pcm_hw_params_refine(sparams, links, params);
}
static int snd_pcm_extplug_hw_refine_cchange(snd_pcm_t *pcm,
snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
@ -511,7 +511,7 @@ usually you will call the external plugin API function,
#snd_pcm_extplug_create() or #snd_pcm_ioplug_create(), depending
on the plugin type. The PCM handle must be filled *pcmp in return.
Then this function must return either a value 0 when succeeded, or a
negative value as the error code.
negative value as the error code.
Finally, add #SND_PCM_PLUGIN_SYMBOL() with the name of your
plugin as the argument at the end. This defines the proper versioned
@ -547,12 +547,12 @@ SND_PCM_PLUGIN_DEFINE_FUNC(myplug)
....
continue;
}
SNDERR("Unknown field %s", id);
snd_error(PCM, "Unknown field %s", id);
return -EINVAL;
}
if (! slave) {
SNDERR("No slave defined for myplug");
snd_error(PCM, "No slave defined for myplug");
return -EINVAL;
}
@ -596,7 +596,7 @@ Otherfields are optional and should be initialized with zero.
The constant #SND_PCM_EXTPLUG_VERSION must be passed to the version
field for the version check in alsa-lib. A non-NULL ASCII string
has to be passed to the name field. The callback field contains the
has to be passed to the name field. The callback field contains the
table of callback functions for this plugin (defined as
#snd_pcm_extplug_callback_t).
@ -611,7 +611,7 @@ The callback functions in #snd_pcm_extplug_callback_t define the real
behavior of the driver.
At least, transfer callback must be given. This callback is called
at each time certain size of data block is transfered to the slave
PCM. Other callbacks are optional.
PCM. Other callbacks are optional.
The close callback is called when the PCM is closed. If the plugin
allocates private resources, this is the place to release them
@ -640,7 +640,7 @@ either #snd_pcm_extplug_set_slave_param_minmax() and
as former functions.
To clear the parameter constraints, call #snd_pcm_extplug_params_reset()
function.
function.
When using snd_pcm_extplug_set_param_*() or snd_pcm_extplug_set_slave_param_*()
for any parameter. This parameter is no longer linked between the client and
@ -690,8 +690,9 @@ int snd_pcm_extplug_create(snd_pcm_extplug_t *extplug, const char *name,
/* We support 1.0.0 to current */
if (extplug->version < 0x010000 ||
extplug->version > SND_PCM_EXTPLUG_VERSION) {
SNDERR("extplug: Plugin version mismatch: 0x%x",
extplug->version);
snd_error(PCM, "extplug: Plugin version mismatch: 0x%x",
extplug->version);
return -ENXIO;
}
@ -781,7 +782,7 @@ int snd_pcm_extplug_set_slave_param_list(snd_pcm_extplug_t *extplug, int type, u
{
extplug_priv_t *ext = extplug->pcm->private_data;
if (type < 0 || type >= SND_PCM_EXTPLUG_HW_PARAMS) {
SNDERR("EXTPLUG: invalid parameter type %d", type);
snd_error(PCM, "EXTPLUG: invalid parameter type %d", type);
return -EINVAL;
}
return snd_ext_parm_set_list(&ext->sparams[type], num_list, list);
@ -803,11 +804,11 @@ int snd_pcm_extplug_set_slave_param_minmax(snd_pcm_extplug_t *extplug, int type,
{
extplug_priv_t *ext = extplug->pcm->private_data;
if (type < 0 || type >= SND_PCM_EXTPLUG_HW_PARAMS) {
SNDERR("EXTPLUG: invalid parameter type %d", type);
snd_error(PCM, "EXTPLUG: invalid parameter type %d", type);
return -EINVAL;
}
if (is_mask_type(type)) {
SNDERR("EXTPLUG: invalid parameter type %d", type);
snd_error(PCM, "EXTPLUG: invalid parameter type %d", type);
return -EINVAL;
}
return snd_ext_parm_set_minmax(&ext->sparams[type], min, max);
@ -829,7 +830,7 @@ int snd_pcm_extplug_set_param_list(snd_pcm_extplug_t *extplug, int type, unsigne
{
extplug_priv_t *ext = extplug->pcm->private_data;
if (type < 0 || type >= SND_PCM_EXTPLUG_HW_PARAMS) {
SNDERR("EXTPLUG: invalid parameter type %d", type);
snd_error(PCM, "EXTPLUG: invalid parameter type %d", type);
return -EINVAL;
}
return snd_ext_parm_set_list(&ext->params[type], num_list, list);
@ -851,11 +852,11 @@ int snd_pcm_extplug_set_param_minmax(snd_pcm_extplug_t *extplug, int type, unsig
{
extplug_priv_t *ext = extplug->pcm->private_data;
if (type < 0 || type >= SND_PCM_EXTPLUG_HW_PARAMS) {
SNDERR("EXTPLUG: invalid parameter type %d", type);
snd_error(PCM, "EXTPLUG: invalid parameter type %d", type);
return -EINVAL;
}
if (is_mask_type(type)) {
SNDERR("EXTPLUG: invalid parameter type %d", type);
snd_error(PCM, "EXTPLUG: invalid parameter type %d", type);
return -EINVAL;
}
return snd_ext_parm_set_minmax(&ext->params[type], min, max);
@ -877,7 +878,7 @@ int snd_pcm_extplug_set_param_link(snd_pcm_extplug_t *extplug, int type,
extplug_priv_t *ext = extplug->pcm->private_data;
if (type < 0 || type >= SND_PCM_EXTPLUG_HW_PARAMS) {
SNDERR("EXTPLUG: invalid parameter type %d", type);
snd_error(PCM, "EXTPLUG: invalid parameter type %d", type);
return -EINVAL;
}
ext->params[type].keep_link = keep_link ? 1 : 0;

View file

@ -25,7 +25,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "pcm_local.h"
#include "pcm_plugin.h"
#include "bswap.h"
@ -239,8 +239,9 @@ static int snd_pcm_file_open_output_file(snd_pcm_file_t *file)
/* clearing */
pipe = popen(file->final_fname + 1, "w");
if (!pipe) {
SYSERR("running %s for writing failed",
file->final_fname);
snd_errornum(PCM, "running %s for writing failed",
file->final_fname);
return -errno;
}
fd = fileno(pipe);
@ -274,8 +275,9 @@ static int snd_pcm_file_open_output_file(snd_pcm_file_t *file)
}
}
if (fd < 0) {
SYSERR("open %s for writing failed",
file->final_fname);
snd_errornum(PCM, "open %s for writing failed",
file->final_fname);
free(tmpfname);
return -errno;
}
@ -303,7 +305,7 @@ static int snd_pcm_file_areas_read_infile(snd_pcm_t *pcm,
return -ENOMEM;
if (file->rbuf_size < frames) {
SYSERR("requested more frames than pcm buffer");
snd_errornum(PCM, "requested more frames than pcm buffer");
return -ENOMEM;
}
@ -312,7 +314,7 @@ static int snd_pcm_file_areas_read_infile(snd_pcm_t *pcm,
return bytes;
bytes = read(file->ifd, file->rbuf, bytes);
if (bytes < 0) {
SYSERR("read from file failed, error: %d", bytes);
snd_errornum(PCM, "read from file failed, error: %d", bytes);
return bytes;
}
@ -351,7 +353,7 @@ static int write_wav_header(snd_pcm_t *pcm)
'd', 'a', 't', 'a',
0, 0, 0, 0
};
setup_wav_header(pcm, &file->wav_header);
res = safe_write(file->fd, header, sizeof(header));
@ -376,9 +378,9 @@ write_error:
* be used to signal XRUN on playback device
*/
if (res < 0)
SYSERR("%s write header failed, file data may be corrupt", file->fname);
snd_errornum(PCM, "%s write header failed, file data may be corrupt", file->fname);
else
SNDERR("%s write header incomplete, file data may be corrupt", file->fname);
snd_error(PCM, "%s write header incomplete, file data may be corrupt", file->fname);
memset(&file->wav_header, 0, sizeof(struct wav_fmt));
@ -440,7 +442,7 @@ static int snd_pcm_file_write_bytes(snd_pcm_t *pcm, size_t bytes)
if (err < 0) {
file->wbuf_used_bytes = 0;
file->file_ptr_bytes = 0;
SYSERR("%s write failed, file data may be corrupt", file->fname);
snd_errornum(PCM, "%s write failed, file data may be corrupt", file->fname);
return err;
}
bytes -= err;
@ -470,7 +472,7 @@ static int snd_pcm_file_add_frames(snd_pcm_t *pcm,
n = cont;
if (n > avail)
n = avail;
snd_pcm_areas_copy(file->wbuf_areas, file->appl_ptr,
snd_pcm_areas_copy(file->wbuf_areas, file->appl_ptr,
areas, offset,
pcm->channels, n, pcm->format);
frames -= n;
@ -562,7 +564,7 @@ static snd_pcm_sframes_t snd_pcm_file_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t f
snd_pcm_file_t *file = pcm->private_data;
snd_pcm_sframes_t err;
snd_pcm_uframes_t n;
n = snd_pcm_frames_to_bytes(pcm, frames);
if (n > file->wbuf_used_bytes)
frames = snd_pcm_bytes_to_frames(pcm, file->wbuf_used_bytes);
@ -590,7 +592,7 @@ static snd_pcm_sframes_t snd_pcm_file_forward(snd_pcm_t *pcm, snd_pcm_uframes_t
snd_pcm_file_t *file = pcm->private_data;
snd_pcm_sframes_t err;
snd_pcm_uframes_t n;
n = snd_pcm_frames_to_bytes(pcm, frames);
if (file->wbuf_used_bytes + n > file->wbuf_size_bytes)
frames = snd_pcm_bytes_to_frames(pcm, file->wbuf_size_bytes - file->wbuf_used_bytes);
@ -688,7 +690,7 @@ static snd_pcm_sframes_t snd_pcm_file_readn(snd_pcm_t *pcm, void **bufs, snd_pcm
}
static snd_pcm_sframes_t snd_pcm_file_mmap_commit(snd_pcm_t *pcm,
snd_pcm_uframes_t offset,
snd_pcm_uframes_t offset,
snd_pcm_uframes_t size)
{
snd_pcm_file_t *file = pcm->private_data;
@ -791,7 +793,7 @@ static int snd_pcm_file_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
if (file->fd < 0) {
err = snd_pcm_file_open_output_file(file);
if (err < 0) {
SYSERR("failed opening output file %s", file->fname);
snd_errornum(PCM, "failed opening output file %s", file->fname);
return err;
}
}
@ -914,7 +916,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
else if (!strcmp(fmt, "wav"))
format = SND_PCM_FILE_FORMAT_WAV;
else {
SNDERR("file format %s is unknown", fmt);
snd_error(PCM, "file format %s is unknown", fmt);
return -EINVAL;
}
file = calloc(1, sizeof(snd_pcm_file_t));
@ -932,7 +934,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
if (ifname && (stream == SND_PCM_STREAM_CAPTURE)) {
ifd = open(ifname, O_RDONLY); /* TODO: mind blocking mode */
if (ifd < 0) {
SYSERR("open %s for reading failed", ifname);
snd_errornum(PCM, "open %s for reading failed", ifname);
free(file->fname);
free(file);
return -errno;
@ -980,14 +982,14 @@ to a command, and optionally uses an existing file as an input data source
\code
pcm.name {
type file # File PCM
slave STR # Slave name
# or
slave { # Slave definition
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
}
type file # File PCM
slave STR # Slave name
# or
slave { # Slave definition
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
}
file STR # Output filename (or shell command the stream
# will be piped to if STR starts with the pipe
# char).
@ -1032,7 +1034,7 @@ pcm.name {
* changed in future.
*/
int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *root, snd_config_t *conf,
snd_config_t *root, snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
snd_config_iterator_t i, next;
@ -1057,7 +1059,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
if (strcmp(id, "format") == 0) {
err = snd_config_get_string(n, &format);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
return -EINVAL;
}
continue;
@ -1067,7 +1069,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
if (err < 0) {
err = snd_config_get_integer(n, &fd);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
return -EINVAL;
}
}
@ -1078,7 +1080,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
if (err < 0) {
err = snd_config_get_integer(n, &ifd);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
return -EINVAL;
}
}
@ -1087,11 +1089,11 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
if (strcmp(id, "perm") == 0) {
err = snd_config_get_integer(n, &perm);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
return err;
}
if ((perm & ~0777) != 0) {
SNDERR("The field perm must be a valid file permission");
snd_error(PCM, "The field perm must be a valid file permission");
return -EINVAL;
}
continue;
@ -1103,7 +1105,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
trunc = err;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(PCM, "Unknown field %s", id);
return -EINVAL;
}
if (!format) {
@ -1112,13 +1114,13 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
if (snd_config_search(root, "defaults.pcm.file_format", &n) >= 0) {
err = snd_config_get_string(n, &format);
if (err < 0) {
SNDERR("Invalid file format");
snd_error(PCM, "Invalid file format");
return -EINVAL;
}
}
}
if (!slave) {
SNDERR("slave is not defined");
snd_error(PCM, "slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, 0);
@ -1126,7 +1128,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
return err;
if ((!fname || strlen(fname) == 0) && fd < 0) {
snd_config_delete(sconf);
SNDERR("file is not defined");
snd_error(PCM, "file is not defined");
return -EINVAL;
}
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode, conf);

View file

@ -7,7 +7,7 @@
*/
/*
* PCM - Common generic plugin code
* Copyright (c) 2004 by Jaroslav Kysela <perex@perex.cz>
* Copyright (c) 2004 by Jaroslav Kysela <perex@perex.cz>
*
*
* This library is free software; you can redistribute it and/or modify
@ -125,7 +125,7 @@ int snd_pcm_generic_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *info)
}
int snd_pcm_generic_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
{
{
snd_pcm_generic_t *generic = pcm->private_data;
return snd_pcm_status(generic->slave, status);
}
@ -256,7 +256,7 @@ snd_pcm_sframes_t snd_pcm_generic_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_ufr
return _snd_pcm_readn(generic->slave, bufs, size);
}
snd_pcm_sframes_t snd_pcm_generic_mmap_commit(snd_pcm_t *pcm,
snd_pcm_sframes_t snd_pcm_generic_mmap_commit(snd_pcm_t *pcm,
snd_pcm_uframes_t offset,
snd_pcm_uframes_t size)
{

View file

@ -18,11 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
typedef struct {
snd_pcm_t *slave;
int close_slave;
} snd_pcm_generic_t;
} snd_pcm_generic_t;
/* make local functions really local */
#define snd_pcm_generic_close \

View file

@ -26,7 +26,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "pcm_local.h"
#include "pcm_generic.h"
@ -283,9 +283,9 @@ pcm.NAME {
slave STR # Slave name
# or
slave { # Slave definition
pcm STR # Slave PCM name
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
pcm { } # Slave PCM definition
}
hooks {
ID STR # Hook name (see pcm_hook)
@ -350,7 +350,7 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_
void *h = NULL;
if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid hook definition");
snd_error(PCM, "Invalid hook definition");
return -EINVAL;
}
snd_config_for_each(i, next, conf) {
@ -368,27 +368,27 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_
args = n;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(PCM, "Unknown field %s", id);
return -EINVAL;
}
if (!type) {
SNDERR("type is not defined");
snd_error(PCM, "type is not defined");
return -EINVAL;
}
err = snd_config_get_id(type, &id);
if (err < 0) {
SNDERR("unable to get id");
snd_error(PCM, "unable to get id");
return err;
}
err = snd_config_get_string(type, &str);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
return err;
}
err = snd_config_search_definition(root, "pcm_hook_type", str, &type);
if (err >= 0) {
if (snd_config_get_type(type) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid type for PCM type %s definition", str);
snd_error(PCM, "Invalid type for PCM type %s definition", str);
err = -EINVAL;
goto _err;
}
@ -402,7 +402,7 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_
if (strcmp(id, "lib") == 0) {
err = snd_config_get_string(n, &lib);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
goto _err;
}
continue;
@ -410,12 +410,12 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_
if (strcmp(id, "install") == 0) {
err = snd_config_get_string(n, &install);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
goto _err;
}
continue;
}
SNDERR("Unknown field %s", id);
snd_error(PCM, "Unknown field %s", id);
err = -EINVAL;
goto _err;
}
@ -428,12 +428,14 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_
install_func = h ? snd_dlsym(h, install, SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION)) : NULL;
err = 0;
if (!h) {
SNDERR("Cannot open shared library %s (%s)",
lib ? lib : "[builtin]", errbuf);
snd_error(PCM, "Cannot open shared library %s (%s)",
lib ? lib : "[builtin]", errbuf);
err = -ENOENT;
} else if (!install_func) {
SNDERR("symbol %s is not defined inside %s", install,
lib ? lib : "[builtin]");
snd_error(PCM, "symbol %s is not defined inside %s", install,
lib ? lib : "[builtin]");
snd_dlclose(h);
err = -ENXIO;
}
@ -446,7 +448,7 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_
if (args && snd_config_get_string(args, &str) >= 0) {
err = snd_config_search_definition(root, "hook_args", str, &args);
if (err < 0)
SNDERR("unknown hook_args %s", str);
snd_error(PCM, "unknown hook_args %s", str);
else
err = install_func(pcm, args);
snd_config_delete(args);
@ -478,7 +480,7 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_
* changed in future.
*/
int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *root, snd_config_t *conf,
snd_config_t *root, snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
snd_config_iterator_t i, next;
@ -499,17 +501,17 @@ int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name,
}
if (strcmp(id, "hooks") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
return -EINVAL;
}
hooks = n;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(PCM, "Unknown field %s", id);
return -EINVAL;
}
if (!slave) {
SNDERR("slave is not defined");
snd_error(PCM, "slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, 0);
@ -532,7 +534,7 @@ int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name,
if (snd_config_get_string(n, &str) >= 0) {
err = snd_config_search_definition(root, "pcm_hook", str, &n);
if (err < 0) {
SNDERR("unknown pcm_hook %s", str);
snd_error(PCM, "unknown pcm_hook %s", str);
} else {
err = snd_pcm_hook_add_conf(rpcm, root, n);
snd_config_delete(n);
@ -681,13 +683,13 @@ int _snd_pcm_hook_ctl_elems_install(snd_pcm_t *pcm, snd_config_t *conf)
return err;
card = snd_pcm_info_get_card(&info);
if (card < 0) {
SNDERR("No card for this PCM");
snd_error(PCM, "No card for this PCM");
return -EINVAL;
}
sprintf(ctl_name, "hw:%d", card);
err = snd_ctl_open(&ctl, ctl_name, 0);
if (err < 0) {
SNDERR("Cannot open CTL %s", ctl_name);
snd_error(PCM, "Cannot open CTL %s", ctl_name);
return err;
}
err = snd_config_imake_pointer(&pcm_conf, "pcm_handle", pcm);

View file

@ -26,7 +26,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "pcm_local.h"
#include "../control/control_local.h"
#include "../timer/timer_local.h"
@ -145,7 +145,7 @@ static int sync_ptr1(snd_pcm_hw_t *hw, unsigned int flags)
hw->sync_ptr->flags = flags;
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_SYNC_PTR, hw->sync_ptr) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_SYNC_PTR failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_SYNC_PTR failed (%i)", err);
return err;
}
return 0;
@ -268,7 +268,7 @@ static int snd_pcm_hw_nonblock(snd_pcm_t *pcm, int nonblock)
if ((flags = fcntl(fd, F_GETFL)) < 0) {
err = -errno;
SYSMSG("F_GETFL failed (%i)", err);
snd_checknum(PCM, "F_GETFL failed (%i)", err);
return err;
}
if (nonblock)
@ -277,7 +277,7 @@ static int snd_pcm_hw_nonblock(snd_pcm_t *pcm, int nonblock)
flags &= ~O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags) < 0) {
err = -errno;
SYSMSG("F_SETFL for O_NONBLOCK failed (%i)", err);
snd_checknum(PCM, "F_SETFL for O_NONBLOCK failed (%i)", err);
return err;
}
return 0;
@ -291,7 +291,7 @@ static int snd_pcm_hw_async(snd_pcm_t *pcm, int sig, pid_t pid)
if ((flags = fcntl(fd, F_GETFL)) < 0) {
err = -errno;
SYSMSG("F_GETFL failed (%i)", err);
snd_checknum(PCM, "F_GETFL failed (%i)", err);
return err;
}
if (sig >= 0)
@ -300,19 +300,19 @@ static int snd_pcm_hw_async(snd_pcm_t *pcm, int sig, pid_t pid)
flags &= ~O_ASYNC;
if (fcntl(fd, F_SETFL, flags) < 0) {
err = -errno;
SYSMSG("F_SETFL for O_ASYNC failed (%i)", err);
snd_checknum(PCM, "F_SETFL for O_ASYNC failed (%i)", err);
return err;
}
if (sig < 0)
return 0;
if (fcntl(fd, F_SETSIG, (long)sig) < 0) {
err = -errno;
SYSMSG("F_SETSIG failed (%i)", err);
snd_checknum(PCM, "F_SETSIG failed (%i)", err);
return err;
}
if (fcntl(fd, F_SETOWN, (long)pid) < 0) {
err = -errno;
SYSMSG("F_SETOWN failed (%i)", err);
snd_checknum(PCM, "F_SETOWN failed (%i)", err);
return err;
}
return 0;
@ -324,7 +324,7 @@ static int snd_pcm_hw_info(snd_pcm_t *pcm, snd_pcm_info_t * info)
int fd = hw->fd, err;
if (ioctl(fd, SNDRV_PCM_IOCTL_INFO, info) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_INFO failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_INFO failed (%i)", err);
return err;
}
/* may be configurable (optional) */
@ -375,12 +375,14 @@ static int snd_pcm_hw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
if (pcm->tstamp_type != SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY)
params->info |= SND_PCM_INFO_MONOTONIC;
}
return 0;
}
#ifndef DOC_HIDDEN
#define hw_param_mask(params,var) \
&((params)->masks[(var) - SND_PCM_HW_PARAM_FIRST_MASK])
#endif
static int hw_params_call(snd_pcm_hw_t *pcm_hw, snd_pcm_hw_params_t *params)
{
@ -409,7 +411,7 @@ static int snd_pcm_hw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
int err;
if (hw_params_call(hw, params) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_HW_PARAMS failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_HW_PARAMS failed (%i)", err);
return err;
}
params->info &= ~0xf0000000;
@ -434,7 +436,7 @@ static int snd_pcm_hw_change_timer(snd_pcm_t *pcm, int enable)
snd_timer_params_t params = {0};
unsigned int suspend, resume;
int err;
if (enable) {
err = snd_timer_hw_open(&hw->period_timer,
"hw-pcm-period-event",
@ -456,7 +458,7 @@ static int snd_pcm_hw_change_timer(snd_pcm_t *pcm, int enable)
return -EINVAL;
}
hw->period_timer_pfd.events = POLLIN;
hw->period_timer_pfd.revents = 0;
hw->period_timer_pfd.revents = 0;
snd_timer_poll_descriptors(hw->period_timer,
&hw->period_timer_pfd, 1);
hw->period_timer_need_poll = 0;
@ -473,7 +475,7 @@ static int snd_pcm_hw_change_timer(snd_pcm_t *pcm, int enable)
* In older versions, check via poll before read() is
* needed because of the confliction between
* TIMER_START and FIONBIO ioctls.
*/
*/
if (ver < SNDRV_PROTOCOL_VERSION(2, 0, 4))
hw->period_timer_need_poll = 1;
/*
@ -515,7 +517,7 @@ static int snd_pcm_hw_hw_free(snd_pcm_t *pcm)
snd_pcm_hw_change_timer(pcm, 0);
if (ioctl(fd, SNDRV_PCM_IOCTL_HW_FREE) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_HW_FREE failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_HW_FREE failed (%i)", err);
return err;
}
return 0;
@ -541,19 +543,19 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
}
if (params->tstamp_type == SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW &&
hw->version < SNDRV_PROTOCOL_VERSION(2, 0, 12)) {
SYSMSG("Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW");
snd_checknum(PCM, "Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW");
err = -EINVAL;
goto out;
}
if (params->tstamp_type == SND_PCM_TSTAMP_TYPE_MONOTONIC &&
hw->version < SNDRV_PROTOCOL_VERSION(2, 0, 5)) {
SYSMSG("Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC");
snd_checknum(PCM, "Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC");
err = -EINVAL;
goto out;
}
if (ioctl(fd, SNDRV_PCM_IOCTL_SW_PARAMS, params) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err);
goto out;
}
hw->prepare_reset_sw_params = false;
@ -563,7 +565,7 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
SND_PCM_TSTAMP_TYPE_MONOTONIC;
if (ioctl(fd, SNDRV_PCM_IOCTL_TSTAMP, &on) < 0) {
err = -errno;
SNDMSG("TSTAMP failed");
snd_check(PCM, "TSTAMP failed");
goto out;
}
}
@ -589,7 +591,7 @@ static int snd_pcm_hw_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info
i.channel = info->channel;
if (ioctl(fd, SNDRV_PCM_IOCTL_CHANNEL_INFO, &i) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_CHANNEL_INFO failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_CHANNEL_INFO failed (%i)", err);
return err;
}
info->channel = i.channel;
@ -609,13 +611,13 @@ static int snd_pcm_hw_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
if (SNDRV_PROTOCOL_VERSION(2, 0, 13) > hw->version) {
if (ioctl(fd, SNDRV_PCM_IOCTL_STATUS, status) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_STATUS failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_STATUS failed (%i)", err);
return err;
}
} else {
if (ioctl(fd, SNDRV_PCM_IOCTL_STATUS_EXT, status) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_STATUS_EXT failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_STATUS_EXT failed (%i)", err);
return err;
}
}
@ -642,7 +644,7 @@ static int snd_pcm_hw_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
int fd = hw->fd, err;
if (ioctl(fd, SNDRV_PCM_IOCTL_DELAY, delayp) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_DELAY failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_DELAY failed (%i)", err);
return err;
}
return 0;
@ -660,7 +662,7 @@ static int snd_pcm_hw_hwsync(snd_pcm_t *pcm)
} else {
if (ioctl(fd, SNDRV_PCM_IOCTL_HWSYNC) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_HWSYNC failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_HWSYNC failed (%i)", err);
return err;
}
}
@ -690,14 +692,14 @@ static int snd_pcm_hw_prepare(snd_pcm_t *pcm)
snd_pcm_sw_params_current_no_lock(pcm, &sw_params);
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sw_params) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err);
return err;
}
hw->prepare_reset_sw_params = false;
}
if (ioctl(fd, SNDRV_PCM_IOCTL_PREPARE) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_PREPARE failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_PREPARE failed (%i)", err);
return err;
}
return query_status_and_control_data(hw);
@ -709,7 +711,7 @@ static int snd_pcm_hw_reset(snd_pcm_t *pcm)
int fd = hw->fd, err;
if (ioctl(fd, SNDRV_PCM_IOCTL_RESET) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_RESET failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_RESET failed (%i)", err);
return err;
}
return query_status_and_control_data(hw);
@ -726,10 +728,10 @@ static int snd_pcm_hw_start(snd_pcm_t *pcm)
issue_applptr(hw);
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_START) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_START failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_START failed (%i)", err);
#if 0
if (err == -EBADFD)
SNDERR("PCM state = %s", snd_pcm_state_name(snd_pcm_hw_state(pcm)));
snd_error(PCM, "PCM state = %s", snd_pcm_state_name(snd_pcm_hw_state(pcm)));
#endif
return err;
}
@ -742,7 +744,7 @@ static int snd_pcm_hw_drop(snd_pcm_t *pcm)
int err;
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_DROP) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_DROP failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_DROP failed (%i)", err);
return err;
} else {
}
@ -792,7 +794,7 @@ __manual_silence:
sw_params.silence_size = silence_size;
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sw_params) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err);
return err;
}
hw->prepare_reset_sw_params = true;
@ -800,7 +802,7 @@ __manual_silence:
__skip_silence:
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_DRAIN) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_DRAIN failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_DRAIN failed (%i)", err);
return err;
}
return 0;
@ -812,7 +814,7 @@ static int snd_pcm_hw_pause(snd_pcm_t *pcm, int enable)
int err;
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_PAUSE, enable) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_PAUSE failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_PAUSE failed (%i)", err);
return err;
}
return 0;
@ -829,7 +831,7 @@ static snd_pcm_sframes_t snd_pcm_hw_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t fra
int err;
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_REWIND, &frames) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_REWIND failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_REWIND failed (%i)", err);
return err;
}
err = query_status_and_control_data(hw);
@ -850,7 +852,7 @@ static snd_pcm_sframes_t snd_pcm_hw_forward(snd_pcm_t *pcm, snd_pcm_uframes_t fr
if (SNDRV_PROTOCOL_VERSION(2, 0, 4) <= hw->version) {
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_FORWARD, &frames) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_FORWARD failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_FORWARD failed (%i)", err);
return err;
}
err = query_status_and_control_data(hw);
@ -887,7 +889,7 @@ static int snd_pcm_hw_resume(snd_pcm_t *pcm)
int fd = hw->fd, err;
if (ioctl(fd, SNDRV_PCM_IOCTL_RESUME) < 0) {
err = -errno;
SYSMSG("SNDRV_PCM_IOCTL_RESUME failed (%i)", err);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_RESUME failed (%i)", err);
return err;
}
return 0;
@ -898,7 +900,7 @@ static int hw_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2)
snd_pcm_hw_t *hw1 = pcm1->private_data;
snd_pcm_hw_t *hw2 = pcm2->private_data;
if (ioctl(hw1->fd, SNDRV_PCM_IOCTL_LINK, hw2->fd) < 0) {
SYSMSG("SNDRV_PCM_IOCTL_LINK failed (%i)", -errno);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_LINK failed (%i)", -errno);
return -errno;
}
return 0;
@ -907,7 +909,7 @@ static int hw_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2)
static int snd_pcm_hw_link_slaves(snd_pcm_t *pcm, snd_pcm_t *master)
{
if (master->type != SND_PCM_TYPE_HW) {
SYSMSG("Invalid type for SNDRV_PCM_IOCTL_LINK (%i)", master->type);
snd_checknum(PCM, "Invalid type for SNDRV_PCM_IOCTL_LINK (%i)", master->type);
return -EINVAL;
}
return hw_link(master, pcm);
@ -928,7 +930,7 @@ static int snd_pcm_hw_unlink(snd_pcm_t *pcm)
snd_pcm_hw_t *hw = pcm->private_data;
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_UNLINK) < 0) {
SYSMSG("SNDRV_PCM_IOCTL_UNLINK failed (%i)", -errno);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_UNLINK failed (%i)", -errno);
return -errno;
}
return 0;
@ -1128,7 +1130,7 @@ static void unmap_status_data(snd_pcm_hw_t *hw)
if (!hw->mmap_status_fallbacked) {
if (munmap((void *)hw->mmap_status,
page_align(sizeof(*hw->mmap_status))) < 0)
SYSMSG("status munmap failed (%u)", errno);
snd_checknum(PCM, "status munmap failed (%u)", errno);
}
}
@ -1137,7 +1139,7 @@ static void unmap_control_data(snd_pcm_hw_t *hw)
if (!hw->mmap_control_fallbacked) {
if (munmap((void *)hw->mmap_control,
page_align(sizeof(*hw->mmap_control))) < 0)
SYSMSG("control munmap failed (%u)", errno);
snd_checknum(PCM, "control munmap failed (%u)", errno);
}
}
@ -1172,7 +1174,7 @@ static int snd_pcm_hw_close(snd_pcm_t *pcm)
int err = 0;
if (close(hw->fd)) {
err = -errno;
SYSMSG("close failed (%i)", err);
snd_checknum(PCM, "close failed (%i)", err);
}
unmap_status_and_control_data(hw);
@ -1295,7 +1297,7 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev,
ret = snd_ctl_hw_open(&ctl, NULL, card, 0);
if (ret < 0) {
SYSMSG("Cannot open the associated CTL");
snd_checknum(PCM, "Cannot open the associated CTL");
return NULL;
}
@ -1303,7 +1305,7 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev,
ret = snd_ctl_elem_tlv_read(ctl, &id, tlv, sizeof(tlv));
snd_ctl_close(ctl);
if (ret < 0) {
SYSMSG("Cannot read Channel Map TLV");
snd_checknum(PCM, "Cannot read Channel Map TLV");
return NULL;
}
@ -1317,7 +1319,7 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev,
type = tlv[SNDRV_CTL_TLVO_TYPE];
if (type != SND_CTL_TLVT_CONTAINER) {
if (!is_chmap_type(type)) {
SYSMSG("Invalid TLV type %d", type);
snd_checknum(PCM, "Invalid TLV type %d", type);
return NULL;
}
start = tlv;
@ -1330,7 +1332,7 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev,
nums = 0;
for (p = start; size > 0; ) {
if (!is_chmap_type(p[0])) {
SYSMSG("Invalid TLV type %d", p[0]);
snd_checknum(PCM, "Invalid TLV type %d", p[0]);
return NULL;
}
nums++;
@ -1421,8 +1423,9 @@ static snd_pcm_chmap_t *snd_pcm_hw_get_chmap(snd_pcm_t *pcm)
case SNDRV_PCM_STATE_SUSPENDED:
break;
default:
SYSMSG("Invalid PCM state for chmap_get: %s",
snd_pcm_state_name(FAST_PCM_STATE(hw)));
snd_checknum(PCM, "Invalid PCM state for chmap_get: %s",
snd_pcm_state_name(FAST_PCM_STATE(hw)));
return NULL;
}
map = malloc(pcm->channels * sizeof(map->pos[0]) + sizeof(*map));
@ -1432,7 +1435,7 @@ static snd_pcm_chmap_t *snd_pcm_hw_get_chmap(snd_pcm_t *pcm)
ret = snd_ctl_hw_open(&ctl, NULL, hw->card, 0);
if (ret < 0) {
free(map);
SYSMSG("Cannot open the associated CTL");
snd_checknum(PCM, "Cannot open the associated CTL");
chmap_caps_set_error(hw, CHMAP_CTL_GET);
return NULL;
}
@ -1442,7 +1445,7 @@ static snd_pcm_chmap_t *snd_pcm_hw_get_chmap(snd_pcm_t *pcm)
snd_ctl_close(ctl);
if (ret < 0) {
free(map);
SYSMSG("Cannot read Channel Map ctl");
snd_checknum(PCM, "Cannot read Channel Map ctl");
chmap_caps_set_error(hw, CHMAP_CTL_GET);
return NULL;
}
@ -1468,17 +1471,18 @@ static int snd_pcm_hw_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map)
return -ENXIO;
if (map->channels > 128) {
SYSMSG("Invalid number of channels %d", map->channels);
snd_checknum(PCM, "Invalid number of channels %d", map->channels);
return -EINVAL;
}
if (FAST_PCM_STATE(hw) != SNDRV_PCM_STATE_PREPARED) {
SYSMSG("Invalid PCM state for chmap_set: %s",
snd_pcm_state_name(FAST_PCM_STATE(hw)));
snd_checknum(PCM, "Invalid PCM state for chmap_set: %s",
snd_pcm_state_name(FAST_PCM_STATE(hw)));
return -EBADFD;
}
ret = snd_ctl_hw_open(&ctl, NULL, hw->card, 0);
if (ret < 0) {
SYSMSG("Cannot open the associated CTL");
snd_checknum(PCM, "Cannot open the associated CTL");
chmap_caps_set_error(hw, CHMAP_CTL_SET);
return ret;
}
@ -1496,7 +1500,7 @@ static int snd_pcm_hw_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map)
ret = -ENXIO;
}
if (ret < 0)
SYSMSG("Cannot write Channel Map ctl");
snd_checknum(PCM, "Cannot write Channel Map ctl");
return ret;
}
@ -1506,7 +1510,7 @@ static void snd_pcm_hw_dump(snd_pcm_t *pcm, snd_output_t *out)
char *name;
int err = snd_card_get_name(hw->card, &name);
if (err < 0) {
SNDERR("cannot get card name");
snd_error(PCM, "cannot get card name");
return;
}
snd_output_printf(out, "Hardware PCM card %d '%s' device %d subdevice %d\n",
@ -1627,7 +1631,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd,
memset(&info, 0, sizeof(info));
if (ioctl(fd, SNDRV_PCM_IOCTL_INFO, &info) < 0) {
ret = -errno;
SYSMSG("SNDRV_PCM_IOCTL_INFO failed (%i)", ret);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_INFO failed (%i)", ret);
close(fd);
return ret;
@ -1648,7 +1652,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd,
if (ioctl(fd, SNDRV_PCM_IOCTL_PVERSION, &ver) < 0) {
ret = -errno;
SYSMSG("SNDRV_PCM_IOCTL_PVERSION failed (%i)", ret);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_PVERSION failed (%i)", ret);
close(fd);
return ret;
}
@ -1660,7 +1664,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd,
unsigned int user_ver = SNDRV_PCM_VERSION;
if (ioctl(fd, SNDRV_PCM_IOCTL_USER_PVERSION, &user_ver) < 0) {
ret = -errno;
SNDMSG("USER_PVERSION failed");
snd_check(PCM, "USER_PVERSION failed");
return ret;
}
}
@ -1673,7 +1677,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd,
int on = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC;
if (ioctl(fd, SNDRV_PCM_IOCTL_TTSTAMP, &on) < 0) {
ret = -errno;
SNDMSG("TTSTAMP failed");
snd_check(PCM, "TTSTAMP failed");
return ret;
}
}
@ -1685,11 +1689,11 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd,
int on = 1;
if (ioctl(fd, SNDRV_PCM_IOCTL_TSTAMP, &on) < 0) {
ret = -errno;
SNDMSG("TSTAMP failed");
snd_check(PCM, "TSTAMP failed");
return ret;
}
}
hw = calloc(1, sizeof(snd_pcm_hw_t));
if (!hw) {
close(fd);
@ -1777,13 +1781,13 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
filefmt = SNDRV_FILE_PCM_STREAM_CAPTURE;
break;
default:
SNDERR("invalid stream %d", stream);
snd_error(PCM, "invalid stream %d", stream);
return -EINVAL;
}
sprintf(filename, filefmt, card, device);
__again:
if (attempt++ > 3) {
if (attempt++ > 3) {
ret = -EBUSY;
goto _err;
}
@ -1800,14 +1804,14 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
fd = snd_open_device(filename, fmode);
if (fd < 0) {
ret = -errno;
SYSMSG("open '%s' failed (%i)", filename, ret);
snd_checknum(PCM, "open '%s' failed (%i)", filename, ret);
goto _err;
}
if (subdevice >= 0) {
memset(&info, 0, sizeof(info));
if (ioctl(fd, SNDRV_PCM_IOCTL_INFO, &info) < 0) {
ret = -errno;
SYSMSG("SNDRV_PCM_IOCTL_INFO failed (%i)", ret);
snd_checknum(PCM, "SNDRV_PCM_IOCTL_INFO failed (%i)", ret);
goto _err;
}
if (info.subdevice != (unsigned int) subdevice) {
@ -1915,7 +1919,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
if (strcmp(id, "device") == 0) {
err = snd_config_get_integer(n, &device);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
goto fail;
}
continue;
@ -1923,7 +1927,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
if (strcmp(id, "subdevice") == 0) {
err = snd_config_get_integer(n, &subdevice);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
goto fail;
}
continue;
@ -1949,12 +1953,12 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *m;
err = snd_config_search(n, "0", &m);
if (err < 0) {
SNDERR("array expected for rate compound");
snd_error(PCM, "array expected for rate compound");
goto fail;
}
err = snd_config_get_integer(m, &val);
if (err < 0) {
SNDERR("Invalid type for rate.0");
snd_error(PCM, "Invalid type for rate.0");
goto fail;
}
min_rate = max_rate = val;
@ -1962,7 +1966,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
if (err >= 0) {
err = snd_config_get_integer(m, &val);
if (err < 0) {
SNDERR("Invalid type for rate.0");
snd_error(PCM, "Invalid type for rate.0");
goto fail;
}
max_rate = val;
@ -1970,7 +1974,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
} else {
err = snd_config_get_integer(n, &val);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
goto fail;
}
min_rate = max_rate = val;
@ -1981,7 +1985,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
long val;
err = snd_config_get_integer(n, &val);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
goto fail;
}
min_rate = val;
@ -1991,7 +1995,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
long val;
err = snd_config_get_integer(n, &val);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
goto fail;
}
max_rate = val;
@ -2000,7 +2004,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
if (strcmp(id, "format") == 0) {
err = snd_config_get_string(n, &str);
if (err < 0) {
SNDERR("invalid type for %s", id);
snd_error(PCM, "invalid type for %s", id);
goto fail;
}
format = snd_pcm_format_value(str);
@ -2010,7 +2014,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
long val;
err = snd_config_get_integer(n, &val);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
goto fail;
}
channels = val;
@ -2020,7 +2024,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_free_chmaps(chmap);
chmap = _snd_pcm_parse_config_chmaps(n);
if (!chmap) {
SNDERR("Invalid channel map for %s", id);
snd_error(PCM, "Invalid channel map for %s", id);
err = -EINVAL;
goto fail;
}
@ -2030,23 +2034,23 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
long val;
err = snd_config_get_integer(n, &val);
if (err < 0) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
goto fail;
}
drain_silence = val;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(PCM, "Unknown field %s", id);
err = -EINVAL;
goto fail;
}
if (card < 0) {
SNDERR("card is not defined");
snd_error(PCM, "card is not defined");
err = -EINVAL;
goto fail;
}
if ((min_rate < 0) || (max_rate < min_rate)) {
SNDERR("min_rate - max_rate configuration invalid");
snd_error(PCM, "min_rate - max_rate configuration invalid");
err = -EINVAL;
goto fail;
}
@ -2083,8 +2087,8 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
return 0;
fail:
snd_pcm_free_chmaps(chmap);
return err;
snd_pcm_free_chmaps(chmap);
return err;
}
#ifndef DOC_HIDDEN
@ -2150,7 +2154,7 @@ static int use_old_hw_params_ioctl(int fd, unsigned int cmd, snd_pcm_hw_params_t
struct sndrv_pcm_hw_params_old oparams;
unsigned int cmask = 0;
int res;
snd_pcm_hw_convert_to_old_params(&oparams, params, &cmask);
res = ioctl(fd, cmd, &oparams);
snd_pcm_hw_convert_from_old_params(params, &oparams);

View file

@ -25,7 +25,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "pcm_local.h"
#include "pcm_plugin.h"
#include "plugin_ops.h"
@ -295,7 +295,7 @@ static int snd_pcm_iec958_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd
return err;
return 0;
}
static int snd_pcm_iec958_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
@ -454,7 +454,7 @@ snd_pcm_iec958_write_areas(snd_pcm_t *pcm,
if (size > *slave_sizep)
size = *slave_sizep;
iec->func(iec, slave_areas, slave_offset,
areas, offset,
areas, offset,
pcm->channels, size);
*slave_sizep = size;
return size;
@ -472,7 +472,7 @@ snd_pcm_iec958_read_areas(snd_pcm_t *pcm,
snd_pcm_iec958_t *iec = pcm->private_data;
if (size > *slave_sizep)
size = *slave_sizep;
iec->func(iec, areas, offset,
iec->func(iec, areas, offset,
slave_areas, slave_offset,
pcm->channels, size);
*slave_sizep = size;
@ -489,7 +489,7 @@ static int snd_pcm_iec958_init(snd_pcm_t *pcm)
static void snd_pcm_iec958_dump(snd_pcm_t *pcm, snd_output_t *out)
{
snd_pcm_iec958_t *iec = pcm->private_data;
snd_output_printf(out, "IEC958 subframe conversion PCM (%s)\n",
snd_output_printf(out, "IEC958 subframe conversion PCM (%s)\n",
snd_pcm_format_name(iec->sformat));
if (pcm->setup) {
snd_output_printf(out, "Its setup is:\n");
@ -560,12 +560,12 @@ static const snd_pcm_ops_t snd_pcm_iec958_ops = {
* \warning Using of this function might be dangerous in the sense
* of compatibility reasons. The prototype might be freely
* changed in future.
*/
*/
int snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat,
snd_pcm_t *slave, int close_slave,
const unsigned char *status_bits,
const unsigned char *preamble_vals,
int hdmi_mode)
int hdmi_mode)
{
snd_pcm_t *pcm;
snd_pcm_iec958_t *iec;
@ -638,14 +638,14 @@ This plugin converts 32bit IEC958 subframe samples to linear, or linear to
\code
pcm.name {
type iec958 # IEC958 subframe conversion PCM
slave STR # Slave name
# or
slave { # Slave definition
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
}
type iec958 # IEC958 subframe conversion PCM
slave STR # Slave name
# or
slave { # Slave definition
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
}
[status status-bytes] # IEC958 status bits (given in byte array)
# IEC958 preamble bits definitions
# B/M/W or Z/X/Y, B = block start, M = even subframe, W = odd subframe
@ -684,7 +684,7 @@ by the HDMI HBR specification.
* changed in future.
*/
int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *root, snd_config_t *conf,
snd_config_t *root, snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
snd_config_iterator_t i, next;
@ -712,7 +712,7 @@ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name,
}
if (strcmp(id, "status") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
return -EINVAL;
}
status = n;
@ -720,7 +720,7 @@ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name,
}
if (strcmp(id, "preamble") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid type for %s", id);
snd_error(PCM, "Invalid type for %s", id);
return -EINVAL;
}
preamble = n;
@ -733,7 +733,7 @@ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name,
hdmi_mode = err;
continue;
}
SNDERR("Unknown field %s", id);
snd_error(PCM, "Unknown field %s", id);
return -EINVAL;
}
memset(status_bits, 0, sizeof(status_bits));
@ -744,12 +744,12 @@ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name,
long val;
snd_config_t *n = snd_config_iterator_entry(i);
if (snd_config_get_type(n) != SND_CONFIG_TYPE_INTEGER) {
SNDERR("invalid IEC958 status bits");
snd_error(PCM, "invalid IEC958 status bits");
return -EINVAL;
}
err = snd_config_get_integer(n, &val);
if (err < 0) {
SNDERR("invalid IEC958 status bits");
snd_error(PCM, "invalid IEC958 status bits");
return err;
}
status_bits[bytes] = val;
@ -775,19 +775,19 @@ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name,
else if (strcmp(id, "w") == 0 || strcmp(id, "y") == 0)
idx = PREAMBLE_Y;
else {
SNDERR("invalid IEC958 preamble type %s", id);
snd_error(PCM, "invalid IEC958 preamble type %s", id);
return -EINVAL;
}
err = snd_config_get_integer(n, &val);
if (err < 0) {
SNDERR("invalid IEC958 preamble value");
snd_error(PCM, "invalid IEC958 preamble value");
return err;
}
preamble_vals[idx] = val;
}
}
if (!slave) {
SNDERR("slave is not defined");
snd_error(PCM, "slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, 1,
@ -797,8 +797,8 @@ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name,
if (snd_pcm_format_linear(sformat) != 1 &&
sformat != SND_PCM_FORMAT_IEC958_SUBFRAME_LE &&
sformat != SND_PCM_FORMAT_IEC958_SUBFRAME_BE) {
snd_config_delete(sconf);
SNDERR("invalid slave format");
snd_config_delete(sconf);
snd_error(PCM, "invalid slave format");
return -EINVAL;
}
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode, conf);

View file

@ -25,7 +25,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "pcm_local.h"
#include "pcm_ioplug.h"
#include "pcm_ext_parm.h"
@ -482,7 +482,7 @@ static int snd_pcm_ioplug_start(snd_pcm_t *pcm)
{
ioplug_priv_t *io = pcm->private_data;
int err;
if (io->data->state != SND_PCM_STATE_PREPARED)
return -EBADFD;
@ -637,7 +637,7 @@ static snd_pcm_sframes_t ioplug_priv_transfer_areas(snd_pcm_t *pcm,
{
ioplug_priv_t *io = pcm->private_data;
snd_pcm_sframes_t result;
if (! size)
return 0;
if (io->data->callback->transfer)
@ -656,7 +656,7 @@ static snd_pcm_sframes_t snd_pcm_ioplug_writei(snd_pcm_t *pcm, const void *buffe
else {
snd_pcm_channel_area_t areas[pcm->channels];
snd_pcm_areas_from_buf(pcm, areas, (void*)buffer);
return snd_pcm_write_areas(pcm, areas, 0, size,
return snd_pcm_write_areas(pcm, areas, 0, size,
ioplug_priv_transfer_areas);
}
}
@ -982,7 +982,7 @@ Otherfields are optional and should be initialized with zero.
The constant #SND_PCM_IOPLUG_VERSION must be passed to the version
field for the version check in alsa-lib. A non-NULL ASCII string
has to be passed to the name field. The callback field contains the
has to be passed to the name field. The callback field contains the
table of callback functions for this plugin (defined as
#snd_pcm_ioplug_callback_t).
@ -1086,8 +1086,9 @@ int snd_pcm_ioplug_create(snd_pcm_ioplug_t *ioplug, const char *name,
/* We support 1.0.0 to current */
if (ioplug->version < 0x010000 ||
ioplug->version > SND_PCM_IOPLUG_VERSION) {
SNDERR("ioplug: Plugin version mismatch: 0x%x",
ioplug->version);
snd_error(PCM, "ioplug: Plugin version mismatch: 0x%x",
ioplug->version);
return -ENXIO;
}
@ -1156,7 +1157,7 @@ int snd_pcm_ioplug_set_param_list(snd_pcm_ioplug_t *ioplug, int type, unsigned i
{
ioplug_priv_t *io = ioplug->pcm->private_data;
if (type < 0 || type >= SND_PCM_IOPLUG_HW_PARAMS) {
SNDERR("IOPLUG: invalid parameter type %d", type);
snd_error(PCM, "IOPLUG: invalid parameter type %d", type);
return -EINVAL;
}
if (type == SND_PCM_IOPLUG_HW_PERIODS)
@ -1180,11 +1181,11 @@ int snd_pcm_ioplug_set_param_minmax(snd_pcm_ioplug_t *ioplug, int type, unsigned
{
ioplug_priv_t *io = ioplug->pcm->private_data;
if (type < 0 || type >= SND_PCM_IOPLUG_HW_PARAMS) {
SNDERR("IOPLUG: invalid parameter type %d", type);
snd_error(PCM, "IOPLUG: invalid parameter type %d", type);
return -EINVAL;
}
if (type == SND_PCM_IOPLUG_HW_ACCESS || type == SND_PCM_IOPLUG_HW_FORMAT) {
SNDERR("IOPLUG: invalid parameter type %d", type);
snd_error(PCM, "IOPLUG: invalid parameter type %d", type);
return -EINVAL;
}
if (type == SND_PCM_IOPLUG_HW_PERIODS)

Some files were not shown because too many files have changed in this diff Show more