fprintf(stderr, ##args); \
putc('\n', stderr); \
} while (0)
-#endif
+#endif
#define SYSERROR(string) ERROR(string ": %s", strerror(errno))
SYSERROR("socket failed");
return result;
}
-
+
unlink(filename);
addr->sun_family = AF_LOCAL;
SYSERROR("socket failed");
return result;
}
-
+
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
}
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);
}
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);
free(waiters);
return result;
}
-
+
static void usage(void)
{
#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)); \
* 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>
} 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)
/** \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;
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,
* \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);
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);
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
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
*/
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);
#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);
/** Mixer element handle */
typedef struct _snd_mixer_elem snd_mixer_elem_t;
-/**
+/**
* \brief Mixer callback function
* \param ctl Mixer handle
* \param mask event mask
unsigned int mask,
snd_mixer_elem_t *elem);
-/**
+/**
* \brief Mixer element callback function
* \param elem Mixer element
* \param mask event mask
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);
#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)
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);
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,
/** #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,
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);
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);
/** \} */
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);
/** \} */
/** 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 */
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 */
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 */
*/
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 */
* 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 */
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
*/
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
snd_config_t *capture_conf,
snd_pcm_stream_t stream, int mode);
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);
/** \} */
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 */
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 */
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 */
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 */
/**
* \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)
*
* 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) \
#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
*/
#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 */
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 */
#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 */
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 */
#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 */
/*
* 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
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;
*
* 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.
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 */
*
*/
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
*
* 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:
* - 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
* 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);
/**
{
struct bclass_base_ops *ops;
int err;
-
+
err = mixer_simple_basic_dlopen(class, &ops);
if (err < 0)
return 0;
{
struct bclass_base_ops *ops;
int err;
-
+
err = mixer_simple_basic_dlopen(class, &ops);
if (err < 0)
return 0;
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
}
}
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);
}
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);
}
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));
}
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;
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));
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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)
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");
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;
}
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");
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;
}
{"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},
{"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},
};
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 *
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");
pymixer_register(struct pymixer *pymixer, PyObject *args)
{
int err;
-
+
if (!PyArg_ParseTuple(args, ""))
return NULL;
err = snd_mixer_class_register(pymixer->class, pymixer->mixer);
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);
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;
}
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]);
};
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[] = {
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);
res = -EIO;
}
}
-
+
return res;
}
}
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,
#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
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) {
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++;
}
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
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;
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);
}
}
-
+
return 1;
}
long *min, long *max)
{
struct selem_base *s = snd_mixer_elem_get_private(elem);
-
+
*min = s->dir[dir].min;
*max = s->dir[dir].max;
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;
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;
}
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++) {
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;
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;
}
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)
return 1;
__error:
- if (initflag)
- free(priv);
+ if (initflag)
+ free(priv);
if (h)
snd_dlclose(h);
free(xlib);
*
* \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;
and
\code
- a 1
+ a 1
b 2
\endcode
# Compound assignment (first style)
name [=] {
- name1 [=] value [,|;]
- ...
+ name1 [=] value [,|;]
+ ...
}
# Compound assignment (second style)
# Array assignment (first style)
name [
- value0 [,|;]
- value1 [,|;]
- ...
+ value0 [,|;]
+ value1 [,|;]
+ ...
]
# Array assignment (second style)
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 {
break;
}
}
-
+
return c;
}
-
+
static int get_nonwhite(input_t *input)
{
free_local_string(&str);
return c;
}
-
+
static int get_delimstring(char **string, int delim, input_t *input)
{
struct local_string str;
*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)
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;
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;
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)
free(id);
return err;
}
-
+
static int parse_defs(snd_config_t *parent, input_t *input, int skip, int override)
{
int c, err;
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;
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;
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;
{
int err;
snd_config_t *tmp;
-
+
err = snd_config_make(&tmp, id, SND_CONFIG_TYPE_STRING);
if (err < 0)
return err;
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;
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;
-
+
do {
err = snd_card_next(&card);
if (err < 0)
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.
snd_config_update_t *local;
snd_config_update_t *update;
snd_config_t *top;
-
+
assert(_top && _update);
top = *_top;
update = *_update;
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;
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.
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.
return 0;
}
-/**
+/**
* \brief Frees the global configuration tree in #snd_config.
* \return Zero if successful, otherwise a negative error code.
*
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)
* 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);
buf[idx++] = c;
}
}
-
+
/* Parse var=val or val */
static int parse_arg(const char **ptr, unsigned int *varlen, char **val)
}
return 0;
}
-
+
while (1) {
char buf[256];
const char *var = buf;
*result = res;
err = 1;
_end:
- if (subs)
+ if (subs)
snd_config_delete(subs);
return err;
}
* \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.
* \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;
* \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;
default 0
}
\endcode
- */
+ */
int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
snd_config_t *private_data)
{
const char *res, *id;
char *def = NULL;
int idx = 0, err, hit;
-
+
err = snd_config_search(src, "vars", &n);
if (err < 0) {
snd_error(CORE, "field vars not found");
default 0
}
\endcode
- */
+ */
int snd_func_igetenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
snd_config_t *private_data)
{
#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
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)
{
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) {
snd_error(CORE, "field strings not found");
char *res = NULL;
long result = 0, val;
int idx = 0, err, hit;
-
+
err = snd_config_search(src, "integers", &n);
if (err < 0) {
snd_error(CORE, "field integers not found");
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);
}
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)
{
@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;
@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)
{
@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)
{
snd_config_t *n;
char *str;
int card, err;
-
+
err = snd_config_search(src, "card", &n);
if (err < 0) {
snd_error(CORE, "field card not found");
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;
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;
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)
{
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 = 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
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)
{
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 = 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
#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
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;
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_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
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;
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) {
@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)
{
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);
int snd_card_next(int *rcard)
{
int card;
-
+
if (rcard == NULL)
return -EINVAL;
card = *rcard;
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)
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)
\verbatim
index [ID ] Driver - name
- longname
+ longname
\endverbatim
Note that the mixername and components are not listed.
*ctlp = ctl;
return 0;
}
-
+
/**
* \brief set async mode
return ctl->ops->poll_revents(ctl, pfds, nfds, revents);
if (nfds == 1) {
*revents = pfds->revents;
- return 0;
+ return 0;
}
return -EINVAL;
}
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;
}
err = ctl->ops->element_tlv(ctl, op_flag, id->numid, tlv, tlv_size);
__err:
- if (info)
- free(info);
+ if (info)
+ free(info);
return err;
}
* \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;
}
obj->space = entries;
return 0;
-}
+}
/**
* \brief free previously allocated space for CTL element identifiers list
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;
return ext->callback->poll_revents(ext, pfds, nfds, revents);
if (nfds == 1) {
*revents = pfds->revents;
- return 0;
+ return 0;
}
return -EINVAL;
}
#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
\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
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
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);
snd_ctl_hw_t *hw;
int err;
- *handle = NULL;
+ *handle = NULL;
if (CHECK_SANITY(card < 0 || card >= SND_MAX_CARDS)) {
snd_check(CONTROL, "Invalid card index %d", card);
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;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
sock = socket(PF_LOCAL, SOCK_STREAM, 0);
if (sock < 0)
return -errno;
-
+
addr->sun_family = AF_LOCAL;
memcpy(addr->sun_path, filename, l);
result = -errno;
goto _err;
}
-
+
shm = calloc(1, sizeof(snd_ctl_shm_t));
if (!shm) {
result = -ENOMEM;
&_snd_module_control_empty,
#include "ctl_symbols_list.c"
};
-
+
void *snd_control_open_symbols(void)
{
return snd_control_open_objects;
if (*str)
goto out;
}
- }
+ }
err = 0;
out:
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;
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;
{
snd_ctl_t *ctl;
int err;
-
+
if ((err = snd_ctl_open(&ctl, name, mode)) < 0)
return err;
err = snd_hctl_open_ctl(hctlp, ctl);
};
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')
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;
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) {
snd_error(CONTROL, "Invalid poll_fds %d", npfds);
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 &&
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;
{
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;
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)
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, "hint", &cfg) >= 0) {
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
snd_error(CONTROL, "hint (%s) must be a compound", buf);
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;
__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;
}
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)
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;
}
err = 0;
__error:
- snd_ctl_close(list->ctl);
+ snd_ctl_close(list->ctl);
return err;
}
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);
return NULL;
hint1 = delim + 1;
continue;
- }
+ }
if (delim == NULL)
return strdup(hint1 + 4);
size = delim - hint1 - 4;
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)
#ifdef HAVE_LIBDL
int res;
char *vname;
-
+
if (handle == NULL)
return -EINVAL;
vname = alloca(1 + strlen(name) + strlen(version) + 1);
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)
snd_error(CORE, "Cannot open shared library %s (%s)",
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);
*/
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
assert(handle);
*handle = NULL;
-
+
if (card < 0 || card >= SND_MAX_CARDS)
return -EINVAL;
sprintf(filename, SNDRV_FILE_HWDEP, card, device);
static const char **snd_hwdep_open_objects[] = {
&_snd_module_hwdep_hw
};
-
+
void *snd_hwdep_open_symbols(void)
{
return snd_hwdep_open_objects;
{
return (input->ops->gets)(input, str, size);
}
-
+
/**
* \brief Reads a character from an input handle (like \c fgetc(3)).
* \param input The input handle.
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;
*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
*str = '\0';
return str;
}
-
+
static int snd_input_buffer_getc(snd_input_t *input)
{
snd_input_buffer_t *buffer = input->private_data;
*inputp = input;
return 0;
}
-
+
{
unsigned int idx;
unsigned short res;
- assert(mixer && pfds && revents);
+ assert(mixer && pfds && revents);
if (nfds == 0)
return -EINVAL;
res = 0;
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);
}
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;
};
return s1->id->index - s2->id->index;
}
#endif
-
+
/**
* \brief Find a mixer simple element
* \param mixer Mixer handle
* \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);
* \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);
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)
__error:
if (top)
snd_config_delete(top);
- if (class)
+ if (class)
snd_mixer_class_free(class);
return err;
}
static int selem_write(snd_mixer_elem_t *elem)
{
int err;
-
+
err = selem_write_main(elem);
if (err < 0)
selem_read(elem);
simple->str[SM_CAPT].max = cmax != LONG_MIN ? cmax : 0;
}
return 0;
-}
+}
#ifndef DOC_HIDDEN
static const struct suf {
/*
* 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);
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]) {
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) {
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: {
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) ) {
}
}
-
+
return 1;
}
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)
{
}
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;
}
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;
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:
#include <limits.h>
#include <sys/stat.h>
-/**
+/**
* \brief This function is unimplemented.
* \deprecated Since 1.0.14
*/
{
return output->ops->puts(output, str);
}
-
+
/**
* \brief Writes a character to an output handle (like \c putc(3)).
* \param output The output handle.
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;
*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
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;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#define SND_INTERVAL_C
#define SND_INTERVAL_INLINE
*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) {
{
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)
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
typedef struct _snd_interval snd_interval_t;
#ifdef SND_INTERVAL_INLINE
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);
* 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)
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)));
}
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 ||
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
/*****************************************************************************/
-/* 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
/* 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. */
/*****************************************************************************/
-/* 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. */
(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
/*****************************************************************************/
-/* 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
/*****************************************************************************/
-/* 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
#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 {
/*****************************************************************************/
-/* 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
/*****************************************************************************/
-/* 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
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
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
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
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
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
/* 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. */
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);
/**********************************************************************/
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#define SND_MASK_C
#define SND_MASK_INLINE
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
typedef struct _snd_mask snd_mask_t;
#define SND_MASK_MAX 64
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include <strings.h>
#include <sys/types.h>
MASK_INLINE unsigned int ld2(uint32_t v)
{
- 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;
+ 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;
}
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)
\par SND_PCM_STATE_OPEN
The PCM device is in the open state. After the #snd_pcm_open() open call,
the device is in this state. Also, when #snd_pcm_hw_params() call fails,
-then this state is entered to force application calling
+then this state is entered to force application calling
#snd_pcm_hw_params() function to set right communication
parameters.
if (err < 0)
res = err;
return res;
-}
+}
/**
* \brief set nonblock mode
params->rate_den = pcm->rate_den;
params->fifo_size = pcm->fifo_size;
return 0;
-}
+}
/** \brief Install one PCM hardware configuration chosen from a configuration space and #snd_pcm_prepare it
* \param pcm PCM handle
* \return 0 on success otherwise a negative error code
*
* The configuration is chosen fixing single parameters in this order:
- * first access, first format, first subformat, min channels, min rate,
+ * first access, first format, first subformat, min channels, min rate,
* min period time, max buffer size, min tick time. If no mutually
* compatible set of parameters can be chosen, a negative error code
* will be returned.
* If the non-blocking behaviour is selected, then routine doesn't wait at all.
*
* The function is thread-safe when built with the proper option.
- */
+ */
snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
{
int err;
* If the non-blocking behaviour is selected, then routine doesn't wait at all.
*
* The function is thread-safe when built with the proper option.
- */
+ */
snd_pcm_sframes_t snd_pcm_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
{
int err;
* If the non-blocking behaviour is selected, then routine doesn't wait at all.
*
* The function is thread-safe when built with the proper option.
- */
+ */
snd_pcm_sframes_t snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size)
{
int err;
* If the non-blocking behaviour is selected, then routine doesn't wait at all.
*
* The function is thread-safe when built with the proper option.
- */
+ */
snd_pcm_sframes_t snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
{
int err;
* \return 0 on success otherwise a negative error code
*
* The two PCMs will start/stop/prepare in sync.
- */
+ */
int snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2)
{
int err = 0;
#define HW_PARAM(v) [SND_PCM_HW_PARAM_##v] = #v
#define SW_PARAM(v) [SND_PCM_SW_PARAM_##v] = #v
#define FORMAT(v) [SND_PCM_FORMAT_##v] = #v
-#define SUBFORMAT(v) [SND_PCM_SUBFORMAT_##v] = #v
+#define SUBFORMAT(v) [SND_PCM_SUBFORMAT_##v] = #v
#define FORMATD(v, d) [SND_PCM_FORMAT_##v] = d
-#define SUBFORMATD(v, d) [SND_PCM_SUBFORMAT_##v] = d
+#define SUBFORMATD(v, d) [SND_PCM_SUBFORMAT_##v] = d
static const char *const snd_pcm_stream_names[] = {
};
static const char *const snd_pcm_access_names[] = {
- ACCESS(MMAP_INTERLEAVED),
+ ACCESS(MMAP_INTERLEAVED),
ACCESS(MMAP_NONINTERLEAVED),
ACCESS(MMAP_COMPLEX),
ACCESS(RW_INTERLEAVED),
};
static const char *const snd_pcm_format_descriptions[] = {
- FORMATD(S8, "Signed 8 bit"),
+ FORMATD(S8, "Signed 8 bit"),
FORMATD(U8, "Unsigned 8 bit"),
FORMATD(S16_LE, "Signed 16 bit Little Endian"),
FORMATD(S16_BE, "Signed 16 bit Big Endian"),
};
static const char *const snd_pcm_type_names[] = {
- PCMTYPE(HW),
- PCMTYPE(HOOKS),
- PCMTYPE(MULTI),
- PCMTYPE(FILE),
- PCMTYPE(NULL),
- PCMTYPE(SHM),
- PCMTYPE(INET),
- PCMTYPE(COPY),
- PCMTYPE(LINEAR),
- PCMTYPE(ALAW),
- PCMTYPE(MULAW),
- PCMTYPE(ADPCM),
- PCMTYPE(RATE),
- PCMTYPE(ROUTE),
- PCMTYPE(PLUG),
- PCMTYPE(SHARE),
- PCMTYPE(METER),
- PCMTYPE(MIX),
- PCMTYPE(DROUTE),
- PCMTYPE(LBSERVER),
- PCMTYPE(LINEAR_FLOAT),
- PCMTYPE(LADSPA),
- PCMTYPE(DMIX),
+ PCMTYPE(HW),
+ PCMTYPE(HOOKS),
+ PCMTYPE(MULTI),
+ PCMTYPE(FILE),
+ PCMTYPE(NULL),
+ PCMTYPE(SHM),
+ PCMTYPE(INET),
+ PCMTYPE(COPY),
+ PCMTYPE(LINEAR),
+ PCMTYPE(ALAW),
+ PCMTYPE(MULAW),
+ PCMTYPE(ADPCM),
+ PCMTYPE(RATE),
+ PCMTYPE(ROUTE),
+ PCMTYPE(PLUG),
+ PCMTYPE(SHARE),
+ PCMTYPE(METER),
+ PCMTYPE(MIX),
+ PCMTYPE(DROUTE),
+ PCMTYPE(LBSERVER),
+ PCMTYPE(LINEAR_FLOAT),
+ PCMTYPE(LADSPA),
+ PCMTYPE(DMIX),
PCMTYPE(JACK),
PCMTYPE(DSNOOP),
PCMTYPE(IEC958),
};
static const char *const snd_pcm_subformat_names[] = {
- SUBFORMAT(STD),
+ SUBFORMAT(STD),
SUBFORMAT(MSBITS_MAX),
SUBFORMAT(MSBITS_20),
SUBFORMAT(MSBITS_24),
};
static const char *const snd_pcm_subformat_descriptions[] = {
- SUBFORMATD(STD, "Standard"),
+ SUBFORMATD(STD, "Standard"),
SUBFORMATD(MSBITS_MAX, "Maximum based on PCM format"),
SUBFORMATD(MSBITS_20, "20 most significant bits"),
SUBFORMATD(MSBITS_24, "24 most significant bits"),
snd_check(PCM, "PCM not set up");
return -EIO;
}
- snd_output_printf(out, " stream : %s\n", snd_pcm_stream_name(pcm->stream));
+ snd_output_printf(out, " stream : %s\n", snd_pcm_stream_name(pcm->stream));
snd_output_printf(out, " access : %s\n", snd_pcm_access_name(pcm->access));
snd_output_printf(out, " format : %s\n", snd_pcm_format_name(pcm->format));
snd_output_printf(out, " subformat : %s\n", snd_pcm_subformat_name(pcm->subformat));
*
* The asynchronous callback is called when period boundary elapses.
*/
-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)
{
int err;
snd_config_iterator_t i, next;
const char *id;
const char *lib = NULL, *open_name = NULL;
- int (*open_func)(snd_pcm_t **, const char *,
- snd_config_t *, snd_config_t *,
+ int (*open_func)(snd_pcm_t **, const char *,
+ snd_config_t *, snd_config_t *,
snd_pcm_stream_t, int) = NULL;
#ifndef PIC
extern void *snd_pcm_open_symbols(void);
* \param mode Open mode (see #SND_PCM_NONBLOCK, #SND_PCM_ASYNC)
* \return 0 on success otherwise a negative error code
*/
-int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
+int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_stream_t stream, int mode)
{
snd_config_t *top;
* \param lconf Local configuration
* \return 0 on success otherwise a negative error code
*/
-int snd_pcm_open_lconf(snd_pcm_t **pcmp, const char *name,
+int snd_pcm_open_lconf(snd_pcm_t **pcmp, const char *name,
snd_pcm_stream_t stream, int mode,
snd_config_t *lconf)
{
* see also SND_PCM_WAIT_IO and SND_PCM_WAIT_DRAIN
* \return a positive value on success otherwise a negative error code
* (-EPIPE for the xrun and -ESTRPIPE for the suspended status,
- * others for general errors)
+ * others for general errors)
* \retval 0 timeout occurred
* \retval 1 PCM stream is ready for I/O
*
return timeout;
}
-/*
+/*
* like snd_pcm_wait() but doesn't check mmap_avail before calling poll()
*
* used in drain code in some plugins
struct pollfd *pfd;
unsigned short revents = 0;
int npfds, err, err_poll;
-
+
npfds = __snd_pcm_poll_descriptors_count(pcm);
if (npfds <= 0 || npfds >= 16) {
snd_error(PCM, "Invalid poll_fds %d", npfds);
__snd_pcm_lock(pcm->fast_op_arg);
if (err_poll < 0) {
if (errno == EINTR && !PCMINABORT(pcm) && !(pcm->mode & SND_PCM_EINTR))
- continue;
+ continue;
return -errno;
- }
+ }
if (! err_poll)
break;
err = __snd_pcm_poll_revents(pcm, pfd, npfds, &revents);
dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
width = snd_pcm_format_physical_width(format);
silence = snd_pcm_format_silence_64(format);
- /*
- * Iterate copying silent sample for sample data aligned to 64 bit.
- * This is a fast path.
- */
- if (dst_area->step == (unsigned int) width &&
- width != 24 &&
- ((intptr_t)dst & 7) == 0) {
+ /*
+ * Iterate copying silent sample for sample data aligned to 64 bit.
+ * This is a fast path.
+ */
+ if (dst_area->step == (unsigned int) width &&
+ width != 24 &&
+ ((intptr_t)dst & 7) == 0) {
unsigned int dwords = samples * width / 64;
uint64_t *dstp = (uint64_t *)dst;
samples -= dwords * 64 / width;
d.first = dst_start->first;
d.step = width;
snd_pcm_area_copy(&d, dst_offset * chns,
- &s, src_offset * chns,
+ &s, src_offset * chns,
frames * chns, format);
}
channels -= chns;
return err;
// compute frame bits
fb = snd_pcm_format_physical_width((snd_pcm_format_t)format) * channels;
- min_align = 1;
+ min_align = 1;
while (fb % 8) {
fb *= 2;
- min_align *= 2;
+ min_align *= 2;
}
if (val)
*val = min_align;
* \param val Start threshold in frames
* \return 0 otherwise a negative error code
*
- * PCM is automatically started when playback frames available to PCM
+ * PCM is automatically started when playback frames available to PCM
* are >= threshold or when requested capture frames are >= threshold
*/
#ifndef DOXYGEN
* \param val Returned start threshold in frames
* \return 0 otherwise a negative error code
*
- * PCM is automatically started when playback frames available to PCM
+ * PCM is automatically started when playback frames available to PCM
* are >= threshold or when requested capture frames are >= threshold
*/
#ifndef DOXYGEN
* \brief Set silence threshold inside a software configuration container
* \param pcm PCM handle
* \param params Software configuration container
- * \param val Silence threshold in frames
+ * \param val Silence threshold in frames
* \return 0 otherwise a negative error code
*
- * A portion of playback buffer is overwritten with silence (see
+ * A portion of playback buffer is overwritten with silence (see
* #snd_pcm_sw_params_set_silence_size) when playback underrun is nearer
* than silence threshold.
*/
* \param val Returned silence threshold in frames
* \return 0 otherwise a negative error value
*
- * A portion of playback buffer is overwritten with silence (see
+ * A portion of playback buffer is overwritten with silence (see
* #snd_pcm_sw_params_set_silence_size) when playback underrun is nearer
* than silence threshold.
*/
* \return 0 otherwise a negative error code
*
* A portion of playback buffer is overwritten with silence when playback
- * underrun is nearer than silence threshold (see
+ * underrun is nearer than silence threshold (see
* #snd_pcm_sw_params_set_silence_threshold)
*
* When drain silence (see #snd_pcm_hw_params_get_drain_silence) is disabled,
* \return 0 otherwise a negative error code
*
* A portion of playback buffer is overwritten with silence when playback
- * underrun is nearer than silence threshold (see
+ * underrun is nearer than silence threshold (see
* #snd_pcm_sw_params_set_silence_threshold)
*/
#ifndef DOXYGEN
*dst = *src;
}
-/**
+/**
* \brief Get state from a PCM status container (see #snd_pcm_state)
* \param obj #snd_pcm_status_t pointer
* \return PCM state
return obj->state;
}
-/**
+/**
* \brief Get trigger timestamp from a PCM status container
* \param obj #snd_pcm_status_t pointer
* \param ptr Pointer to returned timestamp
ptr->tv_usec = obj->trigger_tstamp.tv_nsec / 1000L;
}
-/**
+/**
* \brief Get trigger hi-res timestamp from a PCM status container
* \param obj #snd_pcm_status_t pointer
* \param ptr Pointer to returned timestamp
}
use_default_symbol_version(__snd_pcm_status_get_trigger_htstamp, snd_pcm_status_get_trigger_htstamp, ALSA_0.9.0rc8);
-/**
+/**
* \brief Get "now" timestamp from a PCM status container
* \param obj #snd_pcm_status_t pointer
* \param ptr Pointer to returned timestamp
ptr->tv_usec = obj->tstamp.tv_nsec / 1000L;
}
-/**
+/**
* \brief Get "now" hi-res timestamp from a PCM status container
* \param obj pointer to #snd_pcm_status_t
* \param ptr Pointer to returned timestamp
}
use_default_symbol_version(__snd_pcm_status_get_htstamp, snd_pcm_status_get_htstamp, ALSA_0.9.0rc8);
-/**
+/**
* \brief Get "now" hi-res audio timestamp from a PCM status container
* \param obj pointer to #snd_pcm_status_t
* \param ptr Pointer to returned timestamp
return obj->delay;
}
-/**
+/**
* \brief Get number of frames available from a PCM status container (see #snd_pcm_avail_update)
* \return Number of frames ready to be read/written
*/
return obj->avail;
}
-/**
+/**
* \brief Get maximum number of frames available from a PCM status container after last #snd_pcm_status call
* \return Maximum number of frames ready to be read/written
*
return obj->avail_max;
}
-/**
+/**
* \brief Get count of ADC overrange detections since last call
* \return Count of ADC overrange detections
*/
/**
* \brief Application request to access a portion of direct (mmap) area
- * \param pcm PCM handle
+ * \param pcm PCM handle
* \param areas Returned mmap channel areas
* \param offset Returned mmap area offset in area steps (== frames)
* \param frames mmap area portion size in frames (wanted on entry, contiguous available on exit)
if (avail < 0)
error(avail);
// at this point, we can transfer at least 'avail' frames
-
+
// we want to process frames in chunks (period_size)
if (avail < period_size)
goto _skip;
commitres = snd_pcm_mmap_commit(pcm_handle, offset, frames);
if (commitres < 0 || commitres != frames)
error(commitres >= 0 ? -EPIPE : commitres);
-
+
size -= frames;
}
_skip:
return pcm->poll_fd;
}
-void snd_pcm_areas_from_buf(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas,
+void snd_pcm_areas_from_buf(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas,
void *buf)
{
unsigned int channel;
snd_pcm_unlock(pcm);
}
-void snd_pcm_areas_from_bufs(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas,
+void snd_pcm_areas_from_bufs(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas,
void **bufs)
{
unsigned int channel;
if (err < 0)
break;
goto _again;
-
+
}
frames = size;
if (frames > (snd_pcm_uframes_t) avail)
pcm_conf = NULL;
err = 0;
_err:
- if (pcm_conf)
- snd_config_delete(pcm_conf);
+ if (pcm_conf)
+ snd_config_delete(pcm_conf);
if (to_free)
snd_config_delete(conf);
return err;
}
-
+
static void snd_pcm_set_ptr(snd_pcm_t *pcm, snd_pcm_rbptr_t *rbptr,
volatile snd_pcm_uframes_t *hw_ptr, int fd, off_t offset)
{
{
snd_pcm_t **a;
int idx;
-
+
a = slave_rbptr->link_dst;
for (idx = 0; idx < slave_rbptr->link_dst_count; idx++)
if (a[idx] == NULL) {
return;
__found:
- pcm_rbptr->master = NULL;
+ pcm_rbptr->master = NULL;
pcm_rbptr->ptr = NULL;
pcm_rbptr->fd = -1;
pcm_rbptr->offset = 0UL;
/*
* basic helpers
*/
-
-
+
+
/**
* \brief Recover the stream state from an error or suspend
* \param pcm PCM handle
*/
int snd_pcm_recover(snd_pcm_t *pcm, int err, int silent)
{
- if (err > 0)
- err = -err;
- if (err == -EINTR) /* nothing to do, continue */
- return 0;
- if (err == -EPIPE) {
- const char *s;
- if (snd_pcm_stream(pcm) == SND_PCM_STREAM_PLAYBACK)
- s = "underrun";
- else
- s = "overrun";
- if (!silent)
+ if (err > 0)
+ err = -err;
+ if (err == -EINTR) /* nothing to do, continue */
+ return 0;
+ if (err == -EPIPE) {
+ const char *s;
+ if (snd_pcm_stream(pcm) == SND_PCM_STREAM_PLAYBACK)
+ s = "underrun";
+ else
+ s = "overrun";
+ if (!silent)
snd_error(PCM, "%s occurred", s);
- err = snd_pcm_prepare(pcm);
- if (err < 0) {
+ err = snd_pcm_prepare(pcm);
+ if (err < 0) {
snd_error(PCM, "cannot recovery from %s, prepare failed: %s", s, snd_strerror(err));
- return err;
- }
- return 0;
- }
- if (err == -ESTRPIPE) {
- while ((err = snd_pcm_resume(pcm)) == -EAGAIN)
- /* wait until suspend flag is released */
- poll(NULL, 0, 1000);
- if (err < 0) {
- err = snd_pcm_prepare(pcm);
- if (err < 0) {
+ return err;
+ }
+ return 0;
+ }
+ if (err == -ESTRPIPE) {
+ while ((err = snd_pcm_resume(pcm)) == -EAGAIN)
+ /* wait until suspend flag is released */
+ poll(NULL, 0, 1000);
+ if (err < 0) {
+ err = snd_pcm_prepare(pcm);
+ if (err < 0) {
snd_error(PCM, "cannot recovery from suspend, prepare failed: %s", snd_strerror(err));
- return err;
- }
- }
- return 0;
- }
- return err;
+ return err;
+ }
+ }
+ return 0;
+ }
+ return err;
}
/**
* \return 0 on success otherwise a negative error code
*/
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)
{
snd_pcm_hw_params_t params_saved, params = {0};
snd_pcm_sw_params_t swparams = {0};
s);
return err;
- }
+ }
/* set software resampling */
err = snd_pcm_hw_params_set_rate_resample(pcm, ¶ms, soft_resample);
if (err < 0) {
* \return 0 on success otherwise a negative error code
*/
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)
{
snd_pcm_hw_params_t params = {0};
int err;
assert(pcm);
err = snd_pcm_hw_params_current(pcm, ¶ms);
if (err < 0)
- return err;
+ return err;
err = INTERNAL(snd_pcm_hw_params_get_buffer_size)(¶ms, buffer_size);
if (err < 0)
return err;
* 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
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)
{
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;
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);
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");
\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
* 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;
return err;
if (snd_pcm_format_linear(sformat) != 1 &&
sformat != SND_PCM_FORMAT_IMA_ADPCM) {
- snd_config_delete(sconf);
+ snd_config_delete(sconf);
snd_error(PCM, "invalid slave format");
return -EINVAL;
}
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "bswap.h"
#include "pcm_plugin.h"
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)
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)
{
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);
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;
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);
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");
* \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;
\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
* 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;
return err;
if (snd_pcm_format_linear(sformat) != 1 &&
sformat != SND_PCM_FORMAT_A_LAW) {
- snd_config_delete(sconf);
+ snd_config_delete(sconf);
snd_error(PCM, "invalid slave format");
return -EINVAL;
}
\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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
#include "bswap.h"
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)
{
{
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;
\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 {
* 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;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
/*
*
*/
-
+
#if !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__ANDROID__)
union semun {
int val; /* Value for SETVAL */
#endif
};
#endif
-
+
/*
* FIXME:
* add possibility to use futexes here
}
/*
- * 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);
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;
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;
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;
if (i != dmix->server_fd && i != dmix->hw_fd)
close(i);
}
-
+
/* detach from parent */
setsid();
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;
close(dmix->server_fd);
return ret;
}
-
+
ret = fork();
if (ret < 0) {
close(dmix->server_fd);
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) |
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;
int loops = 10;
__again:
- if (loops-- <= 0) {
+ if (loops-- <= 0) {
snd_error(PCM, "unable to find a valid configuration for slave");
- return -EINVAL;
- }
+ return -EINVAL;
+ }
ret = snd_pcm_hw_params_any(spcm, &hw_params);
if (ret < 0) {
snd_error(PCM, "snd_pcm_hw_params_any failed");
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,
return ret;
}
}
-
+
ret = snd_pcm_hw_params(spcm, &hw_params);
if (ret < 0) {
snd_error(PCM, "unable to install hw params");
snd_pcm_areas_silence(dst_areas, 0, spcm->channels,
spcm->buffer_size, spcm->format);
}
-
+
ret = snd_pcm_start(spcm);
if (ret < 0) {
snd_error(PCM, "unable to start PCM stream");
}
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
snd_error(PCM, "unable to open hardware");
return ret;
}
-
+
spcm = *spcmp;
spcm->donot_close = 1;
spcm->setup = 1;
*
*/
-#include "pcm_local.h"
+#include "pcm_local.h"
#include "../timer/timer_local.h"
#define DIRECT_IPC_SEMS 1
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*/
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
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)
{
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);
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;
}
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) {
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:
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:
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
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);
{
snd_pcm_direct_t *dmix = pcm->private_data;
int err;
-
+
switch(dmix->state) {
case SNDRV_PCM_STATE_DRAINING:
case SNDRV_PCM_STATE_RUNNING:
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);
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);
{
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)
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)
snd_error(PCM, "unable to open slave");
goto _err;
}
-
+
if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) {
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) {
snd_error(PCM, "unable to initialize slave");
if (dmix->shmptr->use_server) {
dmix->server_free = dmix_server_free;
-
+
ret = snd_pcm_direct_server_create(dmix);
if (ret < 0) {
snd_error(PCM, "unable to create server");
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)
ret = -EINVAL;
goto _err;
}
-
+
ret = snd_pcm_direct_initialize_secondary_slave(dmix, spcm, params);
if (ret < 0) {
snd_error(PCM, "unable to initialize slave");
}
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;
*pcmp = pcm;
return 0;
-
+
_err:
if (dmix->timer)
snd_timer_close(dmix->timer);
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 */
}
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;
}
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;
#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
#undef LOCK_PREFIX
#undef XADD
#undef XSUB
-
+
#define i386_dmix_supported_format \
((1ULL << SND_PCM_FORMAT_S16_LE) |\
(1ULL << SND_PCM_FORMAT_S32_LE) |\
if (!smp) {
FILE *in;
char line[255];
-
+
/* try to determine the capabilities of the CPU */
in = fopen("/proc/cpuinfo", "r");
if (in) {
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;
"\tdecl %[size]\n"
"\tjnz 1b\n"
"\temms\n"
- "5:"
+ "5:"
#ifdef BOUNDED_EBX
"\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */
#endif
#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
#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) |\
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;
#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"
#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"
#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"
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
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)
{
snd_pcm_direct_t *dshare = pcm->private_data;
int err;
-
+
switch (dshare->state) {
case SNDRV_PCM_STATE_DRAINING:
case SNDRV_PCM_STATE_RUNNING:
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);
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);
{
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)
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)
snd_error(PCM, "unable to open slave");
goto _err;
}
-
+
if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) {
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) {
snd_error(PCM, "unable to initialize slave");
}
dshare->spcm = spcm;
-
+
if (dshare->shmptr->use_server) {
ret = snd_pcm_direct_server_create(dshare);
if (ret < 0) {
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)
ret = -EINVAL;
goto _err;
}
-
+
ret = snd_pcm_direct_initialize_secondary_slave(dshare, spcm, params);
if (ret < 0) {
snd_error(PCM, "unable to initialize slave");
goto _err;
}
dshare->shmptr->u.dshare.chn_mask |= dshare->u.dshare.chn_mask;
-
+
ret = snd_pcm_direct_initialize_poll_fd(dshare);
if (ret < 0) {
snd_error(PCM, "unable to initialize poll_fd");
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;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
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);
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;
}
{
snd_pcm_direct_t *dsnoop = pcm->private_data;
int err;
-
+
switch(dsnoop->state) {
case SNDRV_PCM_STATE_DRAINING:
case SNDRV_PCM_STATE_RUNNING:
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);
{
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)
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)
snd_error(PCM, "unable to open slave");
goto _err;
}
-
+
if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) {
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) {
snd_error(PCM, "unable to initialize slave");
}
dsnoop->spcm = spcm;
-
+
if (dsnoop->shmptr->use_server) {
ret = snd_pcm_direct_server_create(dsnoop);
if (ret < 0) {
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");
ret = -EINVAL;
goto _err;
}
-
+
ret = snd_pcm_direct_initialize_secondary_slave(dsnoop, spcm, params);
if (ret < 0) {
snd_error(PCM, "unable to initialize slave");
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);
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 */
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
* 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;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
#include "pcm_extplug.h"
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)
#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
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).
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
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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
#include "bswap.h"
'd', 'a', 't', 'a',
0, 0, 0, 0
};
-
+
setup_wav_header(pcm, &file->wav_header);
res = safe_write(file->fd, header, sizeof(header));
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;
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);
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);
}
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;
\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).
* 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;
*/
/*
* 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
}
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);
}
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)
{
* 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 \
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_generic.h"
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)
* 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;
* 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"
if (pcm->tstamp_type != SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY)
params->info |= SND_PCM_INFO_MONOTONIC;
}
-
+
return 0;
}
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",
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;
* 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;
/*
return ret;
}
}
-
+
hw = calloc(1, sizeof(snd_pcm_hw_t));
if (!hw) {
close(fd);
sprintf(filename, filefmt, card, device);
__again:
- if (attempt++ > 3) {
+ if (attempt++ > 3) {
ret = -EBUSY;
goto _err;
}
return 0;
fail:
- snd_pcm_free_chmaps(chmap);
- return err;
+ snd_pcm_free_chmaps(chmap);
+ return err;
}
#ifndef DOC_HIDDEN
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);
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
#include "plugin_ops.h"
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)
{
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;
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;
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");
* \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;
\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
* 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;
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);
+ snd_config_delete(sconf);
snd_error(PCM, "invalid slave format");
return -EINVAL;
}
* 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"
{
ioplug_priv_t *io = pcm->private_data;
int err;
-
+
if (io->data->state != SND_PCM_STATE_PREPARED)
return -EBADFD;
{
ioplug_priv_t *io = pcm->private_data;
snd_pcm_sframes_t result;
-
+
if (! size)
return 0;
if (io->data->callback->transfer)
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);
}
}
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).
* The LADSPA plugin rewrite was sponsored by MediaNet AG
* http://www.medianet.ag
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
#include <dirent.h>
unsigned int allocated; /* count of allocated samples */
LADSPA_Data *zero[2]; /* zero input or dummy output */
} snd_pcm_ladspa_t;
-
+
typedef struct {
- unsigned int size;
- unsigned int *array;
+ unsigned int size;
+ unsigned int *array;
} snd_pcm_ladspa_array_t;
typedef struct {
- snd_pcm_ladspa_array_t channels;
- snd_pcm_ladspa_array_t ports;
+ snd_pcm_ladspa_array_t channels;
+ snd_pcm_ladspa_array_t ports;
LADSPA_Data **m_data;
- LADSPA_Data **data;
+ LADSPA_Data **data;
} snd_pcm_ladspa_eps_t;
typedef struct snd_pcm_ladspa_instance {
#endif /* DOC_HIDDEN */
static unsigned int snd_pcm_ladspa_count_ports(snd_pcm_ladspa_plugin_t *lplug,
- LADSPA_PortDescriptor pdesc)
+ LADSPA_PortDescriptor pdesc)
{
- unsigned int res = 0, idx;
- for (idx = 0; idx < lplug->desc->PortCount; idx++) {
- if ((lplug->desc->PortDescriptors[idx] & pdesc) == pdesc)
- res++;
- }
- return res;
+ unsigned int res = 0, idx;
+ for (idx = 0; idx < lplug->desc->PortCount; idx++) {
+ if ((lplug->desc->PortDescriptors[idx] & pdesc) == pdesc)
+ res++;
+ }
+ return res;
}
static int snd_pcm_ladspa_find_port(unsigned int *res,
{
while (!list_empty(plugins)) {
snd_pcm_ladspa_plugin_t *plugin = list_entry(plugins->next, snd_pcm_ladspa_plugin_t, list);
- snd_pcm_ladspa_free_io(&plugin->input);
- snd_pcm_ladspa_free_io(&plugin->output);
+ snd_pcm_ladspa_free_io(&plugin->input);
+ snd_pcm_ladspa_free_io(&plugin->output);
if (plugin->dl_handle)
dlclose(plugin->dl_handle);
free(plugin->filename);
static void snd_pcm_ladspa_free(snd_pcm_ladspa_t *ladspa)
{
- unsigned int idx;
+ unsigned int idx;
snd_pcm_ladspa_free_plugins(&ladspa->pplugins);
snd_pcm_ladspa_free_plugins(&ladspa->cplugins);
for (idx = 0; idx < 2; idx++) {
free(ladspa->zero[idx]);
- ladspa->zero[idx] = NULL;
- }
- ladspa->allocated = 0;
+ ladspa->zero[idx] = NULL;
+ }
+ ladspa->allocated = 0;
}
static int snd_pcm_ladspa_close(snd_pcm_t *pcm)
err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD);
if (err < 0)
return err;
- if (ladspa->channels > 0 && pcm->stream == SND_PCM_STREAM_PLAYBACK) {
- err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_CHANNELS, ladspa->channels, 0);
- if (err < 0)
- return err;
- }
+ if (ladspa->channels > 0 && pcm->stream == SND_PCM_STREAM_PLAYBACK) {
+ err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_CHANNELS, ladspa->channels, 0);
+ if (err < 0)
+ return err;
+ }
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
return 0;
}
&saccess_mask);
_snd_pcm_hw_params_set_format(sparams, SND_PCM_FORMAT_FLOAT);
_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);
- if (ladspa->channels > 0 && pcm->stream == SND_PCM_STREAM_CAPTURE)
- _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_CHANNELS, ladspa->channels, 0);
+ if (ladspa->channels > 0 && pcm->stream == SND_PCM_STREAM_CAPTURE)
+ _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_CHANNELS, ladspa->channels, 0);
return 0;
}
return err;
return 0;
}
-
+
static int snd_pcm_ladspa_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
{
struct list_head *list, *pos, *pos1, *next1;
unsigned int idx;
-
+
list = pcm->stream == SND_PCM_STREAM_PLAYBACK ? &ladspa->pplugins : &ladspa->cplugins;
list_for_each(pos, list) {
snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list);
if (plugin->desc->cleanup)
plugin->desc->cleanup(instance->handle);
if (instance->input.m_data) {
- for (idx = 0; idx < instance->input.channels.size; idx++)
+ for (idx = 0; idx < instance->input.channels.size; idx++)
free(instance->input.m_data[idx]);
free(instance->input.m_data);
- }
+ }
if (instance->output.m_data) {
- for (idx = 0; idx < instance->output.channels.size; idx++)
+ for (idx = 0; idx < instance->output.channels.size; idx++)
free(instance->output.m_data[idx]);
free(instance->output.m_data);
- }
- free(instance->input.data);
- free(instance->output.data);
+ }
+ free(instance->input.data);
+ free(instance->output.data);
list_del(&(instance->list));
snd_pcm_ladspa_free_eps(&instance->input);
snd_pcm_ladspa_free_eps(&instance->output);
}
static int snd_pcm_ladspa_add_to_carray(snd_pcm_ladspa_array_t *array,
- unsigned int idx,
- unsigned int val)
+ unsigned int idx,
+ unsigned int val)
{
- unsigned int *narray;
- unsigned int idx1;
-
- if (idx >= array->size) {
- narray = realloc(array->array, sizeof(unsigned int) * (idx + 1));
- if (narray == NULL)
- return -ENOMEM;
- for (idx1 = array->size; idx1 < idx; idx1++)
- narray[idx1] = NO_ASSIGN;
- array->array = narray;
- array->size = idx + 1;
- array->array[idx] = val;
- return 0;
- }
- if (array->array[idx] == NO_ASSIGN)
- array->array[idx] = val;
- else
- return -EINVAL;
- return 0;
+ unsigned int *narray;
+ unsigned int idx1;
+
+ if (idx >= array->size) {
+ narray = realloc(array->array, sizeof(unsigned int) * (idx + 1));
+ if (narray == NULL)
+ return -ENOMEM;
+ for (idx1 = array->size; idx1 < idx; idx1++)
+ narray[idx1] = NO_ASSIGN;
+ array->array = narray;
+ array->size = idx + 1;
+ array->array[idx] = val;
+ return 0;
+ }
+ if (array->array[idx] == NO_ASSIGN)
+ array->array[idx] = val;
+ else
+ return -EINVAL;
+ return 0;
}
static int snd_pcm_ladspa_add_to_array(snd_pcm_ladspa_array_t *array,
- unsigned int idx,
- unsigned int val)
+ unsigned int idx,
+ unsigned int val)
{
- unsigned int *narray;
- unsigned int idx1;
-
- if (idx >= array->size) {
- narray = realloc(array->array, sizeof(unsigned int) * (idx + 1));
- if (narray == NULL)
- return -ENOMEM;
- for (idx1 = array->size; idx1 < idx; idx1++)
- narray[idx1] = NO_ASSIGN;
- array->array = narray;
- array->size = idx + 1;
- }
- array->array[idx] = val;
- return 0;
+ unsigned int *narray;
+ unsigned int idx1;
+
+ if (idx >= array->size) {
+ narray = realloc(array->array, sizeof(unsigned int) * (idx + 1));
+ if (narray == NULL)
+ return -ENOMEM;
+ for (idx1 = array->size; idx1 < idx; idx1++)
+ narray[idx1] = NO_ASSIGN;
+ array->array = narray;
+ array->size = idx + 1;
+ }
+ array->array[idx] = val;
+ return 0;
}
static int snd_pcm_ladspa_connect_plugin1(snd_pcm_ladspa_plugin_t *plugin,
assert(plugin->policy == SND_PCM_LADSPA_POLICY_NONE);
channels = io->port_bindings_size > 0 ?
- io->port_bindings_size :
- snd_pcm_ladspa_count_ports(plugin, io->pdesc | LADSPA_PORT_AUDIO);
+ io->port_bindings_size :
+ snd_pcm_ladspa_count_ports(plugin, io->pdesc | LADSPA_PORT_AUDIO);
for (idx = idx1 = 0; idx < channels; idx++) {
if (io->port_bindings_size > 0)
- port = io->port_bindings[idx];
- else {
- err = snd_pcm_ladspa_find_port(&port, plugin, io->pdesc | LADSPA_PORT_AUDIO, idx);
- if (err < 0) {
+ port = io->port_bindings[idx];
+ else {
+ err = snd_pcm_ladspa_find_port(&port, plugin, io->pdesc | LADSPA_PORT_AUDIO, idx);
+ if (err < 0) {
snd_error(PCM, "unable to find audio %s port %u plugin '%s'", io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", idx, plugin->desc->Name);
- return err;
- }
- }
- if (port == NO_ASSIGN)
- continue;
- err = snd_pcm_ladspa_add_to_carray(&eps->channels, idx1, idx);
- if (err < 0) {
+ return err;
+ }
+ }
+ if (port == NO_ASSIGN)
+ continue;
+ err = snd_pcm_ladspa_add_to_carray(&eps->channels, idx1, idx);
+ if (err < 0) {
snd_error(PCM, "unable to add channel %u for audio %s plugin '%s'", idx, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name);
- return err;
- }
- err = snd_pcm_ladspa_add_to_array(&eps->ports, idx1, port);
- if (err < 0) {
+ return err;
+ }
+ err = snd_pcm_ladspa_add_to_array(&eps->ports, idx1, port);
+ if (err < 0) {
snd_error(PCM, "unable to add port %u for audio %s plugin '%s'", port, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name);
- return err;
- }
- idx1++;
+ return err;
+ }
+ idx1++;
}
return 0;
}
static int snd_pcm_ladspa_connect_plugin(snd_pcm_ladspa_plugin_t *plugin,
snd_pcm_ladspa_instance_t *instance)
{
- int err;
-
- err = snd_pcm_ladspa_connect_plugin1(plugin, &plugin->input, &instance->input);
- if (err < 0)
- return err;
- err = snd_pcm_ladspa_connect_plugin1(plugin, &plugin->output, &instance->output);
- if (err < 0)
- return err;
- return 0;
+ int err;
+
+ err = snd_pcm_ladspa_connect_plugin1(plugin, &plugin->input, &instance->input);
+ if (err < 0)
+ return err;
+ err = snd_pcm_ladspa_connect_plugin1(plugin, &plugin->output, &instance->output);
+ if (err < 0)
+ return err;
+ return 0;
}
static int snd_pcm_ladspa_connect_plugin_duplicate1(snd_pcm_ladspa_plugin_t *plugin,
- snd_pcm_ladspa_plugin_io_t *io,
- snd_pcm_ladspa_eps_t *eps,
- unsigned int idx)
+ snd_pcm_ladspa_plugin_io_t *io,
+ snd_pcm_ladspa_eps_t *eps,
+ unsigned int idx)
{
unsigned int port;
int err;
if (err < 0) {
snd_error(PCM, "unable to find audio %s port %u plugin '%s'", io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", (unsigned int)0, plugin->desc->Name);
return err;
- }
+ }
}
err = snd_pcm_ladspa_add_to_carray(&eps->channels, 0, idx);
if (err < 0) {
snd_error(PCM, "unable to add channel %u for audio %s plugin '%s'", idx, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name);
- return err;
- }
- err = snd_pcm_ladspa_add_to_array(&eps->ports, 0, port);
- if (err < 0) {
+ return err;
+ }
+ err = snd_pcm_ladspa_add_to_array(&eps->ports, 0, port);
+ if (err < 0) {
snd_error(PCM, "unable to add port %u for audio %s plugin '%s'", port, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name);
- return err;
- }
- return 0;
+ return err;
+ }
+ return 0;
}
static int snd_pcm_ladspa_connect_plugin_duplicate(snd_pcm_ladspa_plugin_t *plugin,
err = snd_pcm_ladspa_connect_plugin_duplicate1(plugin, in_io, &instance->input, idx);
if (err < 0)
- return err;
+ return err;
err = snd_pcm_ladspa_connect_plugin_duplicate1(plugin, out_io, &instance->output, idx);
if (err < 0)
- return err;
- return 0;
+ return err;
+ return 0;
}
-static void snd_pcm_ladspa_get_default_cvalue(const LADSPA_Descriptor * desc, unsigned int port, LADSPA_Data *val)
+static void snd_pcm_ladspa_get_default_cvalue(const LADSPA_Descriptor * desc, unsigned int port, LADSPA_Data *val)
{
- LADSPA_PortRangeHintDescriptor hdesc;
-
- hdesc = desc->PortRangeHints[port].HintDescriptor;
- switch (hdesc & LADSPA_HINT_DEFAULT_MASK) {
- case LADSPA_HINT_DEFAULT_MINIMUM:
- *val = desc->PortRangeHints[port].LowerBound;
- break;
- case LADSPA_HINT_DEFAULT_LOW:
- if (LADSPA_IS_HINT_LOGARITHMIC(hdesc)) {
- *val = exp(log(desc->PortRangeHints[port].LowerBound)
- * 0.75
- + log(desc->PortRangeHints[port].UpperBound)
- * 0.25);
- } else {
- *val = (desc->PortRangeHints[port].LowerBound * 0.75) +
- (desc->PortRangeHints[port].UpperBound * 0.25);
- }
- break;
- case LADSPA_HINT_DEFAULT_MIDDLE:
- if (LADSPA_IS_HINT_LOGARITHMIC(hdesc)) {
- *val = sqrt(desc->PortRangeHints[port].LowerBound *
- desc->PortRangeHints[port].UpperBound);
- } else {
- *val = 0.5 *
- (desc->PortRangeHints[port].LowerBound +
- desc->PortRangeHints[port].UpperBound);
- }
- break;
- case LADSPA_HINT_DEFAULT_HIGH:
- if (LADSPA_IS_HINT_LOGARITHMIC(hdesc)) {
- *val = exp(log(desc->PortRangeHints[port].LowerBound)
- * 0.25
- + log(desc->PortRangeHints[port].UpperBound)
- * 0.75);
- } else {
- *val = (desc->PortRangeHints[port].LowerBound * 0.25) +
- (desc->PortRangeHints[port].UpperBound * 0.75);
- }
- break;
- case LADSPA_HINT_DEFAULT_MAXIMUM:
- *val = desc->PortRangeHints[port].UpperBound;
- break;
- case LADSPA_HINT_DEFAULT_0:
- *val = 0;
- break;
- case LADSPA_HINT_DEFAULT_1:
- *val = 1;
- break;
- case LADSPA_HINT_DEFAULT_100:
- *val = 100;
- break;
- case LADSPA_HINT_DEFAULT_440:
- *val = 440;
- break;
- default:
- *val = 0; /* reasonable default, if everything fails */
- break;
- }
+ LADSPA_PortRangeHintDescriptor hdesc;
+
+ hdesc = desc->PortRangeHints[port].HintDescriptor;
+ switch (hdesc & LADSPA_HINT_DEFAULT_MASK) {
+ case LADSPA_HINT_DEFAULT_MINIMUM:
+ *val = desc->PortRangeHints[port].LowerBound;
+ break;
+ case LADSPA_HINT_DEFAULT_LOW:
+ if (LADSPA_IS_HINT_LOGARITHMIC(hdesc)) {
+ *val = exp(log(desc->PortRangeHints[port].LowerBound)
+ * 0.75
+ + log(desc->PortRangeHints[port].UpperBound)
+ * 0.25);
+ } else {
+ *val = (desc->PortRangeHints[port].LowerBound * 0.75) +
+ (desc->PortRangeHints[port].UpperBound * 0.25);
+ }
+ break;
+ case LADSPA_HINT_DEFAULT_MIDDLE:
+ if (LADSPA_IS_HINT_LOGARITHMIC(hdesc)) {
+ *val = sqrt(desc->PortRangeHints[port].LowerBound *
+ desc->PortRangeHints[port].UpperBound);
+ } else {
+ *val = 0.5 *
+ (desc->PortRangeHints[port].LowerBound +
+ desc->PortRangeHints[port].UpperBound);
+ }
+ break;
+ case LADSPA_HINT_DEFAULT_HIGH:
+ if (LADSPA_IS_HINT_LOGARITHMIC(hdesc)) {
+ *val = exp(log(desc->PortRangeHints[port].LowerBound)
+ * 0.25
+ + log(desc->PortRangeHints[port].UpperBound)
+ * 0.75);
+ } else {
+ *val = (desc->PortRangeHints[port].LowerBound * 0.25) +
+ (desc->PortRangeHints[port].UpperBound * 0.75);
+ }
+ break;
+ case LADSPA_HINT_DEFAULT_MAXIMUM:
+ *val = desc->PortRangeHints[port].UpperBound;
+ break;
+ case LADSPA_HINT_DEFAULT_0:
+ *val = 0;
+ break;
+ case LADSPA_HINT_DEFAULT_1:
+ *val = 1;
+ break;
+ case LADSPA_HINT_DEFAULT_100:
+ *val = 100;
+ break;
+ case LADSPA_HINT_DEFAULT_440:
+ *val = 440;
+ break;
+ default:
+ *val = 0; /* reasonable default, if everything fails */
+ break;
+ }
}
static int snd_pcm_ladspa_connect_controls(snd_pcm_ladspa_plugin_t *plugin,
for (idx = midx = 0; idx < plugin->desc->PortCount; idx++)
if ((plugin->desc->PortDescriptors[idx] & (io->pdesc | LADSPA_PORT_CONTROL)) == (io->pdesc | LADSPA_PORT_CONTROL)) {
if (io->controls_size > midx) {
- if (!io->controls_initialized[midx])
- snd_pcm_ladspa_get_default_cvalue(plugin->desc, idx, &io->controls[midx]);
+ if (!io->controls_initialized[midx])
+ snd_pcm_ladspa_get_default_cvalue(plugin->desc, idx, &io->controls[midx]);
plugin->desc->connect_port(instance->handle, idx, &io->controls[midx]);
} else {
return -EINVAL;
}
static int snd_pcm_ladspa_check_connect(snd_pcm_ladspa_plugin_t *plugin,
- snd_pcm_ladspa_plugin_io_t *io,
- snd_pcm_ladspa_eps_t *eps,
- unsigned int depth)
+ snd_pcm_ladspa_plugin_io_t *io,
+ snd_pcm_ladspa_eps_t *eps,
+ unsigned int depth)
{
- unsigned int idx, midx;
- int err = 0;
+ unsigned int idx, midx;
+ int err = 0;
for (idx = midx = 0; idx < plugin->desc->PortCount; idx++)
if ((plugin->desc->PortDescriptors[idx] & (io->pdesc | LADSPA_PORT_AUDIO)) == (io->pdesc | LADSPA_PORT_AUDIO)) {
- if (eps->channels.array[midx] == NO_ASSIGN) {
+ if (eps->channels.array[midx] == NO_ASSIGN) {
snd_error(PCM, "%s port for plugin %s depth %u is not connected", io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name, depth);
- err++;
- }
+ err++;
+ }
midx++;
}
- if (err > 0) {
+ if (err > 0) {
snd_error(PCM, "%i connection errors total", err);
- return -EINVAL;
- }
- return 0;
+ return -EINVAL;
+ }
+ return 0;
}
static int snd_pcm_ladspa_allocate_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *ladspa)
{
struct list_head *list, *pos;
unsigned int depth, idx, count;
- unsigned int in_channels;
+ unsigned int in_channels;
unsigned int in_ports, out_ports;
snd_pcm_ladspa_instance_t *instance = NULL;
int err;
-
+
list = pcm->stream == SND_PCM_STREAM_PLAYBACK ? &ladspa->pplugins : &ladspa->cplugins;
in_channels = ladspa->channels > 0 ? ladspa->channels :
- (pcm->stream == SND_PCM_STREAM_PLAYBACK ? pcm->channels : ladspa->plug.gen.slave->channels);
+ (pcm->stream == SND_PCM_STREAM_PLAYBACK ? pcm->channels : ladspa->plug.gen.slave->channels);
depth = 0;
list_for_each(pos, list) {
snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list);
- in_ports = snd_pcm_ladspa_count_ports(plugin, LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO);
- out_ports = snd_pcm_ladspa_count_ports(plugin, LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO);
+ in_ports = snd_pcm_ladspa_count_ports(plugin, LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO);
+ out_ports = snd_pcm_ladspa_count_ports(plugin, LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO);
count = 1;
if (plugin->policy == SND_PCM_LADSPA_POLICY_DUPLICATE) {
- if (in_ports == 1 && out_ports == 1)
- count = in_channels;
- else
- plugin->policy = SND_PCM_LADSPA_POLICY_NONE;
- }
- for (idx = 0; idx < count; idx++) {
+ if (in_ports == 1 && out_ports == 1)
+ count = in_channels;
+ else
+ plugin->policy = SND_PCM_LADSPA_POLICY_NONE;
+ }
+ for (idx = 0; idx < count; idx++) {
instance = (snd_pcm_ladspa_instance_t *)calloc(1, sizeof(snd_pcm_ladspa_instance_t));
if (instance == NULL)
return -ENOMEM;
return err;
}
} else {
- err = snd_pcm_ladspa_connect_plugin(plugin, instance);
- if (err < 0) {
+ err = snd_pcm_ladspa_connect_plugin(plugin, instance);
+ if (err < 0) {
snd_error(PCM, "Unable to connect plugin '%s' depth %u", plugin->desc->Name, depth);
- return err;
- }
+ return err;
+ }
}
err = snd_pcm_ladspa_connect_controls(plugin, &plugin->input, instance);
assert(err >= 0);
}
err = snd_pcm_ladspa_check_connect(plugin, &plugin->input, &instance->input, depth);
if (err < 0)
- return err;
+ return err;
err = snd_pcm_ladspa_check_connect(plugin, &plugin->output, &instance->output, depth);
if (err < 0)
- return err;
+ return err;
depth++;
}
return 0;
static LADSPA_Data *snd_pcm_ladspa_allocate_zero(snd_pcm_ladspa_t *ladspa, unsigned int idx)
{
- if (ladspa->zero[idx] == NULL)
- ladspa->zero[idx] = calloc(ladspa->allocated, sizeof(LADSPA_Data));
- return ladspa->zero[idx];
+ if (ladspa->zero[idx] == NULL)
+ ladspa->zero[idx] = calloc(ladspa->allocated, sizeof(LADSPA_Data));
+ return ladspa->zero[idx];
}
static int snd_pcm_ladspa_allocate_memory(snd_pcm_t *pcm, snd_pcm_ladspa_t *ladspa)
unsigned int ichannels, ochannels;
void **pchannels, **npchannels;
unsigned int idx, chn;
-
- ladspa->allocated = 2048;
- if (pcm->buffer_size > ladspa->allocated)
- ladspa->allocated = pcm->buffer_size;
- if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
- ichannels = pcm->channels;
- ochannels = ladspa->plug.gen.slave->channels;
- } else {
- ichannels = ladspa->plug.gen.slave->channels;
- ochannels = pcm->channels;
- }
+
+ ladspa->allocated = 2048;
+ if (pcm->buffer_size > ladspa->allocated)
+ ladspa->allocated = pcm->buffer_size;
+ if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
+ ichannels = pcm->channels;
+ ochannels = ladspa->plug.gen.slave->channels;
+ } else {
+ ichannels = ladspa->plug.gen.slave->channels;
+ ochannels = pcm->channels;
+ }
pchannels = calloc(1, sizeof(void *) * channels);
if (pchannels == NULL)
- return -ENOMEM;
+ return -ENOMEM;
list = pcm->stream == SND_PCM_STREAM_PLAYBACK ? &ladspa->pplugins : &ladspa->cplugins;
list_for_each(pos, list) {
snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list);
instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list);
nchannels = channels;
for (idx = 0; idx < instance->input.channels.size; idx++) {
- chn = instance->input.channels.array[idx];
- assert(instance->input.ports.array[idx] != NO_ASSIGN);
- if (chn >= nchannels)
- nchannels = chn + 1;
- }
+ chn = instance->input.channels.array[idx];
+ assert(instance->input.ports.array[idx] != NO_ASSIGN);
+ if (chn >= nchannels)
+ nchannels = chn + 1;
+ }
for (idx = 0; idx < instance->output.channels.size; idx++) {
- chn = instance->output.channels.array[idx];
- assert(instance->output.ports.array[idx] != NO_ASSIGN);
- if (chn >= nchannels)
- nchannels = chn + 1;
- }
- if (nchannels != channels) {
- npchannels = realloc(pchannels, nchannels * sizeof(void *));
- if (npchannels == NULL) {
- free(pchannels);
- return -ENOMEM;
- }
- for (idx = channels; idx < nchannels; idx++)
- npchannels[idx] = NULL;
- pchannels = npchannels;
- }
- assert(instance->input.data == NULL);
- assert(instance->input.m_data == NULL);
- assert(instance->output.data == NULL);
- assert(instance->output.m_data == NULL);
- instance->input.data = calloc(instance->input.channels.size, sizeof(void *));
- instance->input.m_data = calloc(instance->input.channels.size, sizeof(void *));
- instance->output.data = calloc(instance->output.channels.size, sizeof(void *));
- instance->output.m_data = calloc(instance->output.channels.size, sizeof(void *));
- if (instance->input.data == NULL ||
- instance->input.m_data == NULL ||
- instance->output.data == NULL ||
- instance->output.m_data == NULL) {
- free(pchannels);
- return -ENOMEM;
- }
+ chn = instance->output.channels.array[idx];
+ assert(instance->output.ports.array[idx] != NO_ASSIGN);
+ if (chn >= nchannels)
+ nchannels = chn + 1;
+ }
+ if (nchannels != channels) {
+ npchannels = realloc(pchannels, nchannels * sizeof(void *));
+ if (npchannels == NULL) {
+ free(pchannels);
+ return -ENOMEM;
+ }
+ for (idx = channels; idx < nchannels; idx++)
+ npchannels[idx] = NULL;
+ pchannels = npchannels;
+ }
+ assert(instance->input.data == NULL);
+ assert(instance->input.m_data == NULL);
+ assert(instance->output.data == NULL);
+ assert(instance->output.m_data == NULL);
+ instance->input.data = calloc(instance->input.channels.size, sizeof(void *));
+ instance->input.m_data = calloc(instance->input.channels.size, sizeof(void *));
+ instance->output.data = calloc(instance->output.channels.size, sizeof(void *));
+ instance->output.m_data = calloc(instance->output.channels.size, sizeof(void *));
+ if (instance->input.data == NULL ||
+ instance->input.m_data == NULL ||
+ instance->output.data == NULL ||
+ instance->output.m_data == NULL) {
+ free(pchannels);
+ return -ENOMEM;
+ }
for (idx = 0; idx < instance->input.channels.size; idx++) {
- chn = instance->input.channels.array[idx];
- if (pchannels[chn] == NULL && chn < ichannels) {
- instance->input.data[idx] = NULL;
- continue;
- }
- instance->input.data[idx] = pchannels[chn];
- if (instance->input.data[idx] == NULL) {
- instance->input.data[idx] = snd_pcm_ladspa_allocate_zero(ladspa, 0);
- if (instance->input.data[idx] == NULL) {
- free(pchannels);
- return -ENOMEM;
- }
- }
- }
- for (idx = 0; idx < instance->output.channels.size; idx++) {
- chn = instance->output.channels.array[idx];
- /* FIXME/OPTIMIZE: check if we can remove double alloc */
- /* if LADSPA plugin has no broken inplace */
- instance->output.data[idx] = malloc(sizeof(LADSPA_Data) * ladspa->allocated);
- if (instance->output.data[idx] == NULL) {
- free(pchannels);
- return -ENOMEM;
- }
- pchannels[chn] = instance->output.m_data[idx] = instance->output.data[idx];
- }
+ chn = instance->input.channels.array[idx];
+ if (pchannels[chn] == NULL && chn < ichannels) {
+ instance->input.data[idx] = NULL;
+ continue;
+ }
+ instance->input.data[idx] = pchannels[chn];
+ if (instance->input.data[idx] == NULL) {
+ instance->input.data[idx] = snd_pcm_ladspa_allocate_zero(ladspa, 0);
+ if (instance->input.data[idx] == NULL) {
+ free(pchannels);
+ return -ENOMEM;
+ }
+ }
+ }
+ for (idx = 0; idx < instance->output.channels.size; idx++) {
+ chn = instance->output.channels.array[idx];
+ /* FIXME/OPTIMIZE: check if we can remove double alloc */
+ /* if LADSPA plugin has no broken inplace */
+ instance->output.data[idx] = malloc(sizeof(LADSPA_Data) * ladspa->allocated);
+ if (instance->output.data[idx] == NULL) {
+ free(pchannels);
+ return -ENOMEM;
+ }
+ pchannels[chn] = instance->output.m_data[idx] = instance->output.data[idx];
+ }
}
}
/* OPTIMIZE: we have already allocated areas for ALSA output channels */
snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list);
list_for_each(pos1, &plugin->instances) {
instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list);
- for (idx = 0; idx < instance->output.channels.size; idx++) {
- chn = instance->output.channels.array[idx];
- if (instance->output.data[idx] == pchannels[chn]) {
+ for (idx = 0; idx < instance->output.channels.size; idx++) {
+ chn = instance->output.channels.array[idx];
+ if (instance->output.data[idx] == pchannels[chn]) {
free(instance->output.m_data[idx]);
instance->output.m_data[idx] = NULL;
- if (chn < ochannels) {
- instance->output.data[idx] = NULL;
- } else {
- instance->output.data[idx] = snd_pcm_ladspa_allocate_zero(ladspa, 1);
- if (instance->output.data[idx] == NULL) {
- free(pchannels);
- return -ENOMEM;
- }
- }
- }
- }
- }
- }
+ if (chn < ochannels) {
+ instance->output.data[idx] = NULL;
+ } else {
+ instance->output.data[idx] = snd_pcm_ladspa_allocate_zero(ladspa, 1);
+ if (instance->output.data[idx] == NULL) {
+ free(pchannels);
+ return -ENOMEM;
+ }
+ }
+ }
+ }
+ }
+ }
#if 0
- printf("zero[0] = %p\n", ladspa->zero[0]);
- printf("zero[1] = %p\n", ladspa->zero[1]);
+ printf("zero[0] = %p\n", ladspa->zero[0]);
+ printf("zero[1] = %p\n", ladspa->zero[1]);
list_for_each(pos, list) {
snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list);
list_for_each(pos1, &plugin->instances) {
instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list);
- for (idx = 0; idx < instance->input.channels.size; idx++)
- printf("%i:alloc-input%i: data = %p, m_data = %p\n", instance->depth, idx, instance->input.data[idx], instance->input.m_data[idx]);
- for (idx = 0; idx < instance->output.channels.size; idx++)
- printf("%i:alloc-output%i: data = %p, m_data = %p\n", instance->depth, idx, instance->output.data[idx], instance->output.m_data[idx]);
+ for (idx = 0; idx < instance->input.channels.size; idx++)
+ printf("%i:alloc-input%i: data = %p, m_data = %p\n", instance->depth, idx, instance->input.data[idx], instance->input.m_data[idx]);
+ for (idx = 0; idx < instance->output.channels.size; idx++)
+ printf("%i:alloc-output%i: data = %p, m_data = %p\n", instance->depth, idx, instance->output.data[idx], instance->output.m_data[idx]);
}
}
#endif
{
snd_pcm_ladspa_t *ladspa = pcm->private_data;
int err;
-
+
snd_pcm_ladspa_free_instances(pcm, ladspa, 1);
err = snd_pcm_ladspa_allocate_instances(pcm, ladspa);
if (err < 0) {
struct list_head *pos, *pos1;
LADSPA_Data *data;
unsigned int idx, chn, size1, size2;
-
+
if (size > *slave_sizep)
size = *slave_sizep;
- size2 = size;
+ size2 = size;
#if 0 /* no processing - for testing purposes only */
snd_pcm_areas_copy(slave_areas, slave_offset,
areas, offset,
pcm->channels, size, pcm->format);
#else
- while (size > 0) {
- size1 = size;
- if (size1 > ladspa->allocated)
- size1 = ladspa->allocated;
- list_for_each(pos, &ladspa->pplugins) {
- snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list);
- list_for_each(pos1, &plugin->instances) {
- instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list);
- for (idx = 0; idx < instance->input.channels.size; idx++) {
- chn = instance->input.channels.array[idx];
- data = instance->input.data[idx];
- if (data == NULL) {
- data = (LADSPA_Data *)((char *)areas[chn].addr + (areas[chn].first / 8));
- data += offset;
- }
- instance->desc->connect_port(instance->handle, instance->input.ports.array[idx], data);
- }
- for (idx = 0; idx < instance->output.channels.size; idx++) {
- chn = instance->output.channels.array[idx];
- data = instance->output.data[idx];
- if (data == NULL) {
- data = (LADSPA_Data *)((char *)slave_areas[chn].addr + (areas[chn].first / 8));
- data += slave_offset;
- }
+ while (size > 0) {
+ size1 = size;
+ if (size1 > ladspa->allocated)
+ size1 = ladspa->allocated;
+ list_for_each(pos, &ladspa->pplugins) {
+ snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list);
+ list_for_each(pos1, &plugin->instances) {
+ instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list);
+ for (idx = 0; idx < instance->input.channels.size; idx++) {
+ chn = instance->input.channels.array[idx];
+ data = instance->input.data[idx];
+ if (data == NULL) {
+ data = (LADSPA_Data *)((char *)areas[chn].addr + (areas[chn].first / 8));
+ data += offset;
+ }
+ instance->desc->connect_port(instance->handle, instance->input.ports.array[idx], data);
+ }
+ for (idx = 0; idx < instance->output.channels.size; idx++) {
+ chn = instance->output.channels.array[idx];
+ data = instance->output.data[idx];
+ if (data == NULL) {
+ data = (LADSPA_Data *)((char *)slave_areas[chn].addr + (areas[chn].first / 8));
+ data += slave_offset;
+ }
instance->desc->connect_port(instance->handle, instance->output.ports.array[idx], data);
- }
- instance->desc->run(instance->handle, size1);
- }
- }
- offset += size1;
- slave_offset += size1;
- size -= size1;
+ }
+ instance->desc->run(instance->handle, size1);
+ }
+ }
+ offset += size1;
+ slave_offset += size1;
+ size -= size1;
}
#endif
*slave_sizep = size2;
if (size > *slave_sizep)
size = *slave_sizep;
- size2 = size;
+ size2 = size;
#if 0 /* no processing - for testing purposes only */
snd_pcm_areas_copy(areas, offset,
slave_areas, slave_offset,
pcm->channels, size, pcm->format);
#else
- while (size > 0) {
- size1 = size;
- if (size1 > ladspa->allocated)
- size1 = ladspa->allocated;
- list_for_each(pos, &ladspa->cplugins) {
- snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list);
- list_for_each(pos1, &plugin->instances) {
- instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list);
- for (idx = 0; idx < instance->input.channels.size; idx++) {
- chn = instance->input.channels.array[idx];
- data = instance->input.data[idx];
- if (data == NULL) {
- data = (LADSPA_Data *)((char *)slave_areas[chn].addr + (areas[chn].first / 8));
- data += slave_offset;
- }
- instance->desc->connect_port(instance->handle, instance->input.ports.array[idx], data);
- }
- for (idx = 0; idx < instance->output.channels.size; idx++) {
- chn = instance->output.channels.array[idx];
- data = instance->output.data[idx];
- if (data == NULL) {
- data = (LADSPA_Data *)((char *)areas[chn].addr + (areas[chn].first / 8));
- data += offset;
- }
- instance->desc->connect_port(instance->handle, instance->output.ports.array[idx], data);
- }
- instance->desc->run(instance->handle, size1);
- }
- }
- offset += size1;
- slave_offset += size1;
- size -= size1;
+ while (size > 0) {
+ size1 = size;
+ if (size1 > ladspa->allocated)
+ size1 = ladspa->allocated;
+ list_for_each(pos, &ladspa->cplugins) {
+ snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list);
+ list_for_each(pos1, &plugin->instances) {
+ instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list);
+ for (idx = 0; idx < instance->input.channels.size; idx++) {
+ chn = instance->input.channels.array[idx];
+ data = instance->input.data[idx];
+ if (data == NULL) {
+ data = (LADSPA_Data *)((char *)slave_areas[chn].addr + (areas[chn].first / 8));
+ data += slave_offset;
+ }
+ instance->desc->connect_port(instance->handle, instance->input.ports.array[idx], data);
+ }
+ for (idx = 0; idx < instance->output.channels.size; idx++) {
+ chn = instance->output.channels.array[idx];
+ data = instance->output.data[idx];
+ if (data == NULL) {
+ data = (LADSPA_Data *)((char *)areas[chn].addr + (areas[chn].first / 8));
+ data += offset;
+ }
+ instance->desc->connect_port(instance->handle, instance->output.ports.array[idx], data);
+ }
+ instance->desc->run(instance->handle, size1);
+ }
+ }
+ offset += size1;
+ slave_offset += size1;
+ size -= size1;
}
#endif
*slave_sizep = size2;
}
static void snd_pcm_ladspa_dump_direction(snd_pcm_ladspa_plugin_t *plugin,
- snd_pcm_ladspa_plugin_io_t *io,
- snd_output_t *out)
+ snd_pcm_ladspa_plugin_io_t *io,
+ snd_output_t *out)
{
unsigned int idx, midx;
goto __control;
snd_output_printf(out, " Audio %s port bindings:\n", io->pdesc == LADSPA_PORT_INPUT ? "input" : "output");
for (idx = 0; idx < io->port_bindings_size; idx++) {
- if (io->port_bindings[idx] == NO_ASSIGN)
+ if (io->port_bindings[idx] == NO_ASSIGN)
snd_output_printf(out, " %i -> NONE\n", idx);
- else
- snd_output_printf(out, " %i -> %i\n", idx, io->port_bindings[idx]);
+ else
+ snd_output_printf(out, " %i -> %i\n", idx, io->port_bindings[idx]);
}
__control:
- if (io->controls_size == 0)
- return;
+ if (io->controls_size == 0)
+ return;
snd_output_printf(out, " Control %s port initial values:\n", io->pdesc == LADSPA_PORT_INPUT ? "input" : "output");
for (idx = midx = 0; idx < plugin->desc->PortCount; idx++) {
if ((plugin->desc->PortDescriptors[idx] & (io->pdesc | LADSPA_PORT_CONTROL)) == (io->pdesc | LADSPA_PORT_CONTROL)) {
- snd_output_printf(out, " %i \"%s\" = %.8f\n", idx, plugin->desc->PortNames[idx], io->controls[midx]);
- midx++;
- }
- }
+ snd_output_printf(out, " %i \"%s\" = %.8f\n", idx, plugin->desc->PortNames[idx], io->controls[midx]);
+ midx++;
+ }
+ }
}
static void snd_pcm_ladspa_dump_array(snd_output_t *out,
- snd_pcm_ladspa_array_t *array,
- snd_pcm_ladspa_plugin_t *plugin)
+ snd_pcm_ladspa_array_t *array,
+ snd_pcm_ladspa_plugin_t *plugin)
{
- unsigned int size = array->size;
- unsigned int val, idx = 0;
-
- while (size-- > 0) {
- if (idx > 0) {
- snd_output_putc(out, ',');
- snd_output_putc(out, ' ');
- }
- val = array->array[idx++];
- if (val == NO_ASSIGN)
- snd_output_putc(out, '-');
- else
- snd_output_printf(out, "%u", val);
- if (plugin && val != NO_ASSIGN)
- snd_output_printf(out, " \"%s\"", plugin->desc->PortNames[val]);
- }
+ unsigned int size = array->size;
+ unsigned int val, idx = 0;
+
+ while (size-- > 0) {
+ if (idx > 0) {
+ snd_output_putc(out, ',');
+ snd_output_putc(out, ' ');
+ }
+ val = array->array[idx++];
+ if (val == NO_ASSIGN)
+ snd_output_putc(out, '-');
+ else
+ snd_output_printf(out, "%u", val);
+ if (plugin && val != NO_ASSIGN)
+ snd_output_printf(out, " \"%s\"", plugin->desc->PortNames[val]);
+ }
}
static void snd_pcm_ladspa_plugins_dump(struct list_head *list, snd_output_t *out)
{
struct list_head *pos, *pos2;
-
+
list_for_each(pos, list) {
snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list);
snd_output_printf(out, " Policy: %s\n", plugin->policy == SND_PCM_LADSPA_POLICY_NONE ? "none" : "duplicate");
snd_output_printf(out, " Plugin Name: %s\n", plugin->desc->Name);
snd_output_printf(out, " Plugin Label: %s\n", plugin->desc->Label);
snd_output_printf(out, " Plugin Unique ID: %lu\n", plugin->desc->UniqueID);
- snd_output_printf(out, " Instances:\n");
+ snd_output_printf(out, " Instances:\n");
list_for_each(pos2, &plugin->instances) {
- snd_pcm_ladspa_instance_t *in = (snd_pcm_ladspa_instance_t *) pos2;
- snd_output_printf(out, " Depth: %i\n", in->depth);
- snd_output_printf(out, " InChannels: ");
- snd_pcm_ladspa_dump_array(out, &in->input.channels, NULL);
- snd_output_printf(out, "\n InPorts: ");
- snd_pcm_ladspa_dump_array(out, &in->input.ports, plugin);
- snd_output_printf(out, "\n OutChannels: ");
- snd_pcm_ladspa_dump_array(out, &in->output.channels, NULL);
- snd_output_printf(out, "\n OutPorts: ");
- snd_pcm_ladspa_dump_array(out, &in->output.ports, plugin);
- snd_output_printf(out, "\n");
+ snd_pcm_ladspa_instance_t *in = (snd_pcm_ladspa_instance_t *) pos2;
+ snd_output_printf(out, " Depth: %i\n", in->depth);
+ snd_output_printf(out, " InChannels: ");
+ snd_pcm_ladspa_dump_array(out, &in->input.channels, NULL);
+ snd_output_printf(out, "\n InPorts: ");
+ snd_pcm_ladspa_dump_array(out, &in->input.ports, plugin);
+ snd_output_printf(out, "\n OutChannels: ");
+ snd_pcm_ladspa_dump_array(out, &in->output.channels, NULL);
+ snd_output_printf(out, "\n OutPorts: ");
+ snd_pcm_ladspa_dump_array(out, &in->output.ports, plugin);
+ snd_output_printf(out, "\n");
}
snd_pcm_ladspa_dump_direction(plugin, &plugin->input, out);
snd_pcm_ladspa_dump_direction(plugin, &plugin->output, out);
if (strcmp(label, d->Label))
continue;
#else
- char *labellocale;
- struct lconv *lc;
- if (label != NULL) {
- lc = localeconv ();
- labellocale = malloc (strlen (label) + 1);
- if (labellocale == NULL) {
- dlclose(handle);
- return -ENOMEM;
+ char *labellocale;
+ struct lconv *lc;
+ if (label != NULL) {
+ lc = localeconv ();
+ labellocale = malloc (strlen (label) + 1);
+ if (labellocale == NULL) {
+ dlclose(handle);
+ return -ENOMEM;
+ }
+ strcpy (labellocale, label);
+ if (strrchr(labellocale, '.'))
+ *strrchr (labellocale, '.') = *lc->decimal_point;
+ if (strcmp(label, d->Label) && strcmp(labellocale, d->Label)) {
+ free(labellocale);
+ continue;
}
- strcpy (labellocale, label);
- if (strrchr(labellocale, '.'))
- *strrchr (labellocale, '.') = *lc->decimal_point;
- if (strcmp(label, d->Label) && strcmp(labellocale, d->Label)) {
- free(labellocale);
- continue;
- }
- free (labellocale);
- }
+ free (labellocale);
+ }
#endif
if (ladspa_id > 0 && d->UniqueID != ladspa_id)
continue;
int len = strlen(path), err;
int need_slash;
char *filename;
-
+
if (len < 1)
return 0;
need_slash = path[len - 1] != '/';
-
+
dir = opendir(path);
if (!dir)
return -ENOENT;
-
+
while (1) {
dirent = readdir64(dir);
if (!dirent) {
closedir(dir);
return 0;
}
-
+
filename = malloc(len + strlen(dirent->d_name) + 1 + need_slash);
if (filename == NULL) {
closedir(dir);
const char *c;
size_t l;
int err;
-
+
for (c = path; (l = strcspn(c, ": ")) > 0; ) {
char name[l + 1];
char *fullpath;
c++;
}
return -ENOENT;
-}
+}
static int snd_pcm_ladspa_add_default_controls(snd_pcm_ladspa_plugin_t *lplug,
- snd_pcm_ladspa_plugin_io_t *io)
+ snd_pcm_ladspa_plugin_io_t *io)
{
unsigned int count = 0;
LADSPA_Data *array;
io->controls = array;
return 0;
-}
+}
static int snd_pcm_ladspa_parse_controls(snd_pcm_ladspa_plugin_t *lplug,
snd_pcm_ladspa_plugin_io_t *io,
- snd_config_t *controls)
+ snd_config_t *controls)
{
snd_config_iterator_t i, next;
int err;
static int snd_pcm_ladspa_parse_bindings(snd_pcm_ladspa_plugin_t *lplug,
snd_pcm_ladspa_plugin_io_t *io,
- snd_config_t *bindings)
+ snd_config_t *bindings)
{
unsigned int count = 0;
unsigned int *array;
snd_error(PCM, "error adding default controls");
return err;
}
-
+
if (conf == NULL) {
return 0;
}
/* ignore values of parameters for output controls */
if (controls && !(io->pdesc & LADSPA_PORT_OUTPUT)) {
- err = snd_pcm_ladspa_parse_controls(lplug, io, controls);
- if (err < 0)
+ err = snd_pcm_ladspa_parse_controls(lplug, io, controls);
+ if (err < 0)
return err;
}
if (bindings) {
- err = snd_pcm_ladspa_parse_bindings(lplug, io, bindings);
- if (err < 0)
+ err = snd_pcm_ladspa_parse_bindings(lplug, io, bindings);
+ if (err < 0)
return err;
}
\code
pcm.name {
- type ladspa # ALSA<->LADSPA PCM
- slave STR # Slave name
- # or
- slave { # Slave definition
- pcm STR # Slave PCM name
- # or
- pcm { } # Slave PCM definition
- }
- [channels INT] # count input channels (input to LADSPA plugin chain)
+ type ladspa # ALSA<->LADSPA PCM
+ slave STR # Slave name
+ # or
+ slave { # Slave definition
+ pcm STR # Slave PCM name
+ # or
+ pcm { } # Slave PCM definition
+ }
+ [channels INT] # count input channels (input to LADSPA plugin chain)
[path STR] # Path (directory) with LADSPA plugins
plugins | # Definition for both directions
- playback_plugins | # Definition for playback direction
+ playback_plugins | # Definition for playback direction
capture_plugins { # Definition for capture direction
N { # Configuration for LADPSA plugin N
[id INT] # LADSPA plugin ID (for example 1043)
C INT or STR # C - channel, INT - audio port index, STR - audio port name
}
controls {
- # valid only in the input block
+ # valid only in the input block
I INT or REAL # I - control port index, INT or REAL - control value
# or
STR INT or REAL # STR - control port name, INT or REAL - control value
* changed in future.
*/
int _snd_pcm_ladspa_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;
if (strcmp(id, "channels") == 0) {
snd_config_get_integer(n, &channels);
if (channels > 1024)
- channels = 1024;
- if (channels < 0)
- channels = 0;
+ channels = 1024;
+ if (channels < 0)
+ channels = 0;
continue;
}
if (strcmp(id, "plugins") == 0) {
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
#include "plugin_ops.h"
return err;
return 0;
}
-
+
static int snd_pcm_lfloat_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
if (size > *slave_sizep)
size = *slave_sizep;
lfloat->func(slave_areas, slave_offset,
- areas, offset,
+ areas, offset,
pcm->channels, size,
lfloat->int32_idx, lfloat->float32_idx);
*slave_sizep = size;
snd_pcm_lfloat_t *lfloat = pcm->private_data;
if (size > *slave_sizep)
size = *slave_sizep;
- lfloat->func(areas, offset,
+ lfloat->func(areas, offset,
slave_areas, slave_offset,
pcm->channels, size,
lfloat->int32_idx, lfloat->float32_idx);
static void snd_pcm_lfloat_dump(snd_pcm_t *pcm, snd_output_t *out)
{
snd_pcm_lfloat_t *lfloat = pcm->private_data;
- snd_output_printf(out, "Linear Integer <-> Linear Float conversion PCM (%s)\n",
+ snd_output_printf(out, "Linear Integer <-> Linear Float conversion PCM (%s)\n",
snd_pcm_format_name(lfloat->sformat));
if (pcm->setup) {
snd_output_printf(out, "Its setup is:\n");
snd_pcm_set_hw_ptr(pcm, &lfloat->plug.hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &lfloat->plug.appl_ptr, -1, 0);
*pcmp = pcm;
-
+
return 0;
}
\code
pcm.name {
- type lfloat # Linear<->Float 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 lfloat # Linear<->Float 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
* changed in future.
*/
int _snd_pcm_lfloat_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;
int _snd_pcm_lfloat_open(snd_pcm_t **pcmp ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED,
snd_config_t *root ATTRIBUTE_UNUSED,
- snd_config_t *conf ATTRIBUTE_UNUSED,
+ snd_config_t *conf ATTRIBUTE_UNUSED,
snd_pcm_stream_t stream ATTRIBUTE_UNUSED,
int mode ATTRIBUTE_UNUSED)
{
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
#include "plugin_ops.h"
int snd_pcm_linear_get_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format)
{
int sign, width, pwidth, endian;
- sign = (snd_pcm_format_signed(src_format) !=
+ sign = (snd_pcm_format_signed(src_format) !=
snd_pcm_format_signed(dst_format));
#ifdef SND_LITTLE_ENDIAN
endian = snd_pcm_format_big_endian(src_format);
int snd_pcm_linear_put_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format)
{
int sign, width, pwidth, endian;
- sign = (snd_pcm_format_signed(src_format) !=
+ sign = (snd_pcm_format_signed(src_format) !=
snd_pcm_format_signed(dst_format));
#ifdef SND_LITTLE_ENDIAN
endian = snd_pcm_format_big_endian(dst_format);
return err;
return 0;
}
-
+
static int snd_pcm_linear_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
size = *slave_sizep;
if (linear->use_getput)
snd_pcm_linear_getput(slave_areas, slave_offset,
- areas, offset,
+ areas, offset,
pcm->channels, size,
linear->get_idx, linear->put_idx);
else
snd_pcm_linear_convert(slave_areas, slave_offset,
- areas, offset,
+ areas, offset,
pcm->channels, size, linear->conv_idx);
*slave_sizep = size;
return size;
if (size > *slave_sizep)
size = *slave_sizep;
if (linear->use_getput)
- snd_pcm_linear_getput(areas, offset,
+ snd_pcm_linear_getput(areas, offset,
slave_areas, slave_offset,
pcm->channels, size,
linear->get_idx, linear->put_idx);
else
- snd_pcm_linear_convert(areas, offset,
+ snd_pcm_linear_convert(areas, offset,
slave_areas, slave_offset,
pcm->channels, size, linear->conv_idx);
*slave_sizep = size;
static void snd_pcm_linear_dump(snd_pcm_t *pcm, snd_output_t *out)
{
snd_pcm_linear_t *linear = pcm->private_data;
- snd_output_printf(out, "Linear conversion PCM (%s)\n",
+ snd_output_printf(out, "Linear conversion PCM (%s)\n",
snd_pcm_format_name(linear->sformat));
if (pcm->setup) {
snd_output_printf(out, "Its setup is:\n");
\code
pcm.name {
- type linear # Linear 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 linear # Linear 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
* changed in future.
*/
int _snd_pcm_linear_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;
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);
-typedef snd_pcm_sframes_t (*snd_pcm_xfer_areas_func_t)(snd_pcm_t *pcm,
+typedef snd_pcm_sframes_t (*snd_pcm_xfer_areas_func_t)(snd_pcm_t *pcm,
const snd_pcm_channel_area_t *areas,
- snd_pcm_uframes_t offset,
+ snd_pcm_uframes_t offset,
snd_pcm_uframes_t size);
snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_t *areas,
static inline snd_pcm_uframes_t snd_pcm_mmap_offset(snd_pcm_t *pcm)
{
- assert(pcm);
+ assert(pcm);
return *pcm->appl.ptr % pcm->buffer_size;
}
static inline snd_pcm_uframes_t snd_pcm_mmap_hw_offset(snd_pcm_t *pcm)
{
- assert(pcm);
+ assert(pcm);
return *pcm->hw.ptr % pcm->buffer_size;
}
(1U << (SND_PCM_FORMAT_U18_3LE - 32)) | \
(1U << (SND_PCM_FORMAT_S18_3BE - 32)) | \
(1U << (SND_PCM_FORMAT_U18_3BE - 32))) }
-
+
#define SND_PCM_FMTBIT_FLOAT \
{ ((1U << SND_PCM_FORMAT_FLOAT_LE) | \
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
n = dst_cont;
if (n > src_cont)
n = src_cont;
- snd_pcm_areas_copy(meter->buf_areas, dst_offset,
+ snd_pcm_areas_copy(meter->buf_areas, dst_offset,
areas, src_offset,
pcm->channels, n, pcm->format);
frames -= n;
if (scope->enabled)
scope->ops->update(scope);
}
- nanosleep(&meter->delay, NULL);
+ nanosleep(&meter->delay, NULL);
}
list_for_each(pos, &meter->scopes) {
scope = list_entry(pos, snd_pcm_scope_t, list);
return err;
return 0;
}
-
+
static int snd_pcm_meter_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
}
pcm.name {
- type meter # Meter PCM
- slave STR # Slave name
- # or
- slave { # Slave definition
- pcm STR # Slave PCM name
- # or
- pcm { } # Slave PCM definition
- }
+ type meter # Meter PCM
+ slave STR # Slave name
+ # or
+ slave { # Slave definition
+ pcm STR # Slave PCM name
+ # or
+ pcm { } # Slave PCM definition
+ }
[frequency INT] # Updates per second
scopes {
ID STR # Scope name (see pcm_scope)
* changed in future.
*/
int _snd_pcm_meter_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;
* \param scopep Pointer to newly created and added scope
* \return 0 on success otherwise a negative error code
*
- * s16 pseudo scope convert #SND_PCM_TYPE_METER PCM frames in CPU endian
+ * s16 pseudo scope convert #SND_PCM_TYPE_METER PCM frames in CPU endian
* 16 bit frames for use with other scopes. Don't forget to insert it before
* and to not insert it more time (see #snd_pcm_meter_search_scope)
*/
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "bswap.h"
#include <stdio.h>
return bswap_64(u.i);
#endif
}
- case SNDRV_PCM_FORMAT_FLOAT_BE:
+ case SNDRV_PCM_FORMAT_FLOAT_BE:
{
union {
float f[2];
}
case SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE:
case SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE:
- return 0;
+ return 0;
case SNDRV_PCM_FORMAT_MU_LAW:
return 0x7f7f7f7f7f7f7f7fULL;
case SNDRV_PCM_FORMAT_A_LAW:
__snd_pcm_mmap_begin(pcm, &pcm_areas, &pcm_offset, &frames);
snd_pcm_areas_copy(pcm_areas, pcm_offset,
- areas, offset,
- pcm->channels,
+ areas, offset,
+ pcm->channels,
frames, pcm->format);
result = __snd_pcm_mmap_commit(pcm, pcm_offset, frames);
if (result < 0)
snd_pcm_uframes_t pcm_offset;
snd_pcm_uframes_t frames = size;
snd_pcm_sframes_t result;
-
+
__snd_pcm_mmap_begin(pcm, &pcm_areas, &pcm_offset, &frames);
snd_pcm_areas_copy(areas, offset,
pcm_areas, pcm_offset,
- pcm->channels,
+ pcm->channels,
frames, pcm->format);
result = __snd_pcm_mmap_commit(pcm, pcm_offset, frames);
if (result < 0)
} else
info->type = SND_PCM_AREA_LOCAL;
return 0;
-}
+}
int snd_pcm_mmap(snd_pcm_t *pcm)
{
size_t size;
unsigned int c1;
if (i->addr) {
- a->addr = i->addr;
- a->first = i->first;
- a->step = i->step;
- continue;
- }
- size = i->first + i->step * (pcm->buffer_size - 1) + pcm->sample_bits;
+ a->addr = i->addr;
+ a->first = i->first;
+ a->step = i->step;
+ continue;
+ }
+ size = i->first + i->step * (pcm->buffer_size - 1) + pcm->sample_bits;
for (c1 = c + 1; c1 < pcm->channels; ++c1) {
snd_pcm_channel_info_t *i1 = &pcm->mmap_channels[c1];
size_t s;
switch (i1->type) {
case SND_PCM_AREA_MMAP:
if (i1->u.mmap.fd != i->u.mmap.fd ||
- i1->u.mmap.offset != i->u.mmap.offset)
+ i1->u.mmap.offset != i->u.mmap.offset)
continue;
break;
case SND_PCM_AREA_SHM:
case SND_PCM_AREA_LOCAL:
if (pcm->access != SND_PCM_ACCESS_MMAP_INTERLEAVED &&
pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED)
- continue;
+ continue;
break;
default:
assert(0);
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_generic.h"
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
#include "plugin_ops.h"
return err;
return 0;
}
-
+
static int snd_pcm_mulaw_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
if (size > *slave_sizep)
size = *slave_sizep;
mulaw->func(slave_areas, slave_offset,
- areas, offset,
+ areas, offset,
pcm->channels, size,
mulaw->getput_idx);
*slave_sizep = size;
snd_pcm_mulaw_t *mulaw = pcm->private_data;
if (size > *slave_sizep)
size = *slave_sizep;
- mulaw->func(areas, offset,
+ mulaw->func(areas, offset,
slave_areas, slave_offset,
pcm->channels, size,
mulaw->getput_idx);
static void snd_pcm_mulaw_dump(snd_pcm_t *pcm, snd_output_t *out)
{
snd_pcm_mulaw_t *mulaw = pcm->private_data;
- snd_output_printf(out, "Mu-Law conversion PCM (%s)\n",
+ snd_output_printf(out, "Mu-Law conversion PCM (%s)\n",
snd_pcm_format_name(mulaw->sformat));
if (pcm->setup) {
snd_output_printf(out, "Its setup is:\n");
\code
pcm.name {
- type mulaw # Mu-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 mulaw # Mu-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
* changed in future.
*/
int _snd_pcm_mulaw_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;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_generic.h"
#include <stdio.h>
return err;
return 0;
}
-
+
static int snd_pcm_multi_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
unsigned int slave_idx ATTRIBUTE_UNUSED,
snd_pcm_hw_params_t *params,
for (i = 0; i < multi->slaves_count; ++i) {
/* Reset each slave, as well as in prepare */
err = snd_pcm_reset(multi->slaves[i].pcm);
- if (err < 0)
+ if (err < 0)
result = err;
}
multi->hw_ptr = multi->appl_ptr = 0;
* including the first one has to be relinked to the given master.
*/
static int snd_pcm_multi_link_slaves(snd_pcm_t *pcm, snd_pcm_t *master)
-{
+{
snd_pcm_multi_t *multi = pcm->private_data;
unsigned int i;
int err;
snd_pcm_multi_channel_t *c = &multi->channels[k];
if (c->slave_idx < 0)
continue;
- snd_output_printf(out, " %d: slave %d, channel %d\n",
+ snd_output_printf(out, " %d: slave %d, channel %d\n",
k, c->slave_idx, c->slave_channel);
}
if (pcm->setup) {
}
stream = slaves_pcm[0]->stream;
-
+
multi->slaves_count = slaves_count;
multi->master_slave = master_slave;
multi->slaves = calloc(slaves_count, sizeof(*multi->slaves));
\code
pcm.name {
- type multi # Multiple streams conversion PCM
- slaves { # Slaves definition
+ type multi # Multiple streams conversion PCM
+ slaves { # Slaves definition
ID STR # Slave PCM name
# or
ID {
pcm { } # Slave PCM definition
channels INT # Slave channels
}
- }
+ }
bindings { # Bindings table
N {
slave STR # Slave key
err = -EINVAL;
goto _free;
}
- if (schannel < 0 ||
+ if (schannel < 0 ||
(unsigned int) schannel >= slaves_channels[slave]) {
snd_error(PCM, "Invalid or missing schannel for channel %s", id);
err = -EINVAL;
channels_sidx[cchannel] = slave;
channels_schannel[cchannel] = schannel;
}
-
+
for (idx = 0; idx < slaves_count; ++idx) {
err = snd_pcm_open_slave(&slaves_pcm[idx], root,
slaves_conf[idx], stream, mode,
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
#include "bswap.h"
static snd_pcm_sframes_t snd_pcm_null_avail_update(snd_pcm_t *pcm)
{
snd_pcm_null_t *null = pcm->private_data;
- if (null->state == SND_PCM_STATE_PREPARED) {
- /* it is required to return the correct avail count for */
- /* the prepared stream, otherwise the start is not called */
- return snd_pcm_mmap_avail(pcm);
- }
+ if (null->state == SND_PCM_STATE_PREPARED) {
+ /* it is required to return the correct avail count for */
+ /* the prepared stream, otherwise the start is not called */
+ return snd_pcm_mmap_avail(pcm);
+ }
return pcm->buffer_size;
}
}
null->poll_fd = fd;
null->state = SND_PCM_STATE_OPEN;
-
+
err = snd_pcm_new(&pcm, SND_PCM_TYPE_NULL, name, stream, mode);
if (err < 0) {
close(fd);
\code
pcm.name {
- type null # Null PCM
+ type null # Null PCM
[chmap MAP] # Provide channel maps; MAP is a string array
}
\endcode
* changed in future.
*/
int _snd_pcm_null_open(snd_pcm_t **pcmp, const char *name,
- snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf,
+ snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
snd_config_iterator_t i, next;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#ifndef NDEBUG
params->info = ~0U;
}
-/* Return the value for field PAR if it's fixed in configuration space
+/* Return the value for field PAR if it's fixed in configuration space
defined by PARAMS. Return -EINVAL otherwise
*/
int snd_pcm_hw_param_get(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var,
}
return changed;
}
-
-/* Inside configuration space defined by PARAMS remove from PAR all
+
+/* Inside configuration space defined by PARAMS remove from PAR all
non integer values. Reduce configuration space accordingly.
Return -EINVAL if the configuration space is empty
*/
-int snd_pcm_hw_param_set_integer(snd_pcm_t *pcm,
+int snd_pcm_hw_param_set_integer(snd_pcm_t *pcm,
snd_pcm_hw_params_t *params,
snd_set_mode_t mode,
snd_pcm_hw_param_t var)
}
-/* Inside configuration space defined by PARAMS remove from PAR all
+/* Inside configuration space defined by PARAMS remove from PAR all
values > minimum. Reduce configuration space accordingly.
Return the minimum.
*/
-int snd_pcm_hw_param_set_first(snd_pcm_t *pcm,
- snd_pcm_hw_params_t *params,
+int snd_pcm_hw_param_set_first(snd_pcm_t *pcm,
+ snd_pcm_hw_params_t *params,
snd_pcm_hw_param_t var,
unsigned int *rval, int *dir)
{
}
-/* Inside configuration space defined by PARAMS remove from PAR all
+/* Inside configuration space defined by PARAMS remove from PAR all
values < maximum. Reduce configuration space accordingly.
Return the maximum.
*/
-int snd_pcm_hw_param_set_last(snd_pcm_t *pcm,
+int snd_pcm_hw_param_set_last(snd_pcm_t *pcm,
snd_pcm_hw_params_t *params,
snd_pcm_hw_param_t var,
unsigned int *rval, int *dir)
return changed;
}
-/* Inside configuration space defined by PARAMS remove from PAR all
+/* Inside configuration space defined by PARAMS remove from PAR all
values < VAL. Reduce configuration space accordingly.
Return new minimum or -EINVAL if the configuration space is empty
*/
return changed;
}
-/* Inside configuration space defined by PARAMS remove from PAR all
+/* Inside configuration space defined by PARAMS remove from PAR all
values >= VAL + 1. Reduce configuration space accordingly.
Return new maximum or -EINVAL if the configuration space is empty
*/
return changed;
}
-/* Inside configuration space defined by PARAMS remove from PAR all
+/* Inside configuration space defined by PARAMS remove from PAR all
values < MIN and all values > MAX. Reduce configuration space accordingly.
Return 0 or -EINVAL if the configuration space is empty
*/
assert(0);
return -EINVAL;
}
- err = _snd_pcm_hw_param_set_minmax(params, var,
+ err = _snd_pcm_hw_param_set_minmax(params, var,
*min, mindir ? *mindir : 0,
*max, maxdir ? *maxdir : 0);
if (err < 0)
return changed;
}
-/* Inside configuration space defined by PARAMS remove from PAR all
+/* Inside configuration space defined by PARAMS remove from PAR all
values != VAL. Reduce configuration space accordingly.
Return -EINVAL if the configuration space is empty
*/
dump_hw_params(params, "set_near", var, *val, err);
return err;
}
-
+
if (err >= 0) {
snd_pcm_hw_params_t params1;
if (min == saved_min && mindir == valdir)
Return the value found.
*/
int snd_pcm_hw_param_set_next(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
- snd_pcm_hw_param_t var,
+ snd_pcm_hw_param_t var,
unsigned int best, int bestdir,
unsigned int val, int *dir)
{
if (err >= 0)
err = snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_PERIOD_TIME, &max, &dir);
if (err >= 0 && (long)min < pcm->minperiodtime &&
- (long)max > pcm->minperiodtime) {
+ (long)max > pcm->minperiodtime) {
min = pcm->minperiodtime; dir = 1;
snd_pcm_hw_param_set_min(pcm, params, SND_CHANGE, SND_PCM_HW_PARAM_PERIOD_TIME, &min, &dir);
}
}
return changed;
}
-
+
#if 0
static void _snd_pcm_hw_param_copy(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var,
const snd_pcm_hw_params_t *src)
diff = -diff;
return diff * p->mul;
}
-
+
int snd_pcm_hw_strategy_simple_near_next_value(snd_pcm_hw_params_t *params,
snd_pcm_hw_param_t var,
int value, int *dir,
assert(0);
return UINT_MAX;
}
-
+
int snd_pcm_hw_strategy_simple_choices_next_value(snd_pcm_hw_params_t *params,
snd_pcm_hw_param_t var,
int value, int *dir,
i = *success;
_snd_pcm_hw_param_copy(&i, var, fail);
err = snd_pcm_hw_refine(pcm, &i);
- if (err == 0 &&
+ if (err == 0 &&
snd_pcm_hw_params_try_explain_failure1(pcm, fail, &i, depth - 1, out) < 0)
continue;
snd_output_printf(out, "%s: ", snd_pcm_hw_param_name(var));
.private_data = 0,
},
{
- .var = SND_PCM_HW_PARAM_SAMPLE_BITS,
+ .var = SND_PCM_HW_PARAM_SAMPLE_BITS,
.func = snd_pcm_hw_rule_sample_bits,
- .deps = { SND_PCM_HW_PARAM_FORMAT,
+ .deps = { SND_PCM_HW_PARAM_FORMAT,
SND_PCM_HW_PARAM_SAMPLE_BITS, -1 },
.private_data = 0,
},
{
- .var = SND_PCM_HW_PARAM_SAMPLE_BITS,
+ .var = SND_PCM_HW_PARAM_SAMPLE_BITS,
.func = snd_pcm_hw_rule_div,
.deps = { SND_PCM_HW_PARAM_FRAME_BITS,
SND_PCM_HW_PARAM_CHANNELS, -1 },
.private_data = 0,
},
{
- .var = SND_PCM_HW_PARAM_FRAME_BITS,
+ .var = SND_PCM_HW_PARAM_FRAME_BITS,
.func = snd_pcm_hw_rule_mul,
.deps = { SND_PCM_HW_PARAM_SAMPLE_BITS,
SND_PCM_HW_PARAM_CHANNELS, -1 },
.private_data = 0,
},
{
- .var = SND_PCM_HW_PARAM_FRAME_BITS,
+ .var = SND_PCM_HW_PARAM_FRAME_BITS,
.func = snd_pcm_hw_rule_mulkdiv,
.deps = { SND_PCM_HW_PARAM_PERIOD_BYTES,
SND_PCM_HW_PARAM_PERIOD_SIZE, -1 },
.private_data = (void*) 8,
},
{
- .var = SND_PCM_HW_PARAM_FRAME_BITS,
+ .var = SND_PCM_HW_PARAM_FRAME_BITS,
.func = snd_pcm_hw_rule_mulkdiv,
.deps = { SND_PCM_HW_PARAM_BUFFER_BYTES,
SND_PCM_HW_PARAM_BUFFER_SIZE, -1 },
.private_data = (void*) 8,
},
{
- .var = SND_PCM_HW_PARAM_CHANNELS,
+ .var = SND_PCM_HW_PARAM_CHANNELS,
.func = snd_pcm_hw_rule_div,
.deps = { SND_PCM_HW_PARAM_FRAME_BITS,
SND_PCM_HW_PARAM_SAMPLE_BITS, -1 },
.private_data = 0,
},
{
- .var = SND_PCM_HW_PARAM_RATE,
+ .var = SND_PCM_HW_PARAM_RATE,
.func = snd_pcm_hw_rule_mulkdiv,
.deps = { SND_PCM_HW_PARAM_PERIOD_SIZE,
SND_PCM_HW_PARAM_PERIOD_TIME, -1 },
.private_data = (void*) 1000000,
},
{
- .var = SND_PCM_HW_PARAM_RATE,
+ .var = SND_PCM_HW_PARAM_RATE,
.func = snd_pcm_hw_rule_mulkdiv,
.deps = { SND_PCM_HW_PARAM_BUFFER_SIZE,
SND_PCM_HW_PARAM_BUFFER_TIME, -1 },
.private_data = (void*) 1000000,
},
{
- .var = SND_PCM_HW_PARAM_PERIODS,
+ .var = SND_PCM_HW_PARAM_PERIODS,
.func = snd_pcm_hw_rule_div,
.deps = { SND_PCM_HW_PARAM_BUFFER_SIZE,
SND_PCM_HW_PARAM_PERIOD_SIZE, -1 },
.private_data = 0,
},
{
- .var = SND_PCM_HW_PARAM_PERIOD_SIZE,
+ .var = SND_PCM_HW_PARAM_PERIOD_SIZE,
.func = snd_pcm_hw_rule_div,
.deps = { SND_PCM_HW_PARAM_BUFFER_SIZE,
SND_PCM_HW_PARAM_PERIODS, -1 },
.private_data = 0,
},
{
- .var = SND_PCM_HW_PARAM_PERIOD_SIZE,
+ .var = SND_PCM_HW_PARAM_PERIOD_SIZE,
.func = snd_pcm_hw_rule_mulkdiv,
.deps = { SND_PCM_HW_PARAM_PERIOD_BYTES,
SND_PCM_HW_PARAM_FRAME_BITS, -1 },
.private_data = (void*) 8,
},
{
- .var = SND_PCM_HW_PARAM_PERIOD_SIZE,
+ .var = SND_PCM_HW_PARAM_PERIOD_SIZE,
.func = snd_pcm_hw_rule_muldivk,
.deps = { SND_PCM_HW_PARAM_PERIOD_TIME,
SND_PCM_HW_PARAM_RATE, -1 },
.private_data = (void*) 1000000,
},
{
- .var = SND_PCM_HW_PARAM_BUFFER_SIZE,
+ .var = SND_PCM_HW_PARAM_BUFFER_SIZE,
.func = snd_pcm_hw_rule_mul,
.deps = { SND_PCM_HW_PARAM_PERIOD_SIZE,
SND_PCM_HW_PARAM_PERIODS, -1 },
.private_data = 0,
},
{
- .var = SND_PCM_HW_PARAM_BUFFER_SIZE,
+ .var = SND_PCM_HW_PARAM_BUFFER_SIZE,
.func = snd_pcm_hw_rule_mulkdiv,
.deps = { SND_PCM_HW_PARAM_BUFFER_BYTES,
SND_PCM_HW_PARAM_FRAME_BITS, -1 },
.private_data = (void*) 8,
},
{
- .var = SND_PCM_HW_PARAM_BUFFER_SIZE,
+ .var = SND_PCM_HW_PARAM_BUFFER_SIZE,
.func = snd_pcm_hw_rule_muldivk,
.deps = { SND_PCM_HW_PARAM_BUFFER_TIME,
SND_PCM_HW_PARAM_RATE, -1 },
.private_data = (void*) 1000000,
},
{
- .var = SND_PCM_HW_PARAM_PERIOD_BYTES,
+ .var = SND_PCM_HW_PARAM_PERIOD_BYTES,
.func = snd_pcm_hw_rule_muldivk,
.deps = { SND_PCM_HW_PARAM_PERIOD_SIZE,
SND_PCM_HW_PARAM_FRAME_BITS, -1 },
.private_data = (void*) 8,
},
{
- .var = SND_PCM_HW_PARAM_BUFFER_BYTES,
+ .var = SND_PCM_HW_PARAM_BUFFER_BYTES,
.func = snd_pcm_hw_rule_muldivk,
.deps = { SND_PCM_HW_PARAM_BUFFER_SIZE,
SND_PCM_HW_PARAM_FRAME_BITS, -1 },
.private_data = (void*) 8,
},
{
- .var = SND_PCM_HW_PARAM_PERIOD_TIME,
+ .var = SND_PCM_HW_PARAM_PERIOD_TIME,
.func = snd_pcm_hw_rule_mulkdiv,
.deps = { SND_PCM_HW_PARAM_PERIOD_SIZE,
SND_PCM_HW_PARAM_RATE, -1 },
.private_data = (void*) 1000000,
},
{
- .var = SND_PCM_HW_PARAM_BUFFER_TIME,
+ .var = SND_PCM_HW_PARAM_BUFFER_TIME,
.func = snd_pcm_hw_rule_mulkdiv,
.deps = { SND_PCM_HW_PARAM_BUFFER_SIZE,
SND_PCM_HW_PARAM_RATE, -1 },
},
},
};
-
+
static const snd_interval_t refine_intervals[SND_PCM_HW_PARAM_LAST_INTERVAL - SND_PCM_HW_PARAM_FIRST_INTERVAL + 1] = {
[SND_PCM_HW_PARAM_SAMPLE_BITS - SND_PCM_HW_PARAM_FIRST_INTERVAL] = {
.min = 1, .max = UINT_MAX,
min_align *= 2;
}
pcm->min_align = min_align;
-
+
pcm->hw_flags = params->flags;
pcm->info = params->info;
pcm->msbits = params->msbits;
pcm->rate_num = params->rate_num;
pcm->rate_den = params->rate_den;
pcm->fifo_size = params->fifo_size;
-
+
/* Default sw params */
memset(&sw, 0, sizeof(sw));
err = snd_pcm_sw_params_default(pcm, &sw);
if (err < 0)
return err;
- if (pcm->mmap_rw ||
+ if (pcm->mmap_rw ||
pcm->access == SND_PCM_ACCESS_MMAP_INTERLEAVED ||
pcm->access == SND_PCM_ACCESS_MMAP_NONINTERLEAVED ||
pcm->access == SND_PCM_ACCESS_MMAP_COMPLEX) {
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
snd_pcm_plug_t *plug = pcm->private_data;
snd_pcm_t *slave = plug->req_slave;
int err;
-
+
if ((err = snd_pcm_info(slave, info)) < 0)
return err;
return 0;
{
snd_pcm_plug_t *plug = pcm->private_data;
int err;
-
+
_snd_pcm_hw_params_any(sparams);
if (plug->sformat >= 0) {
_snd_pcm_hw_params_set_format(sparams, plug->sformat);
/* no mmap support - we need mmap emulation */
if (!snd_pcm_access_mask_test(smask, SND_PCM_ACCESS_RW_INTERLEAVED) &&
- !snd_pcm_access_mask_test(smask, SND_PCM_ACCESS_RW_NONINTERLEAVED))
+ !snd_pcm_access_mask_test(smask, SND_PCM_ACCESS_RW_NONINTERLEAVED))
return -EINVAL; /* even no RW access? no way! */
cmask = (const snd_pcm_access_mask_t *)
if (err < 0)
return err;
}
-
+
if (plug->schannels == -2 || (pcm->mode & SND_PCM_NO_AUTO_CHANNELS))
links |= SND_PCM_HW_PARBIT_CHANNELS;
else {
return err;
return 0;
}
-
+
static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
}
return -EINVAL;
}
-
- err = _snd_pcm_hw_param_set_mask(params,
+
+ err = _snd_pcm_hw_param_set_mask(params,
SND_PCM_HW_PARAM_FORMAT, &fmt_mask);
if (err < 0)
return err;
else {
unsigned int rate_min, srate_min;
int rate_mindir, srate_mindir;
-
+
/* This is a temporary hack, waiting for a better solution */
err = snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_RATE, &rate_min, &rate_mindir);
if (err < 0)
plug->tt_ssize = tt_ssize;
plug->tt_cused = tt_cused;
plug->tt_sused = tt_sused;
-
+
err = snd_pcm_new(&pcm, SND_PCM_TYPE_PLUG, name, slave->stream, slave->mode);
if (err < 0) {
free(plug);
\code
pcm.name {
- type plug # Automatic conversion PCM
- slave STR # Slave name
- # or
- slave { # Slave definition
- pcm STR # Slave PCM name
- # or
- pcm { } # Slave PCM definition
+ type plug # Automatic conversion PCM
+ slave STR # Slave name
+ # or
+ slave { # Slave definition
+ pcm STR # Slave PCM name
+ # or
+ pcm { } # Slave PCM definition
[format STR] # Slave format (default nearest) or "unchanged"
[channels INT] # Slave channels (default nearest) or "unchanged"
[rate INT] # Slave rate (default nearest) or "unchanged"
- }
+ }
route_policy STR # route policy for automatic ttable generation
# STR can be 'default', 'average', 'copy', 'duplicate'
# average: result is average of input channels
* changed in future.
*/
int _snd_pcm_plug_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;
}
}
#endif
-
+
#ifdef BUILD_PCM_PLUGIN_RATE
if (! rate_converter)
rate_converter = snd_pcm_rate_get_default_converter(root);
\endcode
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
#include <limits.h>
frames = n;
if (frames == 0)
return 0;
-
- sframes = frames;
+
+ sframes = frames;
sframes = snd_pcm_rewind(plugin->gen.slave, sframes);
if (sframes < 0)
return sframes;
frames = n;
if (frames == 0)
return 0;
-
- sframes = frames;
+
+ sframes = frames;
sframes = INTERNAL(snd_pcm_forward)(plugin->gen.slave, sframes);
if (sframes < 0)
return sframes;
const snd_pcm_channel_area_t *slave_areas;
snd_pcm_uframes_t slave_offset;
snd_pcm_uframes_t slave_frames = ULONG_MAX;
-
+
result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
if (result < 0) {
err = result;
snd_pcm_uframes_t xfer = 0;
snd_pcm_sframes_t result;
int err;
-
+
while (size > 0) {
snd_pcm_uframes_t frames = size;
const snd_pcm_channel_area_t *slave_areas;
snd_pcm_uframes_t slave_offset;
snd_pcm_uframes_t slave_frames = ULONG_MAX;
-
+
result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
if (result < 0) {
err = result;
result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
if (result > 0 && (snd_pcm_uframes_t)result != slave_frames) {
snd_pcm_sframes_t res;
-
+
res = plugin->undo_read(slave, areas, offset, frames, slave_frames - result);
if (res < 0) {
err = res;
{
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,
snd_pcm_plugin_write_areas);
}
result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
if (result > 0 && (snd_pcm_uframes_t)result != slave_frames) {
snd_pcm_sframes_t res;
-
+
res = plugin->undo_write(pcm, slave_areas, slave_offset + result, slave_frames, slave_frames - result);
if (res < 0) {
err = res;
pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED &&
pcm->access != SND_PCM_ACCESS_RW_NONINTERLEAVED)
return snd_pcm_plugin_sync_hw_ptr_capture(pcm, slave_size);
- *pcm->hw.ptr = slave_hw_ptr;
- return slave_size;
+ *pcm->hw.ptr = slave_hw_ptr;
+ return slave_size;
}
static snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_generic.h"
typedef snd_pcm_uframes_t (*snd_pcm_slave_xfer_areas_func_t)
- (snd_pcm_t *pcm,
+ (snd_pcm_t *pcm,
const snd_pcm_channel_area_t *areas,
- snd_pcm_uframes_t offset,
+ snd_pcm_uframes_t offset,
snd_pcm_uframes_t size,
const snd_pcm_channel_area_t *slave_areas,
- snd_pcm_uframes_t slave_offset,
+ snd_pcm_uframes_t slave_offset,
snd_pcm_uframes_t *slave_sizep);
typedef snd_pcm_sframes_t (*snd_pcm_slave_xfer_areas_undo_func_t)
snd_pcm_slave_xfer_areas_undo_func_t undo_write;
int (*init)(snd_pcm_t *pcm);
snd_pcm_uframes_t appl_ptr, hw_ptr;
-} snd_pcm_plugin_t;
+} snd_pcm_plugin_t;
/* make local functions really local */
#define snd_pcm_plugin_init \
return err;
return 0;
}
-
+
static int snd_pcm_rate_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
period_size->openmin && period_size->openmax &&
period_size->min + 1 == period_size->max) {
if (period_size->min > 0 && (buffer_size->min / period_size->min) * period_size->min == buffer_size->min) {
- snd_interval_set_value(period_size, period_size->min);
- } else if ((buffer_size->max / period_size->max) * period_size->max == buffer_size->max) {
- snd_interval_set_value(period_size, period_size->max);
- }
+ snd_interval_set_value(period_size, period_size->min);
+ } else if ((buffer_size->max / period_size->max) * period_size->max == buffer_size->max) {
+ snd_interval_set_value(period_size, period_size->max);
+ }
}
}
#ifdef DEBUG_REFINE
return 0;
}
-static int snd_pcm_rate_hw_refine(snd_pcm_t *pcm,
+static int snd_pcm_rate_hw_refine(snd_pcm_t *pcm,
snd_pcm_hw_params_t *params)
{
return snd_pcm_hw_refine_slave(pcm, params,
}
static snd_pcm_sframes_t snd_pcm_rate_rewind(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
- snd_pcm_uframes_t frames ATTRIBUTE_UNUSED)
+ snd_pcm_uframes_t frames ATTRIBUTE_UNUSED)
{
- return 0;
+ return 0;
}
static snd_pcm_sframes_t snd_pcm_rate_forward(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
- snd_pcm_uframes_t frames ATTRIBUTE_UNUSED)
+ snd_pcm_uframes_t frames ATTRIBUTE_UNUSED)
{
- return 0;
+ return 0;
}
static int snd_pcm_rate_commit_area(snd_pcm_t *pcm, snd_pcm_rate_t *rate,
if (xfer == slave_size)
goto commit_done;
-
+
/* commit second fragment */
cont = slave_size - cont;
slave_frames = cont;
}
#endif
snd_pcm_areas_copy(rate->sareas, xfer,
- slave_areas, slave_offset,
+ slave_areas, slave_offset,
pcm->channels, cont,
rate->gen.slave->format);
result = snd_pcm_mmap_commit(rate->gen.slave, slave_offset, cont);
snd_pcm_rate_t *rate = pcm->private_data;
snd_pcm_t *slave = rate->gen.slave;
snd_pcm_uframes_t xfer, hw_offset, size;
-
+
xfer = snd_pcm_mmap_capture_avail(pcm);
size = pcm->buffer_size - xfer;
hw_offset = snd_pcm_mmap_hw_offset(pcm);
{
snd_pcm_rate_t *rate = pcm->private_data;
snd_pcm_sframes_t avail;
-
+
if (pcm->stream == SND_PCM_STREAM_CAPTURE)
return snd_pcm_start(rate->gen.slave);
{
snd_pcm_rate_t *rate = pcm->private_data;
if (rate->sformat == SND_PCM_FORMAT_UNKNOWN)
- snd_output_printf(out, "Rate conversion PCM (%d)\n",
+ snd_output_printf(out, "Rate conversion PCM (%d)\n",
rate->srate);
else
- snd_output_printf(out, "Rate conversion PCM (%d, sformat=%s)\n",
+ snd_output_printf(out, "Rate conversion PCM (%d, sformat=%s)\n",
rate->srate,
snd_pcm_format_name(rate->sformat));
if (rate->ops.dump)
\code
pcm.name {
type rate # Rate PCM
- slave STR # Slave name
- # or
- slave { # Slave definition
- pcm STR # Slave PCM name
- # or
- pcm { } # Slave PCM definition
- rate INT # Slave rate
- [format STR] # Slave format
- }
+ slave STR # Slave name
+ # or
+ slave { # Slave definition
+ pcm STR # Slave PCM name
+ # or
+ pcm { } # Slave PCM definition
+ rate INT # Slave rate
+ [format STR] # Slave format
+ }
converter STR # optional
# or
converter [ STR1 STR2 ... ] # optional
* changed in future.
*/
int _snd_pcm_rate_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;
return err;
if (sformat != SND_PCM_FORMAT_UNKNOWN &&
snd_pcm_format_linear(sformat) != 1) {
- snd_config_delete(sconf);
+ snd_config_delete(sconf);
snd_error(PCM, "slave format is not linear");
return -EINVAL;
}
/*
* Linear rate converter plugin
- *
+ *
* Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org>
* 2004 by Jaroslav Kysela <perex@perex.cz>
* 2006 by Takashi Iwai <tiwai@suse.de>
unsigned int dst_frames1;
int16_t sample = 0;
unsigned int pos;
-
+
for (channel = 0; channel < rate->channels; ++channel) {
const snd_pcm_channel_area_t *src_area = &src_areas[channel];
const snd_pcm_channel_area_t *dst_area = &dst_areas[channel];
src += src_step;
src_frames1++;
}
- }
+ }
rate->old_sample[channel] = new_sample;
}
}
unsigned int dst_frames1;
unsigned int get_threshold = rate->pitch;
unsigned int pos;
-
+
for (channel = 0; channel < rate->channels; ++channel) {
const snd_pcm_channel_area_t *src_area = &src_areas[channel];
const snd_pcm_channel_area_t *dst_area = &dst_areas[channel];
src += src_step;
src_frames1++;
}
- }
+ }
rate->old_sample[channel] = new_sample;
}
}
src_frames1 = 0;
dst_frames1 = 0;
while (src_frames1 < src_frames) {
-
+
goto *get;
#define GET16_END after_get
#include "plugin_ops.h"
src_frames1 = 0;
dst_frames1 = 0;
while (src_frames1 < src_frames) {
-
+
new_sample = *src;
src += src_step;
src_frames1++;
}
}
-static void linear_convert(void *obj,
+static void linear_convert(void *obj,
const snd_pcm_channel_area_t *dst_areas,
snd_pcm_uframes_t dst_offset, unsigned int dst_frames,
const snd_pcm_channel_area_t *src_areas,
rate->pitch = (((uint64_t)info->out.period_size * LINEAR_DIV) +
(info->in.period_size/2) ) / info->in.period_size;
-
+
cframes = input_frames(rate, info->out.period_size);
while (cframes != info->in.period_size) {
snd_pcm_uframes_t cframes_new;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include "pcm_plugin.h"
#include "plugin_ops.h"
frames, ttable, params);
return;
}
-
+
conv = conv_labels[params->conv_idx];
src = snd_pcm_channel_area_addr(src_area, src_offset);
dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
frames, ttable, params);
return;
}
-
+
get = get32_labels[params->get_idx];
put = put32_labels[params->put_idx];
src = snd_pcm_channel_area_addr(src_area, src_offset);
/* Zero sum */
goto *zero;
- zero_int64:
+ zero_int64:
sum.as_sint64 = 0;
goto zero_end;
#if SND_PCM_PLUGIN_ROUTE_FLOAT
zero_end:
for (srcidx = 0; srcidx < nsrcs; ++srcidx) {
const char *src = srcs[srcidx];
-
+
/* Get sample */
goto *get32;
#define GET32_END after_get
srcs[srcidx] += src_steps[srcidx];
ttp++;
}
-
+
/* Normalization */
goto *norm;
norm_int64_att:
goto after_norm;
#endif
after_norm:
-
+
/* Put sample */
goto *put32;
#define PUT32_END after_put32
#include "plugin_ops.h"
#undef PUT32_END
after_put32:
-
+
dst += dst_step;
}
}
SND_PCM_HW_PARBIT_BUFFER_TIME |
SND_PCM_HW_PARBIT_TICK_TIME);
if (route->sformat == SND_PCM_FORMAT_UNKNOWN)
- links |= (SND_PCM_HW_PARBIT_FORMAT |
+ links |= (SND_PCM_HW_PARBIT_FORMAT |
SND_PCM_HW_PARBIT_SUBFORMAT |
SND_PCM_HW_PARBIT_SAMPLE_BITS);
if (route->schannels < 0)
return err;
return 0;
}
-
+
static int snd_pcm_route_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
SND_PCM_HW_PARBIT_BUFFER_TIME |
SND_PCM_HW_PARBIT_TICK_TIME);
if (route->sformat == SND_PCM_FORMAT_UNKNOWN)
- links |= (SND_PCM_HW_PARBIT_FORMAT |
+ links |= (SND_PCM_HW_PARBIT_FORMAT |
SND_PCM_HW_PARBIT_SUBFORMAT |
SND_PCM_HW_PARBIT_SAMPLE_BITS);
if (route->schannels < 0)
if (size > *slave_sizep)
size = *slave_sizep;
snd_pcm_route_convert(slave_areas, slave_offset,
- areas, offset,
+ areas, offset,
pcm->channels,
slave->channels,
size, &route->params);
snd_pcm_t *slave = route->plug.gen.slave;
if (size > *slave_sizep)
size = *slave_sizep;
- snd_pcm_route_convert(areas, offset,
+ snd_pcm_route_convert(areas, offset,
slave_areas, slave_offset,
slave->channels,
pcm->channels,
if (route->sformat == SND_PCM_FORMAT_UNKNOWN)
snd_output_printf(out, "Route conversion PCM\n");
else
- snd_output_printf(out, "Route conversion PCM (sformat=%s)\n",
+ snd_output_printf(out, "Route conversion PCM (sformat=%s)\n",
snd_pcm_format_name(route->sformat));
snd_output_puts(out, " Transformation table:\n");
for (dst = 0; dst < route->params.ndsts; dst++) {
snd_pcm_route_t *route;
int err;
assert(pcmp && slave && ttable);
- if (sformat != SND_PCM_FORMAT_UNKNOWN &&
+ if (sformat != SND_PCM_FORMAT_UNKNOWN &&
snd_pcm_format_linear(sformat) != 1)
return -EINVAL;
route = calloc(1, sizeof(snd_pcm_route_t));
if (snd_config_get_id(in, &id) < 0)
continue;
err = safe_strtol(id, &cchannel);
- if (err < 0 ||
+ if (err < 0 ||
cchannel < 0 || (unsigned int) cchannel > tt_csize) {
snd_error(PCM, "Invalid client channel: %s", id);
return -EINVAL;
\code
pcm.name {
- type route # Route & Volume conversion PCM
- slave STR # Slave name
- # or
- slave { # Slave definition
- pcm STR # Slave PCM name
- # or
- pcm { } # Slave PCM definition
- [format STR] # Slave format
- [channels INT] # Slave channels
- }
- ttable { # Transfer table (bi-dimensional compound of cchannels * schannels numbers)
- CCHANNEL {
- SCHANNEL REAL # route value (0.0 - 1.0)
- }
- }
- [chmap MAP] # Override channel maps; MAP is a string array
+ type route # Route & Volume conversion PCM
+ slave STR # Slave name
+ # or
+ slave { # Slave definition
+ pcm STR # Slave PCM name
+ # or
+ pcm { } # Slave PCM definition
+ [format STR] # Slave format
+ [channels INT] # Slave channels
+ }
+ ttable { # Transfer table (bi-dimensional compound of cchannels * schannels numbers)
+ CCHANNEL {
+ SCHANNEL REAL # route value (0.0 - 1.0)
+ }
+ }
+ [chmap MAP] # Override channel maps; MAP is a string array
}
\endcode
* changed in future.
*/
int _snd_pcm_route_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;
}
if (sformat != SND_PCM_FORMAT_UNKNOWN &&
snd_pcm_format_linear(sformat) != 1) {
- snd_config_delete(sconf);
+ snd_config_delete(sconf);
snd_error(PCM, "slave format is not linear");
snd_pcm_free_chmaps(chmaps);
return -EINVAL;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
{
snd_pcm_sframes_t avail;
snd_pcm_t *pcm = slave->pcm;
- avail = slave->hw_ptr - *pcm->appl.ptr;
+ avail = slave->hw_ptr - *pcm->appl.ptr;
if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
avail += pcm->buffer_size;
if (avail < 0)
}
-/*
+/*
- stop PCM on xrun
- update poll status
- draining silencing
return err;
return 0;
}
-
+
static int snd_pcm_share_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
if (err < 0)
goto _err;
err = _snd_pcm_hw_param_set_minmax(params, SND_PCM_HW_PARAM_RATE,
- spcm->rate, 0,
+ spcm->rate, 0,
spcm->rate, 1);
if (err < 0)
goto _err;
assert(0);
break;
}
-
+
share->appl_ptr = share->hw_ptr = 0;
_end:
Pthread_mutex_unlock(&slave->mutex);
free(share);
return -errno;
}
-
+
if (stream == SND_PCM_STREAM_PLAYBACK) {
int bufsize = 1;
err = setsockopt(sd[0], SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize));
share->pcm = pcm;
share->client_socket = sd[0];
share->slave_socket = sd[1];
-
+
pcm->mmap_rw = 1;
pcm->ops = &snd_pcm_share_ops;
pcm->fast_ops = &snd_pcm_share_fast_ops;
\code
pcm.name {
- type share # Share PCM
- slave STR # Slave name
- # or
- slave { # Slave definition
- pcm STR # Slave PCM name
- [format STR] # Slave format
- [channels INT] # Slave channels
- [rate INT] # Slave rate
- [period_time INT] # Slave period time in us
- [buffer_time INT] # Slave buffer time in us
- }
+ type share # Share PCM
+ slave STR # Slave name
+ # or
+ slave { # Slave definition
+ pcm STR # Slave PCM name
+ [format STR] # Slave format
+ [channels INT] # Slave channels
+ [rate INT] # Slave rate
+ [period_time INT] # Slave period time in us
+ [buffer_time INT] # Slave buffer time in us
+ }
bindings {
N INT # Slave channel INT for client channel N
}
int srate = -1;
int speriod_time= -1, sbuffer_time = -1;
unsigned int schannel_max = 0;
-
+
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id;
}
if (schannels <= 0)
schannels = schannel_max + 1;
- err = snd_pcm_share_open(pcmp, name, sname, sformat, srate,
+ err = snd_pcm_share_open(pcmp, name, sname, sformat, srate,
(unsigned int) schannels,
speriod_time, sbuffer_time,
channels, channels_map, stream, mode);
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
size_t mmap_size, mmap_offset, offset;
int fd;
long result;
-
+
shm->ctrl->cmd = &pcm->hw == rbptr ? SND_PCM_IOCTL_HW_PTR_FD : SND_PCM_IOCTL_APPL_PTR_FD;
result = snd_pcm_shm_action_fd0(pcm, &fd);
if (result < 0)
return err;
return 0;
}
-
+
static int snd_pcm_shm_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
snd_pcm_shm_hw_refine_slave);
}
-static int snd_pcm_shm_hw_params_slave(snd_pcm_t *pcm,
+static int snd_pcm_shm_hw_params_slave(snd_pcm_t *pcm,
snd_pcm_hw_params_t *params)
{
snd_pcm_shm_t *shm = pcm->private_data;
snd_errornum(PCM, "socket failed");
return -errno;
}
-
+
addr->sun_family = AF_LOCAL;
memcpy(addr->sun_path, filename, l);
result = -errno;
goto _err;
}
-
+
shm = calloc(1, sizeof(snd_pcm_shm_t));
if (!shm) {
result = -ENOMEM;
\code
pcm.name {
- type shm # Shared memory PCM
+ type shm # Shared memory PCM
server STR # Server name
pcm STR # PCM name
}
/*
* hardware parameters
- */
+ */
err = snd_pcm_hw_params_any(pcm, hw_params);
if (err < 0)
return err;
err = INTERNAL(snd_pcm_hw_params_get_period_time)(hw_params, period_time, NULL);
if (err < 0)
return err;
- }
+ }
} else {
err = snd_pcm_hw_params_set_period_time(pcm, hw_params, *period_time, 0);
if (err < 0)
if (err < 0)
return err;
return 0;
-}
+}
static int set_sw_params(snd_pcm_t *pcm,
snd_pcm_sw_params_t *sw_params,
- snd_spcm_xrun_type_t xrun_type)
+ snd_spcm_xrun_type_t xrun_type)
{
int err;
- err = snd_pcm_sw_params_current(pcm, sw_params);
+ err = snd_pcm_sw_params_current(pcm, sw_params);
if (err < 0)
return err;
err = snd_pcm_sw_params_set_start_threshold(pcm, sw_params, (pcm->buffer_size / pcm->period_size) * pcm->period_size);
/*
* hardware parameters
*/
- err = set_buffer_time(latency, &xbuffer_time);
+ err = set_buffer_time(latency, &xbuffer_time);
if (err < 0)
return err;
-
+
for (i = 0; i < 2; i++) {
buffer_time[i] = xbuffer_time;
period_time[i] = i > 0 ? period_time[0] : 0;
} \
} \
} while (0)
-
+
#define GET_VOL_SCALE \
switch (ch) { \
case 0: \
case SND_PCM_FORMAT_S16_LE:
case SND_PCM_FORMAT_S16_BE:
/* 16bit samples */
- CONVERT_AREA(short,
+ CONVERT_AREA(short,
!snd_pcm_format_cpu_endian(svol->sformat));
break;
case SND_PCM_FORMAT_S32_LE:
case SND_PCM_FORMAT_S16_LE:
case SND_PCM_FORMAT_S16_BE:
/* 16bit samples */
- CONVERT_AREA(short,
+ CONVERT_AREA(short,
!snd_pcm_format_cpu_endian(svol->sformat));
break;
case SND_PCM_FORMAT_S32_LE:
(1ULL << SND_PCM_FORMAT_S16_BE) |
(1ULL << SND_PCM_FORMAT_S24_LE) |
(1ULL << SND_PCM_FORMAT_S32_LE) |
- (1ULL << SND_PCM_FORMAT_S32_BE),
+ (1ULL << SND_PCM_FORMAT_S32_BE),
(1ULL << (SND_PCM_FORMAT_S24_3LE - 32))
}
};
SND_PCM_HW_PARBIT_BUFFER_TIME |
SND_PCM_HW_PARBIT_TICK_TIME);
if (svol->sformat == SND_PCM_FORMAT_UNKNOWN)
- links |= (SND_PCM_HW_PARBIT_FORMAT |
+ links |= (SND_PCM_HW_PARBIT_FORMAT |
SND_PCM_HW_PARBIT_SUBFORMAT |
SND_PCM_HW_PARBIT_SAMPLE_BITS);
err = _snd_pcm_hw_params_refine(sparams, links, params);
return 0;
}
-
+
static int snd_pcm_softvol_hw_refine_cchange(snd_pcm_t *pcm,
snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
SND_PCM_HW_PARBIT_BUFFER_TIME |
SND_PCM_HW_PARBIT_TICK_TIME);
if (svol->sformat == SND_PCM_FORMAT_UNKNOWN)
- links |= (SND_PCM_HW_PARBIT_FORMAT |
+ links |= (SND_PCM_HW_PARBIT_FORMAT |
SND_PCM_HW_PARBIT_SUBFORMAT |
SND_PCM_HW_PARBIT_SAMPLE_BITS);
err = _snd_pcm_hw_params_refine(params, links, sparams);
return err;
if (slave->format != SND_PCM_FORMAT_S16_LE &&
slave->format != SND_PCM_FORMAT_S16_BE &&
- slave->format != SND_PCM_FORMAT_S24_3LE &&
+ slave->format != SND_PCM_FORMAT_S24_3LE &&
slave->format != SND_PCM_FORMAT_S24_LE &&
slave->format != SND_PCM_FORMAT_S32_LE &&
slave->format != SND_PCM_FORMAT_S32_BE) {
int err;
int i;
unsigned int def_val;
-
+
if (svol->max_val == 1) {
snd_ctl_elem_info_set_read_write(cinfo, 1, 1);
err = snd_ctl_add_boolean_elem_set(svol->ctl, cinfo, 1, count);
else
svol->zero_dB_val = (min_dB / (min_dB - max_dB)) *
svol->max_val;
-
+
snd_ctl_elem_info_set_id(&cinfo, ctl_id);
if ((err = snd_ctl_elem_info(svol->ctl, &cinfo)) < 0) {
if (err != -ENOENT) {
if (sformat != SND_PCM_FORMAT_UNKNOWN &&
sformat != SND_PCM_FORMAT_S16_LE &&
sformat != SND_PCM_FORMAT_S16_BE &&
- sformat != SND_PCM_FORMAT_S24_3LE &&
+ sformat != SND_PCM_FORMAT_S24_3LE &&
sformat != SND_PCM_FORMAT_S24_LE &&
sformat != SND_PCM_FORMAT_S32_LE &&
sformat != SND_PCM_FORMAT_S32_BE)
\code
pcm.name {
- type softvol # Soft Volume conversion PCM
- slave STR # Slave name
- # or
- slave { # Slave definition
- pcm STR # Slave PCM name
- # or
- pcm { } # Slave PCM definition
- [format STR] # Slave format
- }
- control {
- name STR # control element id string
+ type softvol # Soft Volume conversion PCM
+ slave STR # Slave name
+ # or
+ slave { # Slave definition
+ pcm STR # Slave PCM name
+ # or
+ pcm { } # Slave PCM definition
+ [format STR] # Slave format
+ }
+ control {
+ name STR # control element id string
[card STR] # control card index
[iface STR] # interface of the element
[index INT] # index of the element
* changed in future.
*/
int _snd_pcm_softvol_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;
if (sformat != SND_PCM_FORMAT_UNKNOWN &&
sformat != SND_PCM_FORMAT_S16_LE &&
sformat != SND_PCM_FORMAT_S16_BE &&
- sformat != SND_PCM_FORMAT_S24_3LE &&
+ sformat != SND_PCM_FORMAT_S24_3LE &&
sformat != SND_PCM_FORMAT_S24_LE &&
sformat != SND_PCM_FORMAT_S32_LE &&
sformat != SND_PCM_FORMAT_S32_BE) {
&_snd_module_pcm_hw,
#include "pcm_symbols_list.c"
};
-
+
void *snd_pcm_open_symbols(void)
{
return snd_pcm_open_objects;
conv_xx12_x210: as_u32(dst) = sx24((uint32_t)bswap_16(as_u16c(src)) << 8); goto CONV_END;
conv_xx12_012x: as_u32(dst) = sx24s((uint32_t)as_u16c(src) << 8); goto CONV_END;
conv_xx12_2100: as_u32(dst) = (uint32_t)bswap_16(as_u16c(src)) << 16; goto CONV_END;
-conv_xx12_0012: as_u32(dst) = (uint32_t)as_u16c(src); goto CONV_END;
+conv_xx12_0012: as_u32(dst) = (uint32_t)as_u16c(src); goto CONV_END;
conv_xx12_xxxA: as_u8(dst) = (as_u16c(src) ^ 0x80) & 0xff; goto CONV_END;
conv_xx12_xxA1: as_u16(dst) = bswap_16(as_u16c(src) ^ 0x80); goto CONV_END;
conv_xx12_xx1A: as_u16(dst) = as_u16c(src) ^ 0x80; goto CONV_END;
#ifdef GET32F_END
get32f_1234F_1234: tmp_float.f = as_floatc(src);
if (tmp_float.f >= 1.0)
- sample = 0x7fffffff;
+ sample = 0x7fffffff;
else if (tmp_float.f <= -1.0)
- sample = 0x80000000;
+ sample = 0x80000000;
else
- sample = (int32_t)(tmp_float.f * (float_t)0x80000000UL);
+ sample = (int32_t)(tmp_float.f * (float_t)0x80000000UL);
goto GET32F_END;
get32f_4321F_1234: tmp_float.i = bswap_32(as_u32c(src));
if (tmp_float.f >= 1.0)
- sample = 0x7fffffff;
+ sample = 0x7fffffff;
else if (tmp_float.f <= -1.0)
- sample = 0x80000000;
+ sample = 0x80000000;
else
- sample = (int32_t)(tmp_float.f * (float_t)0x80000000UL);
+ sample = (int32_t)(tmp_float.f * (float_t)0x80000000UL);
goto GET32F_END;
get32f_1234D_1234: tmp_double.d = as_doublec(src);
if (tmp_double.d >= 1.0)
- sample = 0x7fffffff;
+ sample = 0x7fffffff;
else if (tmp_double.d <= -1.0)
- sample = 0x80000000;
+ sample = 0x80000000;
else
- sample = (int32_t)(tmp_double.d * (double_t)0x80000000UL);
+ sample = (int32_t)(tmp_double.d * (double_t)0x80000000UL);
goto GET32F_END;
get32f_4321D_1234: tmp_double.l = bswap_64(as_u64c(src));
if (tmp_double.d >= 1.0)
- sample = 0x7fffffff;
+ sample = 0x7fffffff;
else if (tmp_double.d <= -1.0)
- sample = 0x80000000;
+ sample = 0x80000000;
else
- sample = (int32_t)(tmp_double.d * (double_t)0x80000000UL);
+ sample = (int32_t)(tmp_double.d * (double_t)0x80000000UL);
goto GET32F_END;
#endif
snd_pcm_scope_set_callback_private(scope, level);
level->win = initscr();
winsdelln(level->win, snd_pcm_meter_get_channels(level->pcm));
- getyx(level->win, y, x);
+ getyx(level->win, y, x);
level->top = y;
return 0;
}
It contains two parts: device name and arguments. Devices and arguments are described
in configuration files. The usual place for default definitions is at /usr/share/alsa/alsa.conf.
-\subsection rawmidi_dev_names_default
+\subsection rawmidi_dev_names_default
The default device is equal to hw device. The defaults are used:
* \anchor example_test_rawmidi
* Shows open and read/write rawmidi operations.
*/
-
+
#include "rawmidi_local.h"
#include <stdio.h>
#include <stdlib.h>
int snd_rawmidi_close(snd_rawmidi_t *rawmidi)
{
int err;
- assert(rawmidi);
+ assert(rawmidi);
err = rawmidi->ops->close(rawmidi);
free(rawmidi->name);
if (rawmidi->open_func)
*/
int snd_rawmidi_poll_descriptors_revents(snd_rawmidi_t *rawmidi, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
{
- assert(rawmidi && pfds && revents);
- if (nfds == 1) {
- *revents = pfds->revents;
- return 0;
- }
- return -EINVAL;
+ assert(rawmidi && pfds && revents);
+ if (nfds == 1) {
+ *revents = pfds->revents;
+ return 0;
+ }
+ return -EINVAL;
}
/**
*outputp = NULL;
if (!inputp && !outputp)
return -EINVAL;
-
+
if ((ret = snd_ctl_hw_open(&ctl, NULL, card, 0)) < 0)
return ret;
if (is_ump)
sprintf(filename, SNDRV_FILE_RAWMIDI, card, device);
__again:
- if (attempt++ > 3) {
- snd_ctl_close(ctl);
- return -EBUSY;
- }
- ret = snd_ctl_rawmidi_prefer_subdevice(ctl, subdevice);
+ if (attempt++ > 3) {
+ snd_ctl_close(ctl);
+ return -EBUSY;
+ }
+ ret = snd_ctl_rawmidi_prefer_subdevice(ctl, subdevice);
if (ret < 0) {
snd_ctl_close(ctl);
return ret;
if (mode & SND_RAWMIDI_NONBLOCK) {
fmode |= O_NONBLOCK;
}
-
+
if (mode & SND_RAWMIDI_SYNC) {
fmode |= O_SYNC;
}
&_snd_module_rawmidi_virt
#endif
};
-
+
void *snd_rawmidi_open_symbols(void)
{
return snd_rawmidi_open_objects;
int pending;
} snd_rawmidi_virtual_t;
-int _snd_seq_open_lconf(snd_seq_t **seqp, const char *name,
+int _snd_seq_open_lconf(snd_seq_t **seqp, const char *name,
int streams, int mode, snd_config_t *lconf,
snd_config_t *parent_conf);
#endif
* See \ref seq page for more details.
*/
-/*
+/*
* Sequencer Interface - main file
*
* This library is free software; you can redistribute it and/or modify
// create a new client
snd_seq_t *open_client()
{
- snd_seq_t *handle;
- int err;
- err = snd_seq_open(&handle, "default", SND_SEQ_OPEN_INPUT, 0);
- if (err < 0)
- return NULL;
- snd_seq_set_client_name(handle, "My Client");
+ snd_seq_t *handle;
+ int err;
+ err = snd_seq_open(&handle, "default", SND_SEQ_OPEN_INPUT, 0);
+ if (err < 0)
+ return NULL;
+ snd_seq_set_client_name(handle, "My Client");
return handle;
}
\endcode
From this time, events from keyboard are automatically sent to this program.
Timestamps will be updated according to the subscribed queue.
\code
- MIDI input port (keyboard)
- |
- V
- ALSA sequencer - update timestamp
- |
- V
- application port
+ MIDI input port (keyboard)
+ |
+ V
+ ALSA sequencer - update timestamp
+ |
+ V
+ application port
\endcode
There is another subscription type for opposite direction:
After this connection is established, events will be properly sent
to MIDI output device.
\code
- application port
- |
- V
- ALSA sequencer - events are scheduled
- |
- V
- MIDI output port (WaveTable etc.)
+ application port
+ |
+ V
+ ALSA sequencer - events are scheduled
+ |
+ V
+ MIDI output port (WaveTable etc.)
\endcode
From the viewpoint of subscription, the examples above are special cases.
Thus, filter applications have to manage
only input and output events regardless of receiver/sender addresses.
\code
- sequencer port #1
- |
- V
- ALSA sequencer (scheduled or real-time)
- |
- V
- sequencer port #2
+ sequencer port #1
+ |
+ V
+ ALSA sequencer (scheduled or real-time)
+ |
+ V
+ sequencer port #2
\endcode
For the detail about subscription, see the section \ref seq_subs_more.
When an event is passed to sequencer from a client, sequencer fills
source.client field
with the sender's id automatically.
-It is the responsibility of sender client to
+It is the responsibility of sender client to
fill the port id of source.port and
both client and port of dest field.
like start, stop and continue queue, change tempo, etc.
to the system timer port.
Then the sequencer system handles the queue according to the received event.
-This port supports subscription. The received timer events are
+This port supports subscription. The received timer events are
broadcasted to all subscribed clients.
The latter port does not receive messages but supports subscription.
\code
void set_tempo(snd_seq_t *handle, int queue)
{
- snd_seq_queue_tempo_t *tempo;
- snd_seq_queue_tempo_alloca(&tempo);
- snd_seq_queue_tempo_set_tempo(tempo, 1000000); // 60 BPM
- snd_seq_queue_tempo_set_ppq(tempo, 48); // 48 PPQ
- snd_seq_set_queue_tempo(handle, queue, tempo);
+ snd_seq_queue_tempo_t *tempo;
+ snd_seq_queue_tempo_alloca(&tempo);
+ snd_seq_queue_tempo_set_tempo(tempo, 1000000); // 60 BPM
+ snd_seq_queue_tempo_set_ppq(tempo, 48); // 48 PPQ
+ snd_seq_set_queue_tempo(handle, queue, tempo);
}
\endcode
\code
void capture_keyboard(snd_seq_t *seq)
{
- snd_seq_addr_t sender, dest;
- snd_seq_port_subscribe_t *subs;
- sender.client = 64;
- sender.port = 0;
- dest.client = 128;
- dest.port = 0;
- snd_seq_port_subscribe_alloca(&subs);
- snd_seq_port_subscribe_set_sender(subs, &sender);
- snd_seq_port_subscribe_set_dest(subs, &dest);
- snd_seq_port_subscribe_set_queue(subs, 1);
- snd_seq_port_subscribe_set_time_update(subs, 1);
- snd_seq_port_subscribe_set_time_real(subs, 1);
- snd_seq_subscribe_port(seq, subs);
+ snd_seq_addr_t sender, dest;
+ snd_seq_port_subscribe_t *subs;
+ sender.client = 64;
+ sender.port = 0;
+ dest.client = 128;
+ dest.port = 0;
+ snd_seq_port_subscribe_alloca(&subs);
+ snd_seq_port_subscribe_set_sender(subs, &sender);
+ snd_seq_port_subscribe_set_dest(subs, &dest);
+ snd_seq_port_subscribe_set_queue(subs, 1);
+ snd_seq_port_subscribe_set_time_update(subs, 1);
+ snd_seq_port_subscribe_set_time_real(subs, 1);
+ snd_seq_subscribe_port(seq, subs);
}
\endcode
\code
void subscribe_output(snd_seq_t *seq)
{
- snd_seq_addr_t sender, dest;
- snd_seq_port_subscribe_t *subs;
- sender.client = 128;
- sender.port = 0;
- dest.client = 65;
- dest.port = 1;
- snd_seq_port_subscribe_alloca(&subs);
- snd_seq_port_subscribe_set_sender(subs, &sender);
- snd_seq_port_subscribe_set_dest(subs, &dest);
- snd_seq_subscribe_port(seq, subs);
+ snd_seq_addr_t sender, dest;
+ snd_seq_port_subscribe_t *subs;
+ sender.client = 128;
+ sender.port = 0;
+ dest.client = 65;
+ dest.port = 1;
+ snd_seq_port_subscribe_alloca(&subs);
+ snd_seq_port_subscribe_set_sender(subs, &sender);
+ snd_seq_port_subscribe_set_dest(subs, &dest);
+ snd_seq_subscribe_port(seq, subs);
}
\endcode
This example can be simplified by using #snd_seq_connect_to() function.
\code
void subscribe_output(snd_seq_t *seq)
{
- snd_seq_connect_to(seq, 0, 65, 1);
+ snd_seq_connect_to(seq, 0, 65, 1);
}
\endcode
// ..in the third application (130:0) ..
void coupling(snd_seq_t *seq)
{
- snd_seq_addr_t sender, dest;
- snd_seq_port_subscribe_t *subs;
- sender.client = 128;
- sender.port = 0;
- dest.client = 129;
- dest.port = 0;
- snd_seq_port_subscribe_alloca(&subs);
- snd_seq_port_subscribe_set_sender(subs, &sender);
- snd_seq_port_subscribe_set_dest(subs, &dest);
- snd_seq_subscribe_port(seq, subs);
+ snd_seq_addr_t sender, dest;
+ snd_seq_port_subscribe_t *subs;
+ sender.client = 128;
+ sender.port = 0;
+ dest.client = 129;
+ dest.port = 0;
+ snd_seq_port_subscribe_alloca(&subs);
+ snd_seq_port_subscribe_set_sender(subs, &sender);
+ snd_seq_port_subscribe_set_dest(subs, &dest);
+ snd_seq_subscribe_port(seq, subs);
}
\endcode
\code
void schedule_event(snd_seq_t *seq)
{
- snd_seq_event_t ev;
+ snd_seq_event_t ev;
- snd_seq_ev_clear(&ev);
- snd_seq_ev_set_source(&ev, my_port);
- snd_seq_ev_set_subs(&ev);
- snd_seq_ev_schedule_tick(&ev, Q, 0, t);
- ... // set event type, data, so on..
+ snd_seq_ev_clear(&ev);
+ snd_seq_ev_set_source(&ev, my_port);
+ snd_seq_ev_set_subs(&ev);
+ snd_seq_ev_schedule_tick(&ev, Q, 0, t);
+ ... // set event type, data, so on..
- snd_seq_event_output(seq, &ev);
- ...
- snd_seq_drain_output(seq); // if necessary
+ snd_seq_event_output(seq, &ev);
+ ...
+ snd_seq_drain_output(seq); // if necessary
}
\endcode
Of course, you can use realtime stamp, too.
\code
void direct_delivery(snd_seq_t *seq)
{
- snd_seq_event_t ev;
+ snd_seq_event_t ev;
- snd_seq_ev_clear(&ev);
- snd_seq_ev_set_source(&ev, port);
- snd_seq_ev_set_subs(&ev);
- snd_seq_ev_set_direct(&ev);
- ... // set event type, data, so on..
+ snd_seq_ev_clear(&ev);
+ snd_seq_ev_set_source(&ev, port);
+ snd_seq_ev_set_subs(&ev);
+ snd_seq_ev_set_direct(&ev);
+ ... // set event type, data, so on..
- snd_seq_event_output(seq, &ev);
- snd_seq_drain_output(seq);
+ snd_seq_event_output(seq, &ev);
+ snd_seq_drain_output(seq);
}
\endcode
You should flush event soon after output event.
\code
void event_filter(snd_seq_t *seq, snd_seq_event_t *ev)
{
- while (snd_seq_event_input(seq, &ev) >= 0) {
- //.. modify input event ..
+ while (snd_seq_event_input(seq, &ev) >= 0) {
+ //.. modify input event ..
- snd_seq_ev_set_source(ev, my_port);
- snd_seq_ev_set_subs(ev);
- snd_seq_ev_set_direct(ev);
- snd_seq_event_output(seq, ev);
- snd_seq_drain_output(seq);
- }
+ snd_seq_ev_set_source(ev, my_port);
+ snd_seq_ev_set_subs(ev);
+ snd_seq_ev_set_direct(ev);
+ snd_seq_event_output(seq, ev);
+ snd_seq_drain_output(seq);
+ }
}
\endcode
const char *id;
const char *lib = NULL, *open_name = NULL;
int (*open_func)(snd_seq_t **, const char *,
- snd_config_t *, snd_config_t *,
+ snd_config_t *, snd_config_t *,
int, int) = NULL;
#ifndef PIC
extern void *snd_seq_open_symbols(void);
* \sa snd_seq_open_lconf(), snd_seq_close(), snd_seq_type(), snd_seq_name(),
* snd_seq_nonblock(), snd_seq_client_id()
*/
-int snd_seq_open(snd_seq_t **seqp, const char *name,
+int snd_seq_open(snd_seq_t **seqp, const char *name,
int streams, int mode)
{
snd_config_t *top;
*
* \sa snd_seq_open()
*/
-int snd_seq_open_lconf(snd_seq_t **seqp, const char *name,
+int snd_seq_open_lconf(snd_seq_t **seqp, const char *name,
int streams, int mode, snd_config_t *lconf)
{
assert(seqp && name && lconf);
}
#ifndef DOC_HIDDEN
-int _snd_seq_open_lconf(snd_seq_t **seqp, const char *name,
+int _snd_seq_open_lconf(snd_seq_t **seqp, const char *name,
int streams, int mode, snd_config_t *lconf,
snd_config_t *parent_conf)
{
*/
int snd_seq_poll_descriptors_revents(snd_seq_t *seq, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
{
- assert(seq && pfds && revents);
- if (nfds == 1) {
- *revents = pfds->revents;
- return 0;
- }
- return -EINVAL;
+ assert(seq && pfds && revents);
+ if (nfds == 1) {
+ *revents = pfds->revents;
+ return 0;
+ }
+ return -EINVAL;
}
/**
*
* Remove all event types added with #snd_seq_client_info_event_filter_add and clear
* the event filtering flag of this client_info container.
- *
+ *
* \sa snd_seq_client_info_event_filter_add(),
* snd_seq_client_info_event_filter_del(),
* snd_seq_client_info_event_filter_check(),
* \brief Add an event type to the event filtering of a client_info container
* \param info client_info container
* \param event_type event type to be added
- *
- * Set the event filtering flag of this client_info and add the specified event type to the
+ *
+ * Set the event filtering flag of this client_info and add the specified event type to the
* filter bitmap of this client_info container.
*
* \sa snd_seq_get_client_info(),
{
assert(info);
return snd_seq_get_bit(event_type, info->event_filter);
-}
+}
/**
* \brief Get the number of opened ports of a client_info container
* \param client client id
* \param info the pointer to be stored
* \return 0 on success otherwise a negative error code
- *
+ *
* Obtains the information of the client with a client id specified by
* info argument.
* The obtained information is written on info parameter.
assert(info);
memcpy(&info->sender, addr, sizeof(*addr));
}
-
+
/**
* \brief Set destination address of a port_subscribe container
* \param info port_subscribe container
{
assert(info);
return info->num_subs;
-}
+}
/**
* \brief Get the address of subscriber of a query_subscribe container
* \return the queue id (zero or positive) on success otherwise a negative error code
*
* \sa snd_seq_alloc_queue()
- */
+ */
int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name)
{
snd_seq_queue_info_t info;
*
* \sa snd_seq_alloc_named_queue(), snd_seq_create_queue(), snd_seq_free_queue(),
* snd_seq_get_queue_info()
- */
+ */
int snd_seq_alloc_queue(snd_seq_t *seq)
{
return snd_seq_alloc_named_queue(seq, NULL);
* \brief Get the queue usage flag to the client
* \param seq sequencer handle
* \param q queue id
- * \return 1 = client is allowed to access the queue, 0 = not allowed,
+ * \return 1 = client is allowed to access the queue, 0 = not allowed,
* otherwise a negative error code
*
* \sa snd_seq_get_queue_info(), snd_seq_set_queue_usage()
assert(info);
info->type = (int)type;
}
-
+
/**
* \brief Set the timer id of a queue_timer container
* \param info queue_timer container
* \brief retrieve an event from sequencer
* \param seq sequencer handle
* \param ev event pointer to be stored
- * \return
+ * \return
*
* Obtains an input event from sequencer.
* The event is created via snd_seq_create_event(), and its pointer is stored on
snd_errornum(SEQUENCER, "poll");
return -errno;
}
- if (pfd.revents & POLLIN)
+ if (pfd.revents & POLLIN)
return snd_seq_event_read_buffer(seq);
return seq->ibuflen;
}
assert(0);
return -EINVAL;
}
-
+
if (mode & SND_SEQ_NONBLOCK)
fmode |= O_NONBLOCK;
static const char **snd_seq_open_objects[] = {
&_snd_module_seq_hw
};
-
+
void *snd_seq_open_symbols(void)
{
return snd_seq_open_objects;
int snd_seq_connect_from(snd_seq_t *seq, int myport, int src_client, int src_port)
{
snd_seq_port_subscribe_t subs;
-
+
memset(&subs, 0, sizeof(subs));
subs.sender.client = src_client;
subs.sender.port = src_port;
int snd_seq_connect_to(snd_seq_t *seq, int myport, int dest_client, int dest_port)
{
snd_seq_port_subscribe_t subs;
-
+
memset(&subs, 0, sizeof(subs));
/*subs.sender.client = seq->client;*/
subs.sender.client = snd_seq_client_id(seq);
int snd_seq_disconnect_from(snd_seq_t *seq, int myport, int src_client, int src_port)
{
snd_seq_port_subscribe_t subs;
-
+
memset(&subs, 0, sizeof(subs));
subs.sender.client = src_client;
subs.sender.port = src_port;
int snd_seq_disconnect_to(snd_seq_t *seq, int myport, int dest_client, int dest_port)
{
snd_seq_port_subscribe_t subs;
-
+
memset(&subs, 0, sizeof(subs));
/*subs.sender.client = seq->client;*/
subs.sender.client = snd_seq_client_id(seq);
pfd.fd = seq->poll_fd;
pfd.events = POLLOUT;
err = poll(&pfd, 1, -1);
- /* restore the room size */
+ /* restore the room size */
info.output_room = saved_room;
snd_seq_set_client_pool(seq, &info);
return err;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "local.h"
#include <stdio.h>
#include <stdlib.h>
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;
int snd_timer_close(snd_timer_t *timer)
{
int err;
- assert(timer);
+ assert(timer);
while (!list_empty(&timer->async_handlers)) {
snd_async_handler_t *h = list_entry(timer->async_handlers.next, snd_async_handler_t, hlist);
snd_async_del_handler(h);
return NULL;
}
return handler->u.timer;
-}
+}
/**
* \brief get count of poll descriptors for timer handle
*/
int snd_timer_poll_descriptors_revents(snd_timer_t *timer, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
{
- assert(timer && pfds && revents);
- if (nfds == 1) {
- *revents = pfds->revents;
- return 0;
- }
- return -EINVAL;
+ assert(timer && pfds && revents);
+ if (nfds == 1) {
+ *revents = pfds->revents;
+ return 0;
+ }
+ return -EINVAL;
}
/**
int snd_timer_async(snd_timer_t *timer, int sig, pid_t pid)
{
assert(timer);
- if (sig == 0)
- sig = SIGIO;
+ if (sig == 0)
+ sig = SIGIO;
if (pid == 0)
pid = getpid();
return timer->ops->async(timer, sig, pid);
tmode = O_RDONLY;
if (mode & SND_TIMER_OPEN_NONBLOCK)
- tmode |= O_NONBLOCK;
+ tmode |= O_NONBLOCK;
fd = snd_open_device(SNDRV_FILE_TIMER, tmode);
if (fd < 0)
return -errno;
int snd_timer_query_close(snd_timer_query_t *timer)
{
int err;
- assert(timer);
+ assert(timer);
err = timer->ops->close(timer);
if (timer->dl_handle)
snd_dlclose(timer->dl_handle);
*/
int snd_timer_query_next_device(snd_timer_query_t *timer, snd_timer_id_t *tid)
{
- assert(timer);
- assert(tid);
+ assert(timer);
+ assert(tid);
return timer->ops->next_device(timer, tid);
}
void snd_timer_ginfo_free(snd_timer_ginfo_t *info)
{
assert(info);
- free(info);
+ free(info);
}
-
+
/**
* \brief copy one snd_timer_info_t structure to another
* \param dst destination snd_timer_info_t structure
int snd_timer_query_info(snd_timer_query_t *timer, snd_timer_ginfo_t *info)
#endif
{
- assert(timer);
- assert(info);
+ assert(timer);
+ assert(info);
return timer->ops->info(timer, info);
}
use_default_symbol_version(__snd_timer_query_info, snd_timer_query_info, ALSA_0.9.0);
int snd_timer_query_params(snd_timer_query_t *timer, snd_timer_gparams_t *params)
#endif
{
- assert(timer);
- assert(params);
+ assert(timer);
+ assert(params);
return timer->ops->params(timer, params);
}
use_default_symbol_version(__snd_timer_query_params, snd_timer_query_params, ALSA_0.9.0);
int snd_timer_query_status(snd_timer_query_t *timer, snd_timer_gstatus_t *status)
#endif
{
- assert(timer);
- assert(status);
+ assert(timer);
+ assert(status);
return timer->ops->status(timer, status);
}
use_default_symbol_version(__snd_timer_query_status, snd_timer_query_status, ALSA_0.9.0);
tmode = O_RDONLY;
if (mode & SND_TIMER_OPEN_NONBLOCK)
- tmode |= O_NONBLOCK;
+ tmode |= O_NONBLOCK;
fd = snd_open_device(SNDRV_FILE_TIMER, tmode);
if (fd < 0)
return -errno;
static const char **snd_timer_open_objects[] = {
&_snd_module_timer_hw
};
-
+
void *snd_timer_open_symbols(void)
{
return (void *)snd_timer_open_objects[0];
static const char **snd_timer_query_open_objects[] = {
&_snd_module_timer_query_hw
};
-
+
void *snd_timer_query_open_symbols(void)
{
return snd_timer_query_open_objects;
GNU Lesser General Public License for more details.
Authors: Mengdong Lin <mengdong.lin@intel.com>
- Yao Jin <yao.jin@intel.com>
- Liam Girdwood <liam.r.girdwood@linux.intel.com>
+ Yao Jin <yao.jin@intel.com>
+ Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/
#include "tplg_local.h"
if (sub_pos == pos)
break;
}
- /* the last elem of the current sub list as the head of
+ /* the last elem of the current sub list as the head of
next sub list*/
sub_base = pos;
count = 0;
GNU Lesser General Public License for more details.
Authors: Mengdong Lin <mengdong.lin@intel.com>
- Yao Jin <yao.jin@intel.com>
- Liam Girdwood <liam.r.girdwood@linux.intel.com>
+ Yao Jin <yao.jin@intel.com>
+ Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/
#include "tplg_local.h"
GNU Lesser General Public License for more details.
Authors: Mengdong Lin <mengdong.lin@intel.com>
- Yao Jin <yao.jin@intel.com>
- Liam Girdwood <liam.r.girdwood@linux.intel.com>
+ Yao Jin <yao.jin@intel.com>
+ Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/
#include "tplg_local.h"
GNU Lesser General Public License for more details.
Authors: Mengdong Lin <mengdong.lin@intel.com>
- Yao Jin <yao.jin@intel.com>
- Liam Girdwood <liam.r.girdwood@linux.intel.com>
+ Yao Jin <yao.jin@intel.com>
+ Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/
#include "tplg_local.h"
GNU Lesser General Public License for more details.
Authors: Mengdong Lin <mengdong.lin@intel.com>
- Yao Jin <yao.jin@intel.com>
- Liam Girdwood <liam.r.girdwood@linux.intel.com>
+ Yao Jin <yao.jin@intel.com>
+ Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/
#include "tplg_local.h"
long val;
void *p = &val;
- errno = 0;
+ errno = 0;
if (safe_strtol_base(str, &val, 16) < 0)
return -EINVAL;
GNU Lesser General Public License for more details.
Authors: Mengdong Lin <mengdong.lin@intel.com>
- Yao Jin <yao.jin@intel.com>
- Liam Girdwood <liam.r.girdwood@linux.intel.com>
+ Yao Jin <yao.jin@intel.com>
+ Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/
#include "tplg_local.h"
GNU Lesser General Public License for more details.
Authors: Mengdong Lin <mengdong.lin@intel.com>
- Yao Jin <yao.jin@intel.com>
- Liam Girdwood <liam.r.girdwood@linux.intel.com>
+ Yao Jin <yao.jin@intel.com>
+ Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/
#include "tplg_local.h"
GNU Lesser General Public License for more details.
Authors: Mengdong Lin <mengdong.lin@intel.com>
- Yao Jin <yao.jin@intel.com>
- Liam Girdwood <liam.r.girdwood@linux.intel.com>
+ Yao Jin <yao.jin@intel.com>
+ Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/
#include "tplg_local.h"
GNU Lesser General Public License for more details.
Authors: Mengdong Lin <mengdong.lin@intel.com>
- Yao Jin <yao.jin@intel.com>
- Liam Girdwood <liam.r.girdwood@linux.intel.com>
+ Yao Jin <yao.jin@intel.com>
+ Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/
#include "tplg_local.h"
GNU Lesser General Public License for more details.
Authors: Mengdong Lin <mengdong.lin@intel.com>
- Yao Jin <yao.jin@intel.com>
- Liam Girdwood <liam.r.girdwood@linux.intel.com>
+ Yao Jin <yao.jin@intel.com>
+ Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/
* 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
+ * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Support for the verb/device/modifier core logic and API,
static int import_master_config(snd_use_case_mgr_t *uc_mgr)
{
int err;
-
+
err = uc_mgr_import_master_config(uc_mgr);
if (err < 0)
return err;
verb_name);
}
-static int is_devlist_supported(snd_use_case_mgr_t *uc_mgr,
+static int is_devlist_supported(snd_use_case_mgr_t *uc_mgr,
struct dev_list *dev_list)
{
struct dev_list_node *device;
return 1 - found_ret;
}
-static inline int is_modifier_supported(snd_use_case_mgr_t *uc_mgr,
+static inline int is_modifier_supported(snd_use_case_mgr_t *uc_mgr,
struct use_case_modifier *modifier)
{
return is_devlist_supported(uc_mgr, &modifier->dev_list);
}
-static inline int is_device_supported(snd_use_case_mgr_t *uc_mgr,
+static inline int is_device_supported(snd_use_case_mgr_t *uc_mgr,
struct use_case_device *device)
{
return is_devlist_supported(uc_mgr, &device->dev_list);
uc_mgr->active_verb = NULL;
err = set_defaults(uc_mgr, true);
-
+
return err;
}
* 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
+ * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Support for the verb/device/modifier core logic and API,
free(tseq);
return err;
}
-
+
err = parse_sequence(uc_mgr, &tseq->transition_list, n);
if (err < 0) {
uc_mgr_free_transition_element(tseq);
if (snd_config_get_id(cfg, &id) < 0)
return -EINVAL;
-
+
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for %s", id);
return -EINVAL;
uc_error("compound type expected for %s, is %d", id, snd_config_get_type(cfg));
return -EINVAL;
}
-
+
err = fcn(uc_mgr, n, data1, data2);
if (err < 0)
return err;
snd_config_iterator_t i, next;
snd_config_t *n;
int err;
-
+
/* in-place evaluation */
err = uc_mgr_evaluate_inplace(uc_mgr, cfg);
if (err < 0)
* 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
+ * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Support for the verb/device/modifier core logic and API,
#define SEQUENCE_ELEMENT_TYPE_DEV_DISABLE_ALL 15
struct ucm_value {
- struct list_head list;
- char *name;
- char *data;
+ struct list_head list;
+ char *name;
+ char *data;
};
/* sequence of a component device */
* 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
+ * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Support for the verb/device/modifier core logic and API,
{
struct list_head *pos, *npos;
struct ucm_value *val;
-
+
list_for_each_safe(pos, npos, base) {
val = list_entry(pos, struct ucm_value, list);
uc_mgr_free_value1(val);
{
struct list_head *pos, *npos;
struct dev_list_node *dlist;
-
+
list_for_each_safe(pos, npos, &dev_list->list) {
dlist = list_entry(pos, struct dev_list_node, list);
free(dlist->name);
{
struct list_head *pos, *npos;
struct sequence_element *seq;
-
+
list_for_each_safe(pos, npos, base) {
seq = list_entry(pos, struct sequence_element, list);
list_del(&seq->list);
{
struct list_head *pos, *npos;
struct transition_sequence *tseq;
-
+
list_for_each_safe(pos, npos, base) {
tseq = list_entry(pos, struct transition_sequence, list);
list_del(&tseq->list);
{
struct list_head *pos, *npos;
struct use_case_modifier *mod;
-
+
list_for_each_safe(pos, npos, base) {
mod = list_entry(pos, struct use_case_modifier, list);
free(mod->name);
{
struct list_head *pos, *npos;
struct use_case_device *dev;
-
+
list_for_each_safe(pos, npos, base) {
dev = list_entry(pos, struct use_case_device, list);
uc_mgr_free_device(dev);
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-
+
#include "config.h"
#include <string.h>
#include <errno.h>
}
- printf("\t capture: systime: %lli nsec, audio time %lli nsec, \tsystime delta %lli \t resolution %d ns \n",
+ printf("\t capture: systime: %lli nsec, audio time %lli nsec, \tsystime delta %lli \t resolution %d ns \n",
timediff(tstamp_c, trigger_tstamp_c),
timestamp2ns(audio_tstamp_c),
timediff(tstamp_c, trigger_tstamp_c) - timestamp2ns(audio_tstamp_c), audio_tstamp_report_c.accuracy
}
snd_ctl_close(handle);
}
-
+
snd_config_update_free_global();
return 0;
}
}
__again:
- if (buffer_size > 0)
- return -1;
- if (last_bufsize == *bufsize)
+ if (buffer_size > 0)
+ return -1;
+ if (last_bufsize == *bufsize)
*bufsize += 4;
last_bufsize = *bufsize;
if (*bufsize > latency_max)
snd_pcm_hw_params_get_buffer_size(p_params, &p_size);
playback_buffer_size = p_size;
if (p_psize * 2 < p_size) {
- snd_pcm_hw_params_get_periods_min(p_params, &val, NULL);
- if (val > 2) {
+ snd_pcm_hw_params_get_periods_min(p_params, &val, NULL);
+ if (val > 2) {
printf("playback device does not support 2 periods per buffer\n");
exit(0);
}
}
snd_pcm_hw_params_get_buffer_size(c_params, &c_size);
if (c_psize * 2 < c_size) {
- snd_pcm_hw_params_get_periods_min(c_params, &val, NULL);
+ snd_pcm_hw_params_get_periods_min(c_params, &val, NULL);
if (val > 2 ) {
printf("capture device does not support 2 periods per buffer\n");
exit(0);
y[chn][1] = y[chn][0];
x[chn][0] = samples[i*channels+chn];
- y[chn][0] = a0*x[chn][0] + a1*x[chn][1] + a2*x[chn][2]
+ y[chn][0] = a0*x[chn][0] + a1*x[chn][1] + a2*x[chn][2]
- b1*y[chn][1] - b2*y[chn][2];
samples[i*channels+chn] = y[chn][0];
}
"-X,--realtime do a realtime check (buffering)\n"
"-O,--policy set scheduler policy (RR, FIFO or OTHER)\n"
);
- printf("Recognized sample formats are:");
- for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
- const char *s = snd_pcm_format_name(k);
- if (s)
- printf(" %s", s);
- }
- printf("\n\n");
- printf(
+ printf("Recognized sample formats are:");
+ for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
+ const char *s = snd_pcm_format_name(k);
+ if (s)
+ printf(" %s", s);
+ }
+ printf("\n\n");
+ printf(
"Tip #1 (usable latency with large periods, non-blocking mode, good CPU usage,\n"
" superb xrun prevention):\n"
" latency -m 8192 -M 8192 -t 1 -p\n"
lfo = 0;
dlfo = 2.*M_PI*FILTERSWEEP_LFO_FREQ/fs;
- x[0] = (float*) malloc(channels*sizeof(float));
- x[1] = (float*) malloc(channels*sizeof(float));
- x[2] = (float*) malloc(channels*sizeof(float));
- y[0] = (float*) malloc(channels*sizeof(float));
- y[1] = (float*) malloc(channels*sizeof(float));
- y[2] = (float*) malloc(channels*sizeof(float));
+ x[0] = (float*) malloc(channels*sizeof(float));
+ x[1] = (float*) malloc(channels*sizeof(float));
+ x[2] = (float*) malloc(channels*sizeof(float));
+ y[0] = (float*) malloc(channels*sizeof(float));
+ y[1] = (float*) malloc(channels*sizeof(float));
+ y[2] = (float*) malloc(channels*sizeof(float));
}
cap_avail_max = 0;
pbk_fill_min = latency * 2;
-
+
while (1) {
frames_in = frames_out = 0;
if (setparams(phandle, chandle, &latency) < 0)
else {
if (effect)
applyeffect(buffer, r);
- if (writebuf(phandle, buffer, r, &frames_out) < 0)
+ if (writebuf(phandle, buffer, r, &frames_out) < 0)
ok = 0;
}
}
old_currtempo = Mf_currtempo;
old_realtime = Mf_realtime;
if (revised_time != tempo_change_time) {
- old_f_realtime = Mf_f_realtime;
- old_currtime = save_time;
+ old_f_realtime = Mf_f_realtime;
+ old_currtime = save_time;
}
delta_secs = mf_ticks2sec (revised_time-old_currtime, Mf_division, save_tempo);
#ifdef DEBUG_TIMES
eputc(laststatus = meta_event);
eputc(end_of_track);
- eputc(0);
+ eputc(0);
*/
/* It's impossible to know how long the track chunk will be beforehand,
- so the position of the track length data is kept so that it can
- be written after the chunk has been generated */
+ so the position of the track length data is kept so that it can
+ be written after the chunk has been generated */
place_marker = ftell (fp);
/* This method turned out not to be portable because the
- parameter returned from ftell is not guaranteed to be
- in bytes on every machine */
+ parameter returned from ftell is not guaranteed to be
+ in bytes on every machine */
/* track.length = place_marker - offset - (long) sizeof(track); */
#ifdef DEBUG
/* 7 bit controllers */
#define damper_pedal 0x40
-#define portamento 0x41
+#define portamento 0x41
#define sustenuto 0x42
#define soft_pedal 0x43
#define general_4 0x44
#define Lexicon (0x06) /* Lexicon */
#define Tempi (0x20) /* Bon Tempi */
#define Siel (0x21) /* S.I.E.L. */
-#define Kawai (0x41)
+#define Kawai (0x41)
#define Roland (0x42)
#define Korg (0x42)
#define Yamaha (0x43)
struct timeval start, end;
long long diff;
snd_rawmidi_status_t *istat, *ostat;
-
+
for (i = 1 ; i<argc ; i++) {
if (argv[i][0]=='-') {
if (!strcmp(argv[i], "--help")) {
if (i + 1 < argc)
oname = argv[++i];
break;
- }
+ }
}
}
fprintf(stderr, "Using: \n");
fprintf(stderr, " Input: %s Output: %s\n", iname, oname);
}
-
+
err = snd_rawmidi_open(&handle_in, NULL, iname, SND_RAWMIDI_NONBLOCK);
if (err) {
fprintf(stderr,"snd_rawmidi_open %s failed: %d\n",iname,err);
if (verbose) {
fprintf(stderr,"Closing\n");
}
-
- snd_rawmidi_drain(handle_in);
- snd_rawmidi_close(handle_in);
- snd_rawmidi_drain(handle_out);
- snd_rawmidi_close(handle_out);
+
+ snd_rawmidi_drain(handle_in);
+ snd_rawmidi_close(handle_in);
+ snd_rawmidi_drain(handle_out);
+ snd_rawmidi_close(handle_out);
return 0;
}
{
src_step /= sizeof(*src);
sum_step /= sizeof(*sum);
- while (size-- > 0) {
- atomic_add(sum, *src);
- src += src_step;
- sum += sum_step;
- }
+ while (size-- > 0) {
+ atomic_add(sum, *src);
+ src += src_step;
+ sum += sum_step;
+ }
}
void saturate(unsigned int size,
- s16 *dst, const s32 *sum,
- unsigned int dst_step, unsigned int sum_step)
+ s16 *dst, const s32 *sum,
+ unsigned int dst_step, unsigned int sum_step)
{
dst_step /= sizeof(*dst);
sum_step /= sizeof(*sum);
- while (size-- > 0) {
- s32 sample = *sum;
- if (unlikely(sample < -0x8000))
- *dst = -0x8000;
- else if (unlikely(sample > 0x7fff))
- *dst = 0x7fff;
- else
- *dst = sample;
- dst += dst_step;
- sum += sum_step;
- }
+ while (size-- > 0) {
+ s32 sample = *sum;
+ if (unlikely(sample < -0x8000))
+ *dst = -0x8000;
+ else if (unlikely(sample > 0x7fff))
+ *dst = 0x7fff;
+ else
+ *dst = sample;
+ dst += dst_step;
+ sum += sum_step;
+ }
}
void mix_areas0(unsigned int size,
{
int count;
char *a;
-
+
for (count = size - 1; count >= 0; count--)
*sum++ = 0;
for (count = size - 1; count >= 0; count--)
int LOOP = 100;
int i, t;
unsigned long long begin, end, diff, diffS, diff0, diff1, diff1_mmx, diff2;
- double cpu_clock = detect_cpu_clock();
+ double cpu_clock = detect_cpu_clock();
s16 *dst = malloc(sizeof(*dst) * size);
s32 *sum = calloc(size, sizeof(*sum));
s16 **srcs = malloc(sizeof(*srcs) * n);
setscheduler();
#ifndef CONFIG_SMP
- printf("CPU clock: %fMhz (UP)\n\n", cpu_clock / 10e5);
+ printf("CPU clock: %fMhz (UP)\n\n", cpu_clock / 10e5);
#else
- printf("CPU clock: %fMhz (SMP)\n\n", cpu_clock / 10e5);
+ printf("CPU clock: %fMhz (SMP)\n\n", cpu_clock / 10e5);
#endif
if (argc > 3) {
size = atoi(argv[1]);
return 0;
}
- if (strcmp(pname, "-")) {
+ if (strcmp(pname, "-")) {
err = snd_pcm_open(&phandle, pname, SND_PCM_STREAM_PLAYBACK, 0);
if (err < 0) {
fprintf(stderr, "Playback PCM open error: %s\n", snd_strerror(err));
static snd_pcm_sframes_t period_size;
static snd_output_t *output = NULL;
-static void generate_sine(const snd_pcm_channel_area_t *areas,
+static void generate_sine(const snd_pcm_channel_area_t *areas,
snd_pcm_uframes_t offset,
int count, double *_phase)
{
/*
* Underrun and suspend recovery
*/
-
+
static int xrun_recovery(snd_pcm_t *handle, int err)
{
if (verbose)
}
}
}
-
+
/*
* Transfer method - write and wait for room in buffer using poll
*/
snd_pcm_channel_area_t *areas = data->areas;
snd_pcm_sframes_t avail;
int err;
-
+
avail = snd_pcm_avail_update(handle);
while (avail >= period_size) {
generate_sine(areas, 0, period_size, &data->phase);
snd_pcm_sframes_t avail, commitres;
snd_pcm_state_t state;
int first = 0, err;
-
+
while (1) {
state = snd_pcm_state(handle);
if (state == SND_PCM_STATE_XRUN) {
}
}
}
-
+
/*
* Transfer method - direct write only using mmap_write functions
*/
}
}
}
-
+
/*
*
*/
"-n,--noresample do not resample\n"
"-e,--pevent enable poll event after each period\n"
"\n");
- printf("Recognized sample formats are:");
- for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
- const char *s = snd_pcm_format_name(k);
- if (s)
- printf(" %s", s);
- }
- printf("\n");
- printf("Recognized transfer methods are:");
- for (k = 0; transfer_methods[k].name; k++)
- printf(" %s", transfer_methods[k].name);
+ printf("Recognized sample formats are:");
+ for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
+ const char *s = snd_pcm_format_name(k);
+ if (s)
+ printf(" %s", s);
+ }
+ printf("\n");
+ printf("Recognized transfer methods are:");
+ for (k = 0; transfer_methods[k].name; k++)
+ printf(" %s", transfer_methods[k].name);
printf("\n");
}
printf("Playback open error: %s\n", snd_strerror(err));
return 0;
}
-
+
if ((err = set_hwparams(handle, hwparams, transfer_methods[method].access)) < 0) {
printf("Setting of hwparams failed: %s\n", snd_strerror(err));
exit(EXIT_FAILURE);
printf("No enough memory\n");
exit(EXIT_FAILURE);
}
-
+
areas = calloc(channels, sizeof(snd_pcm_channel_area_t));
if (areas == NULL) {
printf("No enough memory\n");
exit(EXIT_FAILURE);
}
- for (i = 0; i < 16; i++) {
+ for (i = 0; i < 16; i++) {
frames = snd_pcm_writei(handle, buffer, sizeof(buffer));
if (frames < 0)
frames = snd_pcm_recover(handle, frames, 0);
/*
- * MIDI file player for ALSA sequencer
+ * MIDI file player for ALSA sequencer
* (type 0 only!, the library that is used doesn't support merging of tracks)
*
* Copyright (c) 1998 by Frank van de Pol <F.K.W.van.de.Pol@inter.nl.net>
snd_seq_queue_tempo_alloca(&tempo);
/* ppq must be set before starting the timer */
if (snd_seq_get_queue_tempo(seq_handle, dest_queue, tempo) < 0) {
- perror("get_queue_tempo");
- exit(1);
+ perror("get_queue_tempo");
+ exit(1);
}
if ((slave_ppq = snd_seq_queue_tempo_get_ppq(tempo)) != ppq) {
snd_seq_queue_tempo_set_ppq(tempo, ppq);
if (snd_seq_set_queue_tempo(seq_handle, dest_queue, tempo) < 0) {
- perror("set_queue_tempo");
- if (!slave && !shared_queue)
- exit(1);
+ perror("set_queue_tempo");
+ if (!slave && !shared_queue)
+ exit(1);
else
printf("different PPQ %d in SMF from queue PPQ %d\n", ppq, slave_ppq);
} else
/* start playing... */
if (slave) {
if (verbose >= VERB_INFO)
- printf("Wait till timer starts...\n");
+ printf("Wait till timer starts...\n");
wait_start();
if (verbose >= VERB_INFO)
- printf("Go!\n");
+ printf("Go!\n");
} else if (shared_queue) {
snd_seq_queue_status_t *stat;
snd_seq_queue_status_alloca(&stat);
{
int left;
snd_seq_event_t *input_event;
-
+
if (use_blocking_mode) {
/* read the event - blocked until any event is read */
left = snd_seq_event_input(seq_handle, &input_event);
perror("open /dev/snd/seq");
exit(1);
}
-
+
tmp = snd_seq_nonblock(seq_handle, !use_blocking_mode);
if (tmp < 0) {
perror("block_mode");
exit(1);
}
-
+
/* set the name */
/* set the event filter to receive only the echo event */
/* if running in slave mode, also listen for a START event */
perror("create port");
exit(1);
}
-
+
if (snd_seq_parse_address(seq_handle, &dest_addr, addr) < 0) {
perror("invalid destination address");
exit(1);
exit(1);
}
- /* subscribe for the timer START event */
- if (slave) {
+ /* subscribe for the timer START event */
+ if (slave) {
tmp = snd_seq_connect_from(seq_handle, my_port,
SND_SEQ_CLIENT_SYSTEM,
dest_queue + 16 /*snd_seq_queue_sync_port(dest_queue)*/);
if (tmp < 0) {
perror("subscribe");
exit(1);
- }
+ }
}
-
+
/* change the pool size */
if (snd_seq_set_client_pool_output(seq_handle, WRITE_POOL_SIZE) < 0 ||
snd_seq_set_client_pool_input(seq_handle, READ_POOL_SIZE) < 0 ||
perror("pool");
exit(1);
}
-
+
if (optind < argc) {
F = fopen(argv[optind], "r");
if (F == NULL) {
} else if (tv->tv_sec < 0) {
while (tv->tv_usec <= -1000000) { tv->tv_usec += 1000000; --tv->tv_sec; }
while (tv->tv_usec > 0) { tv->tv_usec -= 1000000; ++tv->tv_sec; }
- } else {
+ } else {
while (tv->tv_usec >= 1000000) { tv->tv_usec -= 1000000; ++tv->tv_sec; }
while (tv->tv_usec < 0) { tv->tv_usec += 1000000; --tv->tv_sec; }
}
int fd_in = -1,fd_out = -1;
snd_rawmidi_t *handle_in = 0,*handle_out = 0;
-
+
if (argc==1) {
usage();
exit(0);
}
-
+
for (i = 1 ; i<argc ; i++) {
if (argv[i][0]=='-') {
switch (argv[i][1]) {
if (i + 1 < argc)
node_out = argv[++i];
break;
- }
+ }
}
}
if (device_in) {
fprintf(stderr,"device %s\n",device_in);
}else if (node_in){
- fprintf(stderr,"%s\n",node_in);
+ fprintf(stderr,"%s\n",node_in);
}else{
fprintf(stderr,"NONE\n");
}
if (device_out) {
fprintf(stderr,"device %s\n",device_out);
}else if (node_out){
- fprintf(stderr,"%s\n",node_out);
+ fprintf(stderr,"%s\n",node_out);
}else{
fprintf(stderr,"NONE\n");
}
}
-
+
if (device_in) {
- err = snd_rawmidi_open(&handle_in,NULL,device_in,0);
+ err = snd_rawmidi_open(&handle_in,NULL,device_in,0);
if (err) {
fprintf(stderr,"snd_rawmidi_open %s failed: %d\n",device_in,err);
}
fd_in = open(node_in,O_RDONLY);
if (fd_in<0) {
fprintf(stderr,"open %s for input failed\n",node_in);
- }
+ }
}
signal(SIGINT,sighandler);
}
}
if (node_out && (!node_in || strcmp(node_out,node_in))) {
- fd_out = open(node_out,O_WRONLY);
+ fd_out = open(node_out,O_WRONLY);
if (fd_out<0) {
fprintf(stderr,"open %s for output failed\n",node_out);
- }
+ }
}
if (node_in && node_out && strcmp(node_out,node_in)==0) {
- fd_in = fd_out = open(node_out,O_RDWR);
+ fd_in = fd_out = open(node_out,O_RDWR);
if (fd_out<0) {
fprintf(stderr,"open %s for input and output failed\n",node_out);
- }
+ }
}
if (!thru) {
if (verbose) {
fprintf(stderr,"read %02x\n",ch);
}
- }
+ }
}
if (handle_out || fd_out!=-1) {
ch=0x90; snd_rawmidi_write(handle_out,&ch,1);
ch=60; snd_rawmidi_write(handle_out,&ch,1);
ch=0; snd_rawmidi_write(handle_out,&ch,1);
- snd_rawmidi_drain(handle_out);
+ snd_rawmidi_drain(handle_out);
}
if (fd_out!=-1) {
unsigned char ch;
}
while (!stop) {
unsigned char ch;
-
+
if (handle_in) {
snd_rawmidi_read(handle_in,&ch,1);
}
if (fd_in!=-1) {
read(fd_in,&ch,1);
- }
+ }
if (verbose) {
fprintf(stderr,"thru: %02x\n",ch);
}
if (handle_out) {
snd_rawmidi_write(handle_out,&ch,1);
- snd_rawmidi_drain(handle_out);
+ snd_rawmidi_drain(handle_out);
}
if (fd_out!=-1) {
write(fd_out,&ch,1);
}
}
}else{
- fprintf(stderr,"Testing midi thru needs both input and output\n");
+ fprintf(stderr,"Testing midi thru needs both input and output\n");
exit(-1);
}
}
if (verbose) {
fprintf(stderr,"Closing\n");
}
-
+
if (handle_in) {
- snd_rawmidi_drain(handle_in);
- snd_rawmidi_close(handle_in);
+ snd_rawmidi_drain(handle_in);
+ snd_rawmidi_close(handle_in);
}
if (handle_out) {
- snd_rawmidi_drain(handle_out);
- snd_rawmidi_close(handle_out);
+ snd_rawmidi_drain(handle_out);
+ snd_rawmidi_close(handle_out);
}
if (fd_in!=-1) {
close(fd_in);
ev->data.note.note,
ev->data.note.velocity);
break;
-
+
case SND_SEQ_EVENT_CONTROLLER:
printf("; ch=%d, param=%i, value=%i\n",
ev->data.control.channel,
ev->data.control.channel,
ev->data.control.value);
break;
-
+
case SND_SEQ_EVENT_CHANPRESS:
case SND_SEQ_EVENT_PITCHBEND:
printf("; ch=%d, value=%i\n",
ev->data.control.channel,
ev->data.control.value);
break;
-
+
case SND_SEQ_EVENT_SYSEX:
{
unsigned char *sysex = (unsigned char *) ev + sizeof(snd_seq_event_t);
unsigned int c;
-
+
printf("; len=%d [", ev->data.ext.len);
-
+
for (c = 0; c < ev->data.ext.len; c++) {
printf("%02x%s", sysex[c], c < ev->data.ext.len - 1 ? ":" : "");
}
printf("]\n");
}
break;
-
+
case SND_SEQ_EVENT_QFRAME:
printf("; frame=0x%02x\n", ev->data.control.value);
break;
-
+
case SND_SEQ_EVENT_CLOCK:
case SND_SEQ_EVENT_START:
case SND_SEQ_EVENT_CONTINUE:
case SND_SEQ_EVENT_ECHO:
{
int i;
-
+
printf("; ");
for (i = 0; i < 8; i++) {
printf("%02i%s", ev->data.raw8.d[i], i < 7 ? ":" : "\n");
}
}
break;
-
+
case SND_SEQ_EVENT_CLIENT_START:
case SND_SEQ_EVENT_CLIENT_EXIT:
case SND_SEQ_EVENT_CLIENT_CHANGE:
return;
}
}
-
+
max = snd_seq_poll_descriptors_count(handle, POLLIN);
pfds = alloca(sizeof(*pfds) * max);
while (1) {
snd_pcm_t *phandle ATTRIBUTE_UNUSED)
{
int err;
-
+
#ifdef USE_PCM
if (phandle) {
snd_pcm_playback_info_t pinfo;
fprintf(stderr, "Sequencer PCM timer setup failed: %s\n", snd_strerror(err));
exit(0);
}
- }
+ }
#endif
if ((err = snd_seq_start_queue(handle, queue, NULL))<0)
fprintf(stderr, "Timer event output error: %s\n", snd_strerror(err));
}
void send_event(snd_seq_t *handle, int queue, int client, int port,
- snd_seq_addr_t *dest, int *time)
+ snd_seq_addr_t *dest, int *time)
{
int err;
snd_seq_event_t ev;
-
+
bzero(&ev, sizeof(ev));
ev.queue = queue;
ev.source.client = ev.dest.client = client;
}
#endif
event_sender_start_timer(handle, client, queue, phandle);
-
+
/* send the first event */
send_event(handle, queue, client, port, &addr, &time);
#ifdef USE_PCM
{
int err;
char name[64];
-
+
sprintf(name, "SeqUtil - %i", getpid());
if ((err = snd_seq_set_client_name(handle, name)) < 0) {
fprintf(stderr, "Set client info error: %s\n", snd_strerror(err));
{
int err;
snd_seq_system_info_t *sysinfo;
-
+
snd_seq_system_info_alloca(&sysinfo);
if ((err = snd_seq_system_info(handle, sysinfo))<0) {
fprintf(stderr, "System info error: %s\n", snd_strerror(err));
exit(0);
}
printf("Queue %i info\n", snd_seq_queue_status_get_queue(status));
- printf(" Tick : %u\n", snd_seq_queue_status_get_tick_time(status));
+ printf(" Tick : %u\n", snd_seq_queue_status_get_tick_time(status));
printf(" Realtime : %i.%i\n",
snd_seq_queue_status_get_real_time(status)->tv_sec,
snd_seq_queue_status_get_real_time(status)->tv_nsec);
{"verbose", 0, NULL, HELPID_VERBOSE},
{"version", 0, NULL, HELPID_VERSION},
{NULL, 0, NULL, 0},
- };
-
- morehelp = 0;
-
+ };
+
+ morehelp = 0;
+
while (1) {
int c;
morehelp++;
}
}
- if (morehelp) {
- help();
- return 1;
- }
+ if (morehelp) {
+ help();
+ return 1;
+ }
if (argc - optind <= 0) {
fprintf(stderr, "seq: Specify command...\n");
return 0;
set_name(handle);
system_info(handle);
- if (!strcmp(argv[optind], "system")) {
+ if (!strcmp(argv[optind], "system")) {
show_system_info(handle);
} else if (!strcmp(argv[optind], "queue")) {
arg = argc - optind > 1 ? atoi(argv[optind + 1]) : -1;
{
int err;
snd_timer_status_t *status;
-
+
snd_timer_status_alloca(&status);
if ((err = snd_timer_status(handle, status)) < 0) {
fprintf(stderr, "timer status %i (%s)\n", err, snd_strerror(err));
int count, err;
struct pollfd *fds;
snd_timer_read_t tr;
-
+
count = snd_timer_poll_descriptors_count(handle);
fds = calloc(count, sizeof(struct pollfd));
if (fds == NULL) {
snd_timer_t *handle = snd_async_handler_get_timer(ahandler);
int *acount = snd_async_handler_get_callback_private(ahandler);
snd_timer_read_t tr;
-
+
while (snd_timer_read(handle, &tr, sizeof(tr)) == sizeof(tr)) {
printf("TIMER: resolution = %uns, ticks = %u\n",
tr.resolution, tr.ticks);
err = snd_ctl_elem_add_iec958(trial->handle, trial->id);
if (err < 0)
- return err;
+ return err;
/*
* In historical reason, the above API is not allowed to fill all of