mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
PCM API cleaning. silencing implementation. xfer_min removal
This commit is contained in:
parent
684703b387
commit
8f1b27dfb8
29 changed files with 1189 additions and 853 deletions
|
|
@ -460,9 +460,6 @@ int pcm_shm_cmd(client_t *client)
|
||||||
ctrl->result = snd_pcm_mmap_forward(pcm, ctrl->u.mmap_forward.frames);
|
ctrl->result = snd_pcm_mmap_forward(pcm, ctrl->u.mmap_forward.frames);
|
||||||
ctrl->appl_ptr = *pcm->appl_ptr;
|
ctrl->appl_ptr = *pcm->appl_ptr;
|
||||||
break;
|
break;
|
||||||
case SND_PCM_IOCTL_SET_AVAIL_MIN:
|
|
||||||
ctrl->result = snd_pcm_set_avail_min(pcm, ctrl->u.set_avail_min.frames);
|
|
||||||
break;
|
|
||||||
case SND_PCM_IOCTL_POLL_DESCRIPTOR:
|
case SND_PCM_IOCTL_POLL_DESCRIPTOR:
|
||||||
ctrl->result = 0;
|
ctrl->result = 0;
|
||||||
return shm_ack_fd(client, snd_pcm_poll_descriptor(pcm));
|
return shm_ack_fd(client, snd_pcm_poll_descriptor(pcm));
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@
|
||||||
#define SND_PCM_IOCTL_ASYNC _IO ('A', 0xf6)
|
#define SND_PCM_IOCTL_ASYNC _IO ('A', 0xf6)
|
||||||
#define SND_PCM_IOCTL_CLOSE _IO ('A', 0xf7)
|
#define SND_PCM_IOCTL_CLOSE _IO ('A', 0xf7)
|
||||||
#define SND_PCM_IOCTL_POLL_DESCRIPTOR _IO ('A', 0xf8)
|
#define SND_PCM_IOCTL_POLL_DESCRIPTOR _IO ('A', 0xf8)
|
||||||
#define SND_PCM_IOCTL_SET_AVAIL_MIN _IO ('A', 0xf9)
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
long result;
|
long result;
|
||||||
|
|
@ -46,6 +45,7 @@ typedef struct {
|
||||||
snd_pcm_hw_params_t hw_refine;
|
snd_pcm_hw_params_t hw_refine;
|
||||||
snd_pcm_hw_params_t hw_params;
|
snd_pcm_hw_params_t hw_params;
|
||||||
snd_pcm_sw_params_t sw_params;
|
snd_pcm_sw_params_t sw_params;
|
||||||
|
snd_pcm_sw_params_t sw_refine;
|
||||||
snd_pcm_status_t status;
|
snd_pcm_status_t status;
|
||||||
struct {
|
struct {
|
||||||
ssize_t frames;
|
ssize_t frames;
|
||||||
|
|
@ -63,9 +63,6 @@ typedef struct {
|
||||||
struct {
|
struct {
|
||||||
ssize_t frames;
|
ssize_t frames;
|
||||||
} mmap_forward;
|
} mmap_forward;
|
||||||
struct {
|
|
||||||
ssize_t frames;
|
|
||||||
} set_avail_min;
|
|
||||||
} u;
|
} u;
|
||||||
char data[0];
|
char data[0];
|
||||||
} snd_pcm_shm_ctrl_t;
|
} snd_pcm_shm_ctrl_t;
|
||||||
|
|
|
||||||
122
include/pcm.h
122
include/pcm.h
|
|
@ -59,6 +59,7 @@ int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock);
|
||||||
int snd_pcm_async(snd_pcm_t *pcm, int sig, pid_t pid);
|
int snd_pcm_async(snd_pcm_t *pcm, int sig, pid_t pid);
|
||||||
int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info);
|
int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info);
|
||||||
int snd_pcm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
|
int snd_pcm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
|
||||||
|
int snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
|
||||||
int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
|
int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
|
||||||
int snd_pcm_status(snd_pcm_t *pcm, snd_pcm_status_t *status);
|
int snd_pcm_status(snd_pcm_t *pcm, snd_pcm_status_t *status);
|
||||||
int snd_pcm_prepare(snd_pcm_t *pcm);
|
int snd_pcm_prepare(snd_pcm_t *pcm);
|
||||||
|
|
@ -78,11 +79,8 @@ ssize_t snd_pcm_readn(snd_pcm_t *pcm, void **bufs, size_t size);
|
||||||
int snd_pcm_dump_hw_setup(snd_pcm_t *pcm, FILE *fp);
|
int snd_pcm_dump_hw_setup(snd_pcm_t *pcm, FILE *fp);
|
||||||
int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, FILE *fp);
|
int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, FILE *fp);
|
||||||
int snd_pcm_dump_setup(snd_pcm_t *pcm, FILE *fp);
|
int snd_pcm_dump_setup(snd_pcm_t *pcm, FILE *fp);
|
||||||
int snd_pcm_dump_hw_params(snd_pcm_hw_params_t *params, FILE *fp);
|
|
||||||
int snd_pcm_dump_hw_params_fail(snd_pcm_hw_params_t *params, FILE *fp);
|
|
||||||
int snd_pcm_dump_sw_params_fail(snd_pcm_sw_params_t *params, FILE *fp);
|
|
||||||
int snd_pcm_dump(snd_pcm_t *pcm, FILE *fp);
|
int snd_pcm_dump(snd_pcm_t *pcm, FILE *fp);
|
||||||
int snd_pcm_dump_status(snd_pcm_status_t *status, FILE *fp);
|
int snd_pcm_status_dump(snd_pcm_status_t *status, FILE *fp);
|
||||||
int snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2);
|
int snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2);
|
||||||
int snd_pcm_unlink(snd_pcm_t *pcm);
|
int snd_pcm_unlink(snd_pcm_t *pcm);
|
||||||
|
|
||||||
|
|
@ -105,22 +103,40 @@ int mask_eq(const mask_t *a, const mask_t *b);
|
||||||
int mask_single(const mask_t *mask);
|
int mask_single(const mask_t *mask);
|
||||||
|
|
||||||
int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
|
int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
|
||||||
int snd_pcm_hw_params_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
int snd_pcm_hw_param_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
|
unsigned int var);
|
||||||
|
int snd_pcm_hw_param_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
unsigned int var, unsigned int val);
|
unsigned int var, unsigned int val);
|
||||||
int snd_pcm_hw_params_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
int snd_pcm_hw_param_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
unsigned int var, unsigned int val);
|
unsigned int var, unsigned int val);
|
||||||
int snd_pcm_hw_params_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
int snd_pcm_hw_param_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
unsigned int var, unsigned int val);
|
unsigned int var, unsigned int val);
|
||||||
int snd_pcm_hw_params_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
int snd_pcm_hw_param_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
unsigned int var, unsigned int min, unsigned int max);
|
unsigned int var, unsigned int min, unsigned int max);
|
||||||
int snd_pcm_hw_params_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
int snd_pcm_hw_param_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
unsigned int par);
|
unsigned int par);
|
||||||
int snd_pcm_hw_params_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
int snd_pcm_hw_param_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
unsigned int par);
|
unsigned int par);
|
||||||
int snd_pcm_hw_params_set(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
int snd_pcm_hw_param_set(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
unsigned int var, unsigned int val);
|
unsigned int var, unsigned int val);
|
||||||
int snd_pcm_hw_params_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
int snd_pcm_hw_param_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
unsigned int var, const mask_t *mask);
|
unsigned int var, const mask_t *mask);
|
||||||
|
int snd_pcm_hw_param_value(const snd_pcm_hw_params_t *params,
|
||||||
|
unsigned int var);
|
||||||
|
const mask_t *snd_pcm_hw_param_value_mask(const snd_pcm_hw_params_t *params,
|
||||||
|
unsigned int var);
|
||||||
|
const interval_t *snd_pcm_hw_param_value_interval(const snd_pcm_hw_params_t *params,
|
||||||
|
unsigned int var);
|
||||||
|
unsigned int snd_pcm_hw_param_value_min(const snd_pcm_hw_params_t *params,
|
||||||
|
unsigned int var);
|
||||||
|
unsigned int snd_pcm_hw_param_value_max(const snd_pcm_hw_params_t *params,
|
||||||
|
unsigned int var);
|
||||||
|
int snd_pcm_hw_params_try_explain_failure(snd_pcm_t *pcm,
|
||||||
|
snd_pcm_hw_params_t *fail,
|
||||||
|
snd_pcm_hw_params_t *success,
|
||||||
|
unsigned int depth,
|
||||||
|
FILE *fp);
|
||||||
|
|
||||||
int snd_pcm_hw_params_info_rate(const snd_pcm_hw_params_t *params,
|
int snd_pcm_hw_params_info_rate(const snd_pcm_hw_params_t *params,
|
||||||
unsigned int *rate_num,
|
unsigned int *rate_num,
|
||||||
unsigned int *rate_den);
|
unsigned int *rate_den);
|
||||||
|
|
@ -128,48 +144,50 @@ int snd_pcm_hw_params_info_msbits(const snd_pcm_hw_params_t *params);
|
||||||
int snd_pcm_hw_params_info_flags(const snd_pcm_hw_params_t *params);
|
int snd_pcm_hw_params_info_flags(const snd_pcm_hw_params_t *params);
|
||||||
int snd_pcm_hw_params_info_fifo_size(const snd_pcm_hw_params_t *params);
|
int snd_pcm_hw_params_info_fifo_size(const snd_pcm_hw_params_t *params);
|
||||||
int snd_pcm_hw_params_info_dig_groups(const snd_pcm_hw_params_t *params);
|
int snd_pcm_hw_params_info_dig_groups(const snd_pcm_hw_params_t *params);
|
||||||
int snd_pcm_hw_params_value(const snd_pcm_hw_params_t *params,
|
int snd_pcm_hw_params_dump(snd_pcm_hw_params_t *params, FILE *fp);
|
||||||
unsigned int var);
|
|
||||||
const mask_t *snd_pcm_hw_params_value_mask(const snd_pcm_hw_params_t *params,
|
|
||||||
unsigned int var);
|
|
||||||
const interval_t *snd_pcm_hw_params_value_interval(const snd_pcm_hw_params_t *params,
|
|
||||||
unsigned int var);
|
|
||||||
unsigned int snd_pcm_hw_params_value_min(const snd_pcm_hw_params_t *params,
|
|
||||||
unsigned int var);
|
|
||||||
unsigned int snd_pcm_hw_params_value_max(const snd_pcm_hw_params_t *params,
|
|
||||||
unsigned int var);
|
|
||||||
int snd_pcm_hw_params_test(const snd_pcm_hw_params_t *params,
|
|
||||||
unsigned int var, unsigned int val);
|
|
||||||
int snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
|
|
||||||
|
|
||||||
typedef struct _snd_pcm_strategy snd_pcm_strategy_t;
|
typedef struct _snd_pcm_hw_strategy snd_pcm_hw_strategy_t;
|
||||||
|
|
||||||
/* choices need to be sorted on ascending badness */
|
/* choices need to be sorted on ascending badness */
|
||||||
typedef struct _snd_pcm_strategy_simple_choices_list {
|
typedef struct _snd_pcm_hw_strategy_simple_choices_list {
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
unsigned int badness;
|
unsigned int badness;
|
||||||
} snd_pcm_strategy_simple_choices_list_t;
|
} snd_pcm_hw_strategy_simple_choices_list_t;
|
||||||
|
|
||||||
int snd_pcm_hw_info_strategy(snd_pcm_t *pcm, snd_pcm_hw_params_t *info,
|
int snd_pcm_hw_params_strategy(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
const snd_pcm_strategy_t *strategy);
|
const snd_pcm_hw_strategy_t *strategy,
|
||||||
|
unsigned int badness_min,
|
||||||
|
unsigned int badness_max);
|
||||||
|
|
||||||
int snd_pcm_strategy_free(snd_pcm_strategy_t *strategy);
|
int snd_pcm_hw_strategy_free(snd_pcm_hw_strategy_t *strategy);
|
||||||
int snd_pcm_strategy_simple(snd_pcm_strategy_t **strategyp,
|
int snd_pcm_hw_strategy_simple(snd_pcm_hw_strategy_t **strategyp,
|
||||||
unsigned int badness_min,
|
unsigned int badness_min,
|
||||||
unsigned int badness_max);
|
unsigned int badness_max);
|
||||||
int snd_pcm_strategy_simple_near(snd_pcm_strategy_t *strategy, int order,
|
int snd_pcm_hw_strategy_simple_near(snd_pcm_hw_strategy_t *strategy, int order,
|
||||||
unsigned int param,
|
|
||||||
unsigned int best,
|
|
||||||
unsigned int mul);
|
|
||||||
int snd_pcm_strategy_simple_choices(snd_pcm_strategy_t *strategy, int order,
|
|
||||||
unsigned int param,
|
unsigned int param,
|
||||||
unsigned int count,
|
unsigned int best,
|
||||||
snd_pcm_strategy_simple_choices_list_t *choices);
|
unsigned int mul);
|
||||||
int snd_pcm_hw_params_try_explain_failure(snd_pcm_t *pcm,
|
int snd_pcm_hw_strategy_simple_choices(snd_pcm_hw_strategy_t *strategy, int order,
|
||||||
snd_pcm_hw_params_t *fail,
|
unsigned int param,
|
||||||
snd_pcm_hw_params_t *success,
|
unsigned int count,
|
||||||
unsigned int depth,
|
snd_pcm_hw_strategy_simple_choices_list_t *choices);
|
||||||
FILE *fp);
|
|
||||||
|
#define SND_PCM_SW_PARAM_START_MODE 0
|
||||||
|
#define SND_PCM_SW_PARAM_READY_MODE 1
|
||||||
|
#define SND_PCM_SW_PARAM_XRUN_MODE 2
|
||||||
|
#define SND_PCM_SW_PARAM_SILENCE_MODE 3
|
||||||
|
#define SND_PCM_SW_PARAM_TSTAMP_MODE 4
|
||||||
|
#define SND_PCM_SW_PARAM_AVAIL_MIN 5
|
||||||
|
#define SND_PCM_SW_PARAM_XFER_ALIGN 6
|
||||||
|
#define SND_PCM_SW_PARAM_SILENCE_THRESHOLD 7
|
||||||
|
#define SND_PCM_SW_PARAM_SILENCE_SIZE 8
|
||||||
|
#define SND_PCM_SW_PARAM_LAST 8
|
||||||
|
|
||||||
|
int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
|
||||||
|
int snd_pcm_sw_param_set(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, unsigned int var, unsigned int val);
|
||||||
|
int snd_pcm_sw_param_near(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, unsigned int var, unsigned int val);
|
||||||
|
int snd_pcm_sw_param_value(snd_pcm_sw_params_t *params, unsigned int var);
|
||||||
|
int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, FILE *fp);
|
||||||
|
|
||||||
/* mmap */
|
/* mmap */
|
||||||
const snd_pcm_channel_area_t *snd_pcm_mmap_areas(snd_pcm_t *pcm);
|
const snd_pcm_channel_area_t *snd_pcm_mmap_areas(snd_pcm_t *pcm);
|
||||||
|
|
@ -183,14 +201,20 @@ ssize_t snd_pcm_mmap_readi(snd_pcm_t *pcm, void *buffer, size_t size);
|
||||||
ssize_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, size_t size);
|
ssize_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, size_t size);
|
||||||
ssize_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, size_t size);
|
ssize_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, size_t size);
|
||||||
|
|
||||||
|
const char *snd_pcm_stream_name(unsigned int stream);
|
||||||
|
const char *snd_pcm_hw_param_name(unsigned int params);
|
||||||
|
const char *snd_pcm_sw_param_name(unsigned int params);
|
||||||
const char *snd_pcm_access_name(unsigned int access);
|
const char *snd_pcm_access_name(unsigned int access);
|
||||||
const char *snd_pcm_format_name(unsigned int format);
|
const char *snd_pcm_format_name(unsigned int format);
|
||||||
const char *snd_pcm_subformat_name(unsigned int subformat);
|
const char *snd_pcm_subformat_name(unsigned int subformat);
|
||||||
const char *snd_pcm_hw_param_name(unsigned int params);
|
|
||||||
const char *snd_pcm_sw_param_name(unsigned int params);
|
|
||||||
|
|
||||||
const char *snd_pcm_format_description(unsigned int format);
|
const char *snd_pcm_format_description(unsigned int format);
|
||||||
int snd_pcm_format_value(const char* name);
|
int snd_pcm_format_value(const char* name);
|
||||||
|
const char *snd_pcm_start_mode_name(unsigned int mode);
|
||||||
|
const char *snd_pcm_ready_mode_name(unsigned int mode);
|
||||||
|
const char *snd_pcm_xrun_mode_name(unsigned int mode);
|
||||||
|
const char *snd_pcm_silence_mode_name(unsigned int mode);
|
||||||
|
const char *snd_pcm_tstamp_mode_name(unsigned int mode);
|
||||||
|
const char *snd_pcm_state_name(unsigned int state);
|
||||||
|
|
||||||
int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_channel, size_t dst_offset,
|
int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_channel, size_t dst_offset,
|
||||||
size_t samples, int format);
|
size_t samples, int format);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@ libpcm_la_SOURCES = mask.c interval.c \
|
||||||
pcm.c pcm_hw.c pcm_plugin.c pcm_copy.c pcm_linear.c \
|
pcm.c pcm_hw.c pcm_plugin.c pcm_copy.c pcm_linear.c \
|
||||||
pcm_route.c pcm_mulaw.c pcm_alaw.c pcm_adpcm.c \
|
pcm_route.c pcm_mulaw.c pcm_alaw.c pcm_adpcm.c \
|
||||||
pcm_rate.c pcm_plug.c pcm_misc.c pcm_mmap.c pcm_multi.c \
|
pcm_rate.c pcm_plug.c pcm_misc.c pcm_mmap.c pcm_multi.c \
|
||||||
pcm_shm.c pcm_file.c pcm_share.c pcm_null.c pcm_params.c
|
pcm_shm.c pcm_file.c pcm_share.c pcm_null.c \
|
||||||
|
pcm_params.c
|
||||||
noinst_HEADERS = pcm_local.h pcm_plugin.h mask.h mask_inline.h \
|
noinst_HEADERS = pcm_local.h pcm_plugin.h mask.h mask_inline.h \
|
||||||
interval.h interval_inline.h
|
interval.h interval_inline.h
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define INTERVAL_C
|
#define INTERVAL_C
|
||||||
|
#define INTERVAL_INLINE
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
@ -215,6 +216,30 @@ int interval_refine_set(interval_t *i, unsigned int val)
|
||||||
return interval_refine(i, &t);
|
return interval_refine(i, &t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* a <- b + c */
|
||||||
|
int interval_add(interval_t *a, const interval_t *b, const interval_t *c)
|
||||||
|
{
|
||||||
|
interval_t t;
|
||||||
|
assert(!a->empty && !b->empty && !c->empty);
|
||||||
|
t.min = add(b->min, c->min);
|
||||||
|
t.openmin = (b->openmin || c->openmin);
|
||||||
|
t.max = add(b->max, c->max);
|
||||||
|
t.openmax = (b->openmax || c->openmax);
|
||||||
|
return interval_refine(a, &t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a <- b - c */
|
||||||
|
int interval_sub(interval_t *a, const interval_t *b, const interval_t *c)
|
||||||
|
{
|
||||||
|
interval_t t;
|
||||||
|
assert(!a->empty && !b->empty && !c->empty);
|
||||||
|
t.min = sub(b->min, c->max);
|
||||||
|
t.openmin = (b->openmin || c->openmax);
|
||||||
|
t.max = add(b->max, c->min);
|
||||||
|
t.openmax = (b->openmax || c->openmin);
|
||||||
|
return interval_refine(a, &t);
|
||||||
|
}
|
||||||
|
|
||||||
/* a <- b * c */
|
/* a <- b * c */
|
||||||
int interval_mul(interval_t *a, const interval_t *b, const interval_t *c)
|
int interval_mul(interval_t *a, const interval_t *b, const interval_t *c)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,9 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef INTERVAL_C
|
#ifdef INTERVAL_INLINE
|
||||||
#include "interval_inline.h"
|
#include "interval_inline.h"
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
void interval_all(interval_t *i);
|
void interval_all(interval_t *i);
|
||||||
void interval_setreal(interval_t *i);
|
void interval_setreal(interval_t *i);
|
||||||
int interval_empty(const interval_t *i);
|
int interval_empty(const interval_t *i);
|
||||||
|
|
@ -33,18 +32,22 @@ int interval_value(const interval_t *i);
|
||||||
int interval_min(const interval_t *i);
|
int interval_min(const interval_t *i);
|
||||||
int interval_max(const interval_t *i);
|
int interval_max(const interval_t *i);
|
||||||
int interval_test(const interval_t *i, unsigned int val);
|
int interval_test(const interval_t *i, unsigned int val);
|
||||||
int interval_refine_min(interval_t *i, unsigned int min);
|
void interval_copy(interval_t *dst, const interval_t *src);
|
||||||
int interval_refine_max(interval_t *i, unsigned int max);
|
int interval_eq(const interval_t *i1, const interval_t *i2);
|
||||||
int interval_refine(interval_t *i, const interval_t *v);
|
#endif
|
||||||
int interval_refine_first(interval_t *i);
|
|
||||||
int interval_refine_last(interval_t *i);
|
int interval_add(interval_t *a, const interval_t *b, const interval_t *c);
|
||||||
int interval_refine_set(interval_t *i, unsigned int val);
|
int interval_sub(interval_t *a, const interval_t *b, const interval_t *c);
|
||||||
int interval_mul(interval_t *a, const interval_t *b, const interval_t *c);
|
int interval_mul(interval_t *a, const interval_t *b, const interval_t *c);
|
||||||
int interval_div(interval_t *a, const interval_t *b, const interval_t *c);
|
int interval_div(interval_t *a, const interval_t *b, const interval_t *c);
|
||||||
int interval_muldivk(interval_t *a, unsigned int k,
|
int interval_muldivk(interval_t *a, unsigned int k,
|
||||||
const interval_t *b, const interval_t *c);
|
const interval_t *b, const interval_t *c);
|
||||||
int interval_mulkdiv(interval_t *a, unsigned int k,
|
int interval_mulkdiv(interval_t *a, unsigned int k,
|
||||||
const interval_t *b, const interval_t *c);
|
const interval_t *b, const interval_t *c);
|
||||||
void interval_copy(interval_t *dst, const interval_t *src);
|
|
||||||
void interval_print(const interval_t *i, FILE *fp);
|
void interval_print(const interval_t *i, FILE *fp);
|
||||||
int interval_eq(const interval_t *i1, const interval_t *i2);
|
int interval_refine_min(interval_t *i, unsigned int min);
|
||||||
|
int interval_refine_max(interval_t *i, unsigned int max);
|
||||||
|
int interval_refine(interval_t *i, const interval_t *v);
|
||||||
|
int interval_refine_first(interval_t *i);
|
||||||
|
int interval_refine_last(interval_t *i);
|
||||||
|
int interval_refine_set(interval_t *i, unsigned int val);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#ifdef INTERVAL_C
|
#ifdef INTERVAL_C
|
||||||
#define INLINE inline
|
#define INLINE inline
|
||||||
#else
|
#else
|
||||||
#define INLINE static inline
|
#define INLINE extern inline
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INLINE void interval_all(interval_t *i)
|
INLINE void interval_all(interval_t *i)
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MASK_C
|
#define MASK_C
|
||||||
|
#define MASK_INLINE
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
|
||||||
|
|
@ -27,14 +27,14 @@
|
||||||
|
|
||||||
#define MASK_MAX 32
|
#define MASK_MAX 32
|
||||||
|
|
||||||
#ifdef MASK_C
|
#ifdef MASK_INLINE
|
||||||
#include "mask_inline.h"
|
#include "mask_inline.h"
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
void mask_none(mask_t *mask);
|
void mask_none(mask_t *mask);
|
||||||
void mask_all(mask_t *mask);
|
void mask_all(mask_t *mask);
|
||||||
void mask_load(mask_t *mask, unsigned int msk);
|
void mask_load(mask_t *mask, unsigned int msk);
|
||||||
int mask_empty(const mask_t *mask);
|
int mask_empty(const mask_t *mask);
|
||||||
|
int mask_full(const mask_t *mask);
|
||||||
void mask_set(mask_t *mask, unsigned int val);
|
void mask_set(mask_t *mask, unsigned int val);
|
||||||
void mask_reset(mask_t *mask, unsigned int val);
|
void mask_reset(mask_t *mask, unsigned int val);
|
||||||
void mask_copy(mask_t *mask, const mask_t *v);
|
void mask_copy(mask_t *mask, const mask_t *v);
|
||||||
|
|
@ -55,3 +55,4 @@ int mask_refine_min(mask_t *mask, unsigned int val);
|
||||||
int mask_refine_max(mask_t *mask, unsigned int val);
|
int mask_refine_max(mask_t *mask, unsigned int val);
|
||||||
int mask_refine_set(mask_t *mask, unsigned int val);
|
int mask_refine_set(mask_t *mask, unsigned int val);
|
||||||
int mask_value(const mask_t *mask);
|
int mask_value(const mask_t *mask);
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,17 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#ifdef MASK_C
|
#ifdef MASK_C
|
||||||
#define INLINE inline
|
#define INLINE inline
|
||||||
#else
|
#else
|
||||||
#define INLINE static inline
|
#define INLINE extern inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MASK_MASK
|
||||||
|
#define MASK_MAX 32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct _mask {
|
struct _mask {
|
||||||
|
|
@ -90,6 +97,11 @@ INLINE int mask_empty(const mask_t *mask)
|
||||||
return mask_bits(mask) == 0;
|
return mask_bits(mask) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INLINE int mask_full(const mask_t *mask)
|
||||||
|
{
|
||||||
|
return mask_bits(mask) == ~0U;
|
||||||
|
}
|
||||||
|
|
||||||
INLINE unsigned int mask_count(const mask_t *mask)
|
INLINE unsigned int mask_count(const mask_t *mask)
|
||||||
{
|
{
|
||||||
return hweight32(mask_bits(mask));
|
return hweight32(mask_bits(mask));
|
||||||
|
|
|
||||||
272
src/pcm/pcm.c
272
src/pcm/pcm.c
|
|
@ -94,24 +94,6 @@ int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
|
||||||
return pcm->ops->info(pcm->op_arg, info);
|
return pcm->ops->info(pcm->op_arg, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
assert(pcm && params);
|
|
||||||
assert(pcm->setup);
|
|
||||||
if ((err = pcm->ops->sw_params(pcm->op_arg, params)) < 0)
|
|
||||||
return err;
|
|
||||||
pcm->start_mode = params->start_mode;
|
|
||||||
pcm->ready_mode = params->ready_mode;
|
|
||||||
pcm->xrun_mode = params->xrun_mode;
|
|
||||||
pcm->avail_min = params->avail_min;
|
|
||||||
pcm->xfer_min = params->xfer_min;
|
|
||||||
pcm->xfer_align = params->xfer_align;
|
|
||||||
pcm->time = params->time;
|
|
||||||
pcm->boundary = params->boundary;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int snd_pcm_status(snd_pcm_t *pcm, snd_pcm_status_t *status)
|
int snd_pcm_status(snd_pcm_t *pcm, snd_pcm_status_t *status)
|
||||||
{
|
{
|
||||||
assert(pcm && status);
|
assert(pcm && status);
|
||||||
|
|
@ -182,19 +164,6 @@ ssize_t snd_pcm_rewind(snd_pcm_t *pcm, size_t frames)
|
||||||
return pcm->fast_ops->rewind(pcm->fast_op_arg, frames);
|
return pcm->fast_ops->rewind(pcm->fast_op_arg, frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
int snd_pcm_set_avail_min(snd_pcm_t *pcm, size_t frames)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
assert(pcm);
|
|
||||||
assert(pcm->setup);
|
|
||||||
assert(frames > 0);
|
|
||||||
err = pcm->fast_ops->set_avail_min(pcm->fast_op_arg, frames);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
pcm->avail_min = frames;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, size_t size)
|
ssize_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
assert(pcm);
|
assert(pcm);
|
||||||
|
|
@ -311,6 +280,8 @@ int snd_pcm_poll_descriptor(snd_pcm_t *pcm)
|
||||||
#define STREAM(v) [SND_PCM_STREAM_##v] = #v
|
#define STREAM(v) [SND_PCM_STREAM_##v] = #v
|
||||||
#define READY(v) [SND_PCM_READY_##v] = #v
|
#define READY(v) [SND_PCM_READY_##v] = #v
|
||||||
#define XRUN(v) [SND_PCM_XRUN_##v] = #v
|
#define XRUN(v) [SND_PCM_XRUN_##v] = #v
|
||||||
|
#define SILENCE(v) [SND_PCM_SILENCE_##v] = #v
|
||||||
|
#define TSTAMP(v) [SND_PCM_TSTAMP_##v] = #v
|
||||||
#define ACCESS(v) [SND_PCM_ACCESS_##v] = #v
|
#define ACCESS(v) [SND_PCM_ACCESS_##v] = #v
|
||||||
#define START(v) [SND_PCM_START_##v] = #v
|
#define START(v) [SND_PCM_START_##v] = #v
|
||||||
#define HW_PARAM(v) [SND_PCM_HW_PARAM_##v] = #v
|
#define HW_PARAM(v) [SND_PCM_HW_PARAM_##v] = #v
|
||||||
|
|
@ -355,11 +326,13 @@ char *snd_pcm_hw_param_names[] = {
|
||||||
char *snd_pcm_sw_param_names[] = {
|
char *snd_pcm_sw_param_names[] = {
|
||||||
SW_PARAM(START_MODE),
|
SW_PARAM(START_MODE),
|
||||||
SW_PARAM(READY_MODE),
|
SW_PARAM(READY_MODE),
|
||||||
SW_PARAM(AVAIL_MIN),
|
|
||||||
SW_PARAM(XFER_MIN),
|
|
||||||
SW_PARAM(XFER_ALIGN),
|
|
||||||
SW_PARAM(XRUN_MODE),
|
SW_PARAM(XRUN_MODE),
|
||||||
SW_PARAM(TIME),
|
SW_PARAM(SILENCE_MODE),
|
||||||
|
SW_PARAM(TSTAMP_MODE),
|
||||||
|
SW_PARAM(AVAIL_MIN),
|
||||||
|
SW_PARAM(XFER_ALIGN),
|
||||||
|
SW_PARAM(SILENCE_THRESHOLD),
|
||||||
|
SW_PARAM(SILENCE_SIZE),
|
||||||
};
|
};
|
||||||
|
|
||||||
char *snd_pcm_access_names[] = {
|
char *snd_pcm_access_names[] = {
|
||||||
|
|
@ -447,125 +420,25 @@ char *snd_pcm_ready_mode_names[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
char *snd_pcm_xrun_mode_names[] = {
|
char *snd_pcm_xrun_mode_names[] = {
|
||||||
XRUN(ASAP),
|
|
||||||
XRUN(FRAGMENT),
|
XRUN(FRAGMENT),
|
||||||
|
XRUN(ASAP),
|
||||||
XRUN(NONE),
|
XRUN(NONE),
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *onoff[] = {
|
char *snd_pcm_silence_mode_names[] = {
|
||||||
[0] = "OFF",
|
SILENCE(FRAGMENT),
|
||||||
[1] = "ON",
|
SILENCE(ASAP),
|
||||||
};
|
};
|
||||||
|
|
||||||
#define assoc(value, names) ({ \
|
char *snd_pcm_tstamp_mode_names[] = {
|
||||||
unsigned int __v = value; \
|
TSTAMP(NONE),
|
||||||
assert(__v < sizeof(names) / sizeof(names[0])); \
|
TSTAMP(MMAP),
|
||||||
names[__v]; \
|
};
|
||||||
})
|
|
||||||
|
|
||||||
|
const char *snd_pcm_stream_name(unsigned int stream)
|
||||||
int snd_pcm_dump_hw_setup(snd_pcm_t *pcm, FILE *fp)
|
|
||||||
{
|
{
|
||||||
assert(pcm);
|
assert(stream <= SND_PCM_STREAM_LAST);
|
||||||
assert(fp);
|
return snd_pcm_stream_names[stream];
|
||||||
assert(pcm->setup);
|
|
||||||
fprintf(fp, "stream : %s\n", assoc(pcm->stream, snd_pcm_stream_names));
|
|
||||||
fprintf(fp, "access : %s\n", assoc(pcm->access, snd_pcm_access_names));
|
|
||||||
fprintf(fp, "format : %s\n", assoc(pcm->format, snd_pcm_format_names));
|
|
||||||
fprintf(fp, "subformat : %s\n", assoc(pcm->subformat, snd_pcm_subformat_names));
|
|
||||||
fprintf(fp, "channels : %u\n", pcm->channels);
|
|
||||||
fprintf(fp, "rate : %u\n", pcm->rate);
|
|
||||||
fprintf(fp, "exact rate : %g (%u/%u)\n", (double) pcm->rate_num / pcm->rate_den, pcm->rate_num, pcm->rate_den);
|
|
||||||
fprintf(fp, "msbits : %u\n", pcm->msbits);
|
|
||||||
fprintf(fp, "fragment_size: %lu\n", (long)pcm->fragment_size);
|
|
||||||
fprintf(fp, "fragments : %u\n", pcm->fragments);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, FILE *fp)
|
|
||||||
{
|
|
||||||
assert(pcm);
|
|
||||||
assert(fp);
|
|
||||||
assert(pcm->setup);
|
|
||||||
fprintf(fp, "start_mode : %s\n", assoc(pcm->start_mode, snd_pcm_start_mode_names));
|
|
||||||
fprintf(fp, "ready_mode : %s\n", assoc(pcm->ready_mode, snd_pcm_ready_mode_names));
|
|
||||||
fprintf(fp, "xrun_mode : %s\n", assoc(pcm->xrun_mode, snd_pcm_xrun_mode_names));
|
|
||||||
fprintf(fp, "avail_min : %ld\n", (long)pcm->avail_min);
|
|
||||||
fprintf(fp, "xfer_min : %ld\n", (long)pcm->xfer_min);
|
|
||||||
fprintf(fp, "xfer_align : %ld\n", (long)pcm->xfer_align);
|
|
||||||
fprintf(fp, "time : %s\n", assoc(pcm->time, onoff));
|
|
||||||
fprintf(fp, "boundary : %ld\n", (long)pcm->boundary);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int snd_pcm_dump_setup(snd_pcm_t *pcm, FILE *fp)
|
|
||||||
{
|
|
||||||
snd_pcm_dump_hw_setup(pcm, fp);
|
|
||||||
snd_pcm_dump_sw_setup(pcm, fp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int snd_pcm_dump_sw_params_fail(snd_pcm_sw_params_t *params, FILE *fp)
|
|
||||||
{
|
|
||||||
int k;
|
|
||||||
if (params->fail_mask == 0) {
|
|
||||||
fprintf(fp, "unknown sw_params failure reason\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
fprintf(fp, "sw_params failed on the following field value(s):\n");
|
|
||||||
for (k = 0; k <= SND_PCM_SW_PARAM_LAST; ++k) {
|
|
||||||
if (!(params->fail_mask & (1U << k)))
|
|
||||||
continue;
|
|
||||||
switch (k) {
|
|
||||||
case SND_PCM_SW_PARAM_START_MODE:
|
|
||||||
fprintf(fp, "start_mode: %s\n", assoc(params->start_mode, snd_pcm_start_mode_names));
|
|
||||||
break;
|
|
||||||
case SND_PCM_SW_PARAM_READY_MODE:
|
|
||||||
fprintf(fp, "ready_mode: %s\n", assoc(params->ready_mode, snd_pcm_ready_mode_names));
|
|
||||||
break;
|
|
||||||
case SND_PCM_SW_PARAM_XRUN_MODE:
|
|
||||||
fprintf(fp, "xrun_mode: %s\n", assoc(params->xrun_mode, snd_pcm_xrun_mode_names));
|
|
||||||
break;
|
|
||||||
case SND_PCM_SW_PARAM_AVAIL_MIN:
|
|
||||||
fprintf(fp, "avail_min: %ld\n", (long)params->avail_min);
|
|
||||||
break;
|
|
||||||
case SND_PCM_SW_PARAM_XFER_MIN:
|
|
||||||
fprintf(fp, "xfer_min: %ld\n", (long)params->xfer_min);
|
|
||||||
break;
|
|
||||||
case SND_PCM_SW_PARAM_XFER_ALIGN:
|
|
||||||
fprintf(fp, "xfer_align: %ld\n", (long)params->xfer_align);
|
|
||||||
break;
|
|
||||||
case SND_PCM_SW_PARAM_TIME:
|
|
||||||
fprintf(fp, "time: %d\n", params->time);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int snd_pcm_dump_status(snd_pcm_status_t *status, FILE *fp)
|
|
||||||
{
|
|
||||||
assert(status);
|
|
||||||
fprintf(fp, "state : %s\n", assoc(status->state, snd_pcm_state_names));
|
|
||||||
fprintf(fp, "trigger_time: %ld.%06ld\n",
|
|
||||||
status->trigger_time.tv_sec, status->trigger_time.tv_usec);
|
|
||||||
fprintf(fp, "tstamp : %ld.%06ld\n",
|
|
||||||
status->tstamp.tv_sec, status->tstamp.tv_usec);
|
|
||||||
fprintf(fp, "delay : %ld\n", (long)status->delay);
|
|
||||||
fprintf(fp, "avail : %ld\n", (long)status->avail);
|
|
||||||
fprintf(fp, "avail_max : %ld\n", (long)status->avail_max);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int snd_pcm_dump(snd_pcm_t *pcm, FILE *fp)
|
|
||||||
{
|
|
||||||
assert(pcm);
|
|
||||||
assert(fp);
|
|
||||||
pcm->ops->dump(pcm->op_arg, fp);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *snd_pcm_access_name(unsigned int access)
|
const char *snd_pcm_access_name(unsigned int access)
|
||||||
|
|
@ -608,6 +481,113 @@ const char *snd_pcm_hw_param_name(unsigned int param)
|
||||||
return snd_pcm_hw_param_names[param];
|
return snd_pcm_hw_param_names[param];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *snd_pcm_sw_param_name(unsigned int param)
|
||||||
|
{
|
||||||
|
assert(param <= SND_PCM_SW_PARAM_LAST);
|
||||||
|
return snd_pcm_sw_param_names[param];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *snd_pcm_start_mode_name(unsigned int mode)
|
||||||
|
{
|
||||||
|
assert(mode <= SND_PCM_START_LAST);
|
||||||
|
return snd_pcm_start_mode_names[mode];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *snd_pcm_ready_mode_name(unsigned int mode)
|
||||||
|
{
|
||||||
|
assert(mode <= SND_PCM_READY_LAST);
|
||||||
|
return snd_pcm_ready_mode_names[mode];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *snd_pcm_xrun_mode_name(unsigned int mode)
|
||||||
|
{
|
||||||
|
assert(mode <= SND_PCM_XRUN_LAST);
|
||||||
|
return snd_pcm_xrun_mode_names[mode];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *snd_pcm_silence_mode_name(unsigned int mode)
|
||||||
|
{
|
||||||
|
assert(mode <= SND_PCM_SILENCE_LAST);
|
||||||
|
return snd_pcm_silence_mode_names[mode];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *snd_pcm_tstamp_mode_name(unsigned int mode)
|
||||||
|
{
|
||||||
|
assert(mode <= SND_PCM_TSTAMP_LAST);
|
||||||
|
return snd_pcm_tstamp_mode_names[mode];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *snd_pcm_state_name(unsigned int state)
|
||||||
|
{
|
||||||
|
assert(state <= SND_PCM_STATE_LAST);
|
||||||
|
return snd_pcm_state_names[state];
|
||||||
|
}
|
||||||
|
|
||||||
|
int snd_pcm_dump_hw_setup(snd_pcm_t *pcm, FILE *fp)
|
||||||
|
{
|
||||||
|
assert(pcm);
|
||||||
|
assert(fp);
|
||||||
|
assert(pcm->setup);
|
||||||
|
fprintf(fp, "stream : %s\n", snd_pcm_stream_name(pcm->stream));
|
||||||
|
fprintf(fp, "access : %s\n", snd_pcm_access_name(pcm->access));
|
||||||
|
fprintf(fp, "format : %s\n", snd_pcm_format_name(pcm->format));
|
||||||
|
fprintf(fp, "subformat : %s\n", snd_pcm_subformat_name(pcm->subformat));
|
||||||
|
fprintf(fp, "channels : %u\n", pcm->channels);
|
||||||
|
fprintf(fp, "rate : %u\n", pcm->rate);
|
||||||
|
fprintf(fp, "exact rate : %g (%u/%u)\n", (double) pcm->rate_num / pcm->rate_den, pcm->rate_num, pcm->rate_den);
|
||||||
|
fprintf(fp, "msbits : %u\n", pcm->msbits);
|
||||||
|
fprintf(fp, "fragment_size: %lu\n", (long)pcm->fragment_size);
|
||||||
|
fprintf(fp, "fragments : %u\n", pcm->fragments);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, FILE *fp)
|
||||||
|
{
|
||||||
|
assert(pcm);
|
||||||
|
assert(fp);
|
||||||
|
assert(pcm->setup);
|
||||||
|
fprintf(fp, "start_mode : %s\n", snd_pcm_start_mode_name(pcm->start_mode));
|
||||||
|
fprintf(fp, "xrun_mode : %s\n", snd_pcm_xrun_mode_name(pcm->xrun_mode));
|
||||||
|
fprintf(fp, "ready_mode : %s\n", snd_pcm_ready_mode_name(pcm->ready_mode));
|
||||||
|
fprintf(fp, "silence_mode : %s\n", snd_pcm_silence_mode_name(pcm->silence_mode));
|
||||||
|
fprintf(fp, "tstamp_mode : %s\n", snd_pcm_tstamp_mode_name(pcm->tstamp_mode));
|
||||||
|
fprintf(fp, "avail_min : %ld\n", (long)pcm->avail_min);
|
||||||
|
fprintf(fp, "xfer_align : %ld\n", (long)pcm->xfer_align);
|
||||||
|
fprintf(fp, "silence_threshold: %ld\n", (long)pcm->silence_threshold);
|
||||||
|
fprintf(fp, "silence_size : %ld\n", (long)pcm->silence_size);
|
||||||
|
fprintf(fp, "boundary : %ld\n", (long)pcm->boundary);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int snd_pcm_dump_setup(snd_pcm_t *pcm, FILE *fp)
|
||||||
|
{
|
||||||
|
snd_pcm_dump_hw_setup(pcm, fp);
|
||||||
|
snd_pcm_dump_sw_setup(pcm, fp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int snd_pcm_status_dump(snd_pcm_status_t *status, FILE *fp)
|
||||||
|
{
|
||||||
|
assert(status);
|
||||||
|
fprintf(fp, "state : %s\n", snd_pcm_state_name(status->state));
|
||||||
|
fprintf(fp, "trigger_time: %ld.%06ld\n",
|
||||||
|
status->trigger_time.tv_sec, status->trigger_time.tv_usec);
|
||||||
|
fprintf(fp, "tstamp : %ld.%06ld\n",
|
||||||
|
status->tstamp.tv_sec, status->tstamp.tv_usec);
|
||||||
|
fprintf(fp, "delay : %ld\n", (long)status->delay);
|
||||||
|
fprintf(fp, "avail : %ld\n", (long)status->avail);
|
||||||
|
fprintf(fp, "avail_max : %ld\n", (long)status->avail_max);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int snd_pcm_dump(snd_pcm_t *pcm, FILE *fp)
|
||||||
|
{
|
||||||
|
assert(pcm);
|
||||||
|
assert(fp);
|
||||||
|
pcm->ops->dump(pcm->op_arg, fp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t snd_pcm_bytes_to_frames(snd_pcm_t *pcm, ssize_t bytes)
|
ssize_t snd_pcm_bytes_to_frames(snd_pcm_t *pcm, ssize_t bytes)
|
||||||
{
|
{
|
||||||
assert(pcm);
|
assert(pcm);
|
||||||
|
|
|
||||||
|
|
@ -339,36 +339,36 @@ static int snd_pcm_adpcm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
mask_t *saccess_mask = alloca(mask_sizeof());
|
mask_t *saccess_mask = alloca(mask_sizeof());
|
||||||
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
err = _snd_pcm_hw_params_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
err = _snd_pcm_hw_param_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
||||||
access_mask);
|
access_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) {
|
if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) {
|
||||||
mask_t *format_mask = alloca(mask_sizeof());
|
mask_t *format_mask = alloca(mask_sizeof());
|
||||||
mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
||||||
err = _snd_pcm_hw_params_mask(params, 1,
|
err = _snd_pcm_hw_param_mask(params, 1,
|
||||||
SND_PCM_HW_PARAM_FORMAT,
|
SND_PCM_HW_PARAM_FORMAT,
|
||||||
format_mask);
|
format_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
} else {
|
} else {
|
||||||
err = _snd_pcm_hw_params_set(params, 1,
|
err = _snd_pcm_hw_param_set(params, 1,
|
||||||
SND_PCM_HW_PARAM_FORMAT,
|
SND_PCM_HW_PARAM_FORMAT,
|
||||||
SND_PCM_FORMAT_IMA_ADPCM);
|
SND_PCM_FORMAT_IMA_ADPCM);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
err = _snd_pcm_hw_params_set(params, 1, SND_PCM_HW_PARAM_SUBFORMAT,
|
err = _snd_pcm_hw_param_set(params, 1, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
||||||
adpcm->sformat);
|
adpcm->sformat);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
err = snd_pcm_hw_refine2(params, &sparams,
|
err = snd_pcm_hw_refine2(params, &sparams,
|
||||||
snd_pcm_hw_refine, slave,
|
snd_pcm_hw_refine, slave,
|
||||||
|
|
@ -395,11 +395,11 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
||||||
adpcm->sformat);
|
adpcm->sformat);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
err = snd_pcm_hw_params2(params, &sparams,
|
err = snd_pcm_hw_params2(params, &sparams,
|
||||||
snd_pcm_hw_params, slave,
|
snd_pcm_hw_params, slave,
|
||||||
|
|
@ -415,7 +415,7 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
||||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||||
if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) {
|
if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) {
|
||||||
adpcm->getput_idx = get_index(snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_FORMAT), SND_PCM_FORMAT_S16);
|
adpcm->getput_idx = get_index(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT), SND_PCM_FORMAT_S16);
|
||||||
adpcm->func = adpcm_encode;
|
adpcm->func = adpcm_encode;
|
||||||
} else {
|
} else {
|
||||||
adpcm->getput_idx = put_index(SND_PCM_FORMAT_S16, adpcm->sformat);
|
adpcm->getput_idx = put_index(SND_PCM_FORMAT_S16, adpcm->sformat);
|
||||||
|
|
@ -423,7 +423,7 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) {
|
if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) {
|
||||||
adpcm->getput_idx = put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_FORMAT));
|
adpcm->getput_idx = put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT));
|
||||||
adpcm->func = adpcm_decode;
|
adpcm->func = adpcm_decode;
|
||||||
} else {
|
} else {
|
||||||
adpcm->getput_idx = get_index(adpcm->sformat, SND_PCM_FORMAT_S16);
|
adpcm->getput_idx = get_index(adpcm->sformat, SND_PCM_FORMAT_S16);
|
||||||
|
|
@ -432,7 +432,7 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
}
|
}
|
||||||
if (adpcm->states)
|
if (adpcm->states)
|
||||||
free(adpcm->states);
|
free(adpcm->states);
|
||||||
adpcm->states = malloc(snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_CHANNELS) * sizeof(*adpcm->states));
|
adpcm->states = malloc(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_CHANNELS) * sizeof(*adpcm->states));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -221,36 +221,36 @@ static int snd_pcm_alaw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
mask_t *saccess_mask = alloca(mask_sizeof());
|
mask_t *saccess_mask = alloca(mask_sizeof());
|
||||||
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
err = _snd_pcm_hw_params_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
err = _snd_pcm_hw_param_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
||||||
access_mask);
|
access_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
if (alaw->sformat == SND_PCM_FORMAT_A_LAW) {
|
if (alaw->sformat == SND_PCM_FORMAT_A_LAW) {
|
||||||
mask_t *format_mask = alloca(mask_sizeof());
|
mask_t *format_mask = alloca(mask_sizeof());
|
||||||
mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
||||||
err = _snd_pcm_hw_params_mask(params, 1,
|
err = _snd_pcm_hw_param_mask(params, 1,
|
||||||
SND_PCM_HW_PARAM_FORMAT,
|
SND_PCM_HW_PARAM_FORMAT,
|
||||||
format_mask);
|
format_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
} else {
|
} else {
|
||||||
err = _snd_pcm_hw_params_set(params, 1,
|
err = _snd_pcm_hw_param_set(params, 1,
|
||||||
SND_PCM_HW_PARAM_FORMAT,
|
SND_PCM_HW_PARAM_FORMAT,
|
||||||
SND_PCM_FORMAT_A_LAW);
|
SND_PCM_FORMAT_A_LAW);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
err = _snd_pcm_hw_params_set(params, 1, SND_PCM_HW_PARAM_SUBFORMAT,
|
err = _snd_pcm_hw_param_set(params, 1, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
||||||
alaw->sformat);
|
alaw->sformat);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
err = snd_pcm_hw_refine2(params, &sparams,
|
err = snd_pcm_hw_refine2(params, &sparams,
|
||||||
snd_pcm_hw_refine, slave,
|
snd_pcm_hw_refine, slave,
|
||||||
|
|
@ -277,11 +277,11 @@ static int snd_pcm_alaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
||||||
alaw->sformat);
|
alaw->sformat);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
err = snd_pcm_hw_params2(params, &sparams,
|
err = snd_pcm_hw_params2(params, &sparams,
|
||||||
snd_pcm_hw_params, slave,
|
snd_pcm_hw_params, slave,
|
||||||
|
|
@ -297,7 +297,7 @@ static int snd_pcm_alaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
||||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||||
if (alaw->sformat == SND_PCM_FORMAT_A_LAW) {
|
if (alaw->sformat == SND_PCM_FORMAT_A_LAW) {
|
||||||
alaw->getput_idx = get_index(snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_FORMAT), SND_PCM_FORMAT_S16);
|
alaw->getput_idx = get_index(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT), SND_PCM_FORMAT_S16);
|
||||||
alaw->func = alaw_encode;
|
alaw->func = alaw_encode;
|
||||||
} else {
|
} else {
|
||||||
alaw->getput_idx = put_index(SND_PCM_FORMAT_S16, alaw->sformat);
|
alaw->getput_idx = put_index(SND_PCM_FORMAT_S16, alaw->sformat);
|
||||||
|
|
@ -305,7 +305,7 @@ static int snd_pcm_alaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (alaw->sformat == SND_PCM_FORMAT_A_LAW) {
|
if (alaw->sformat == SND_PCM_FORMAT_A_LAW) {
|
||||||
alaw->getput_idx = put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_FORMAT));
|
alaw->getput_idx = put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT));
|
||||||
alaw->func = alaw_decode;
|
alaw->func = alaw_decode;
|
||||||
} else {
|
} else {
|
||||||
alaw->getput_idx = get_index(alaw->sformat, SND_PCM_FORMAT_S16);
|
alaw->getput_idx = get_index(alaw->sformat, SND_PCM_FORMAT_S16);
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,12 @@ static int snd_pcm_copy_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
mask_t *saccess_mask = alloca(mask_sizeof());
|
mask_t *saccess_mask = alloca(mask_sizeof());
|
||||||
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
err = _snd_pcm_hw_params_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
err = _snd_pcm_hw_param_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
||||||
access_mask);
|
access_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
err = snd_pcm_hw_refine2(params, &sparams,
|
err = snd_pcm_hw_refine2(params, &sparams,
|
||||||
snd_pcm_hw_refine, slave,
|
snd_pcm_hw_refine, slave,
|
||||||
|
|
@ -64,7 +64,7 @@ static int snd_pcm_copy_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
err = snd_pcm_hw_params2(params, &sparams,
|
err = snd_pcm_hw_params2(params, &sparams,
|
||||||
snd_pcm_hw_params, slave,
|
snd_pcm_hw_params, slave,
|
||||||
|
|
|
||||||
|
|
@ -254,12 +254,6 @@ static ssize_t snd_pcm_file_avail_update(snd_pcm_t *pcm)
|
||||||
return snd_pcm_avail_update(file->slave);
|
return snd_pcm_avail_update(file->slave);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_file_set_avail_min(snd_pcm_t *pcm, size_t frames)
|
|
||||||
{
|
|
||||||
snd_pcm_file_t *file = pcm->private;
|
|
||||||
return snd_pcm_set_avail_min(file->slave, frames);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int snd_pcm_file_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
static int snd_pcm_file_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
{
|
{
|
||||||
snd_pcm_file_t *file = pcm->private;
|
snd_pcm_file_t *file = pcm->private;
|
||||||
|
|
@ -337,7 +331,6 @@ snd_pcm_fast_ops_t snd_pcm_file_fast_ops = {
|
||||||
readn: snd_pcm_file_readn,
|
readn: snd_pcm_file_readn,
|
||||||
avail_update: snd_pcm_file_avail_update,
|
avail_update: snd_pcm_file_avail_update,
|
||||||
mmap_forward: snd_pcm_file_mmap_forward,
|
mmap_forward: snd_pcm_file_mmap_forward,
|
||||||
set_avail_min: snd_pcm_file_set_avail_min,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int snd_pcm_file_open(snd_pcm_t **pcmp, char *name, char *fname, int fd, char *fmt, snd_pcm_t *slave, int close_slave)
|
int snd_pcm_file_open(snd_pcm_t **pcmp, char *name, char *fname, int fd, char *fmt, snd_pcm_t *slave, int close_slave)
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,17 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
|
||||||
{
|
{
|
||||||
snd_pcm_hw_t *hw = pcm->private;
|
snd_pcm_hw_t *hw = pcm->private;
|
||||||
int fd = hw->fd;
|
int fd = hw->fd;
|
||||||
|
if (params->start_mode == pcm->start_mode &&
|
||||||
|
params->ready_mode == pcm->ready_mode &&
|
||||||
|
params->xrun_mode == pcm->xrun_mode &&
|
||||||
|
params->silence_mode == pcm->silence_mode &&
|
||||||
|
params->tstamp_mode == pcm->tstamp_mode &&
|
||||||
|
params->xfer_align == pcm->xfer_align &&
|
||||||
|
params->silence_threshold == pcm->silence_threshold &&
|
||||||
|
params->silence_size == pcm->silence_size) {
|
||||||
|
hw->mmap_control->avail_min = params->avail_min;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (ioctl(fd, SND_PCM_IOCTL_SW_PARAMS, params) < 0) {
|
if (ioctl(fd, SND_PCM_IOCTL_SW_PARAMS, params) < 0) {
|
||||||
SYSERR("SND_PCM_IOCTL_SW_PARAMS failed");
|
SYSERR("SND_PCM_IOCTL_SW_PARAMS failed");
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
@ -482,13 +493,6 @@ static ssize_t snd_pcm_hw_avail_update(snd_pcm_t *pcm)
|
||||||
return avail;
|
return avail;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_hw_set_avail_min(snd_pcm_t *pcm, size_t frames)
|
|
||||||
{
|
|
||||||
snd_pcm_hw_t *hw = pcm->private;
|
|
||||||
hw->mmap_control->avail_min = frames;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void snd_pcm_hw_dump(snd_pcm_t *pcm, FILE *fp)
|
static void snd_pcm_hw_dump(snd_pcm_t *pcm, FILE *fp)
|
||||||
{
|
{
|
||||||
snd_pcm_hw_t *hw = pcm->private;
|
snd_pcm_hw_t *hw = pcm->private;
|
||||||
|
|
@ -535,7 +539,6 @@ snd_pcm_fast_ops_t snd_pcm_hw_fast_ops = {
|
||||||
readn: snd_pcm_hw_readn,
|
readn: snd_pcm_hw_readn,
|
||||||
avail_update: snd_pcm_hw_avail_update,
|
avail_update: snd_pcm_hw_avail_update,
|
||||||
mmap_forward: snd_pcm_hw_mmap_forward,
|
mmap_forward: snd_pcm_hw_mmap_forward,
|
||||||
set_avail_min: snd_pcm_hw_set_avail_min,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int snd_pcm_hw_open_subdevice(snd_pcm_t **pcmp, int card, int device, int subdevice, int stream, int mode)
|
int snd_pcm_hw_open_subdevice(snd_pcm_t **pcmp, int card, int device, int subdevice, int stream, int mode)
|
||||||
|
|
|
||||||
|
|
@ -84,25 +84,25 @@ static int snd_pcm_linear_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||||
mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
err = _snd_pcm_hw_params_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
err = _snd_pcm_hw_param_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
||||||
access_mask);
|
access_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = _snd_pcm_hw_params_mask(params, 1, SND_PCM_HW_PARAM_FORMAT,
|
err = _snd_pcm_hw_param_mask(params, 1, SND_PCM_HW_PARAM_FORMAT,
|
||||||
format_mask);
|
format_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = _snd_pcm_hw_params_set(params, 1, SND_PCM_HW_PARAM_SUBFORMAT,
|
err = _snd_pcm_hw_param_set(params, 1, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
||||||
linear->sformat);
|
linear->sformat);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
err = snd_pcm_hw_refine2(params, &sparams,
|
err = snd_pcm_hw_refine2(params, &sparams,
|
||||||
snd_pcm_hw_refine, slave,
|
snd_pcm_hw_refine, slave,
|
||||||
|
|
@ -129,11 +129,11 @@ static int snd_pcm_linear_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
||||||
linear->sformat);
|
linear->sformat);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
err = snd_pcm_hw_params2(params, &sparams,
|
err = snd_pcm_hw_params2(params, &sparams,
|
||||||
snd_pcm_hw_params, slave,
|
snd_pcm_hw_params, slave,
|
||||||
|
|
@ -148,11 +148,11 @@ static int snd_pcm_linear_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
return err;
|
return err;
|
||||||
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
||||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
|
if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
|
||||||
linear->conv_idx = conv_index(snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_FORMAT),
|
linear->conv_idx = conv_index(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT),
|
||||||
linear->sformat);
|
linear->sformat);
|
||||||
else
|
else
|
||||||
linear->conv_idx = conv_index(linear->sformat,
|
linear->conv_idx = conv_index(linear->sformat,
|
||||||
snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_FORMAT));
|
snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,6 @@ typedef struct {
|
||||||
ssize_t (*readn)(snd_pcm_t *pcm, void **bufs, size_t size);
|
ssize_t (*readn)(snd_pcm_t *pcm, void **bufs, size_t size);
|
||||||
ssize_t (*avail_update)(snd_pcm_t *pcm);
|
ssize_t (*avail_update)(snd_pcm_t *pcm);
|
||||||
ssize_t (*mmap_forward)(snd_pcm_t *pcm, size_t size);
|
ssize_t (*mmap_forward)(snd_pcm_t *pcm, size_t size);
|
||||||
int (*set_avail_min)(snd_pcm_t *pcm, size_t frames);
|
|
||||||
} snd_pcm_fast_ops_t;
|
} snd_pcm_fast_ops_t;
|
||||||
|
|
||||||
struct _snd_pcm {
|
struct _snd_pcm {
|
||||||
|
|
@ -104,12 +103,15 @@ struct _snd_pcm {
|
||||||
size_t fragment_size; /* fragment size */
|
size_t fragment_size; /* fragment size */
|
||||||
unsigned int fragments; /* fragments */
|
unsigned int fragments; /* fragments */
|
||||||
unsigned int start_mode; /* start mode */
|
unsigned int start_mode; /* start mode */
|
||||||
unsigned int ready_mode; /* ready detection mode */
|
|
||||||
unsigned int xrun_mode; /* xrun detection mode */
|
unsigned int xrun_mode; /* xrun detection mode */
|
||||||
|
unsigned int ready_mode; /* ready detection mode */
|
||||||
|
unsigned int tstamp_mode; /* timestamp mode */
|
||||||
size_t avail_min; /* min avail frames for wakeup */
|
size_t avail_min; /* min avail frames for wakeup */
|
||||||
size_t xfer_min; /* xfer min size */
|
unsigned int silence_mode; /* Silence filling mode */
|
||||||
|
size_t silence_threshold; /* Silence filling happens when
|
||||||
|
noise is nearest than this */
|
||||||
|
size_t silence_size; /* Silence filling size */
|
||||||
size_t xfer_align; /* xfer size need to be a multiple */
|
size_t xfer_align; /* xfer size need to be a multiple */
|
||||||
unsigned int time: 1; /* timestamp switch */
|
|
||||||
size_t boundary; /* pointers wrap point */
|
size_t boundary; /* pointers wrap point */
|
||||||
unsigned int info; /* Info for returned setup */
|
unsigned int info; /* Info for returned setup */
|
||||||
unsigned int msbits; /* used most significant bits */
|
unsigned int msbits; /* used most significant bits */
|
||||||
|
|
@ -120,6 +122,7 @@ struct _snd_pcm {
|
||||||
size_t bits_per_sample;
|
size_t bits_per_sample;
|
||||||
size_t bits_per_frame;
|
size_t bits_per_frame;
|
||||||
size_t *appl_ptr;
|
size_t *appl_ptr;
|
||||||
|
size_t min_align;
|
||||||
volatile size_t *hw_ptr;
|
volatile size_t *hw_ptr;
|
||||||
int mmap_rw;
|
int mmap_rw;
|
||||||
snd_pcm_channel_info_t *mmap_channels;
|
snd_pcm_channel_info_t *mmap_channels;
|
||||||
|
|
@ -168,7 +171,6 @@ ssize_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_t *areas,
|
||||||
snd_pcm_xfer_areas_func_t func);
|
snd_pcm_xfer_areas_func_t func);
|
||||||
ssize_t snd_pcm_read_mmap(snd_pcm_t *pcm, size_t size);
|
ssize_t snd_pcm_read_mmap(snd_pcm_t *pcm, size_t size);
|
||||||
ssize_t snd_pcm_write_mmap(snd_pcm_t *pcm, size_t size);
|
ssize_t snd_pcm_write_mmap(snd_pcm_t *pcm, size_t size);
|
||||||
int snd_pcm_hw_info_complete(snd_pcm_hw_params_t *info);
|
|
||||||
int snd_pcm_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *info);
|
int snd_pcm_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *info);
|
||||||
int snd_pcm_channel_info_shm(snd_pcm_t *pcm, snd_pcm_channel_info_t *info, int shmid);
|
int snd_pcm_channel_info_shm(snd_pcm_t *pcm, snd_pcm_channel_info_t *info, int shmid);
|
||||||
|
|
||||||
|
|
@ -313,17 +315,17 @@ static inline int muldiv_near(int a, int b, int c)
|
||||||
|
|
||||||
int _snd_pcm_hw_refine(snd_pcm_hw_params_t *params);
|
int _snd_pcm_hw_refine(snd_pcm_hw_params_t *params);
|
||||||
void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params);
|
void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params);
|
||||||
int _snd_pcm_hw_params_mask(snd_pcm_hw_params_t *params, int hw,
|
int _snd_pcm_hw_param_mask(snd_pcm_hw_params_t *params, int hw,
|
||||||
unsigned int var, const mask_t *mask);
|
unsigned int var, const mask_t *mask);
|
||||||
int _snd_pcm_hw_params_first(snd_pcm_hw_params_t *params, int hw,
|
int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params, int hw,
|
||||||
unsigned int var);
|
unsigned int var);
|
||||||
int _snd_pcm_hw_params_last(snd_pcm_hw_params_t *params, int hw,
|
int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params, int hw,
|
||||||
unsigned int var);
|
unsigned int var);
|
||||||
int _snd_pcm_hw_params_set(snd_pcm_hw_params_t *params, int hw,
|
int _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params, int hw,
|
||||||
unsigned int var, unsigned int val);
|
unsigned int var, unsigned int val);
|
||||||
int _snd_pcm_hw_params_min(snd_pcm_hw_params_t *params, int hw,
|
int _snd_pcm_hw_param_min(snd_pcm_hw_params_t *params, int hw,
|
||||||
unsigned int var, unsigned int val);
|
unsigned int var, unsigned int val);
|
||||||
int _snd_pcm_hw_params_max(snd_pcm_hw_params_t *params, int hw,
|
int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params, int hw,
|
||||||
unsigned int var, unsigned int val);
|
unsigned int var, unsigned int val);
|
||||||
int snd_pcm_hw_refine2(snd_pcm_hw_params_t *params,
|
int snd_pcm_hw_refine2(snd_pcm_hw_params_t *params,
|
||||||
snd_pcm_hw_params_t *sparams,
|
snd_pcm_hw_params_t *sparams,
|
||||||
|
|
|
||||||
|
|
@ -238,37 +238,37 @@ static int snd_pcm_mulaw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
mask_t *saccess_mask = alloca(mask_sizeof());
|
mask_t *saccess_mask = alloca(mask_sizeof());
|
||||||
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
err = _snd_pcm_hw_params_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
err = _snd_pcm_hw_param_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
||||||
access_mask);
|
access_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) {
|
if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) {
|
||||||
mask_t *format_mask = alloca(mask_sizeof());
|
mask_t *format_mask = alloca(mask_sizeof());
|
||||||
mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
||||||
err = _snd_pcm_hw_params_mask(params, 1,
|
err = _snd_pcm_hw_param_mask(params, 1,
|
||||||
SND_PCM_HW_PARAM_FORMAT,
|
SND_PCM_HW_PARAM_FORMAT,
|
||||||
format_mask);
|
format_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
} else {
|
} else {
|
||||||
err = _snd_pcm_hw_params_set(params, 1,
|
err = _snd_pcm_hw_param_set(params, 1,
|
||||||
SND_PCM_HW_PARAM_FORMAT,
|
SND_PCM_HW_PARAM_FORMAT,
|
||||||
SND_PCM_FORMAT_MU_LAW);
|
SND_PCM_FORMAT_MU_LAW);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
err = _snd_pcm_hw_params_set(params, 1, SND_PCM_HW_PARAM_SUBFORMAT,
|
err = _snd_pcm_hw_param_set(params, 1, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
||||||
mulaw->sformat);
|
mulaw->sformat);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
err = snd_pcm_hw_refine2(params, &sparams,
|
err = snd_pcm_hw_refine2(params, &sparams,
|
||||||
snd_pcm_hw_refine, slave,
|
snd_pcm_hw_refine, slave,
|
||||||
SND_PCM_HW_PARBIT_CHANNELS |
|
SND_PCM_HW_PARBIT_CHANNELS |
|
||||||
|
|
@ -294,12 +294,12 @@ static int snd_pcm_mulaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
||||||
mulaw->sformat);
|
mulaw->sformat);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
err = snd_pcm_hw_params2(params, &sparams,
|
err = snd_pcm_hw_params2(params, &sparams,
|
||||||
snd_pcm_hw_params, slave,
|
snd_pcm_hw_params, slave,
|
||||||
SND_PCM_HW_PARBIT_CHANNELS |
|
SND_PCM_HW_PARBIT_CHANNELS |
|
||||||
|
|
@ -314,7 +314,7 @@ static int snd_pcm_mulaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
||||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||||
if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) {
|
if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) {
|
||||||
mulaw->getput_idx = get_index(snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_FORMAT), SND_PCM_FORMAT_S16);
|
mulaw->getput_idx = get_index(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT), SND_PCM_FORMAT_S16);
|
||||||
mulaw->func = mulaw_encode;
|
mulaw->func = mulaw_encode;
|
||||||
} else {
|
} else {
|
||||||
mulaw->getput_idx = put_index(SND_PCM_FORMAT_S16, mulaw->sformat);
|
mulaw->getput_idx = put_index(SND_PCM_FORMAT_S16, mulaw->sformat);
|
||||||
|
|
@ -322,7 +322,7 @@ static int snd_pcm_mulaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) {
|
if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) {
|
||||||
mulaw->getput_idx = put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_FORMAT));
|
mulaw->getput_idx = put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT));
|
||||||
mulaw->func = mulaw_decode;
|
mulaw->func = mulaw_decode;
|
||||||
} else {
|
} else {
|
||||||
mulaw->getput_idx = get_index(mulaw->sformat, SND_PCM_FORMAT_S16);
|
mulaw->getput_idx = get_index(mulaw->sformat, SND_PCM_FORMAT_S16);
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ static int snd_pcm_multi_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
snd_pcm_hw_params_t sparams;
|
snd_pcm_hw_params_t sparams;
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
int err;
|
int err;
|
||||||
const mask_t *access_mask = snd_pcm_hw_params_value_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
const mask_t *access_mask = snd_pcm_hw_param_value_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
||||||
mask_t *saccess_mask = alloca(mask_sizeof());
|
mask_t *saccess_mask = alloca(mask_sizeof());
|
||||||
if (mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) ||
|
if (mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) ||
|
||||||
mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED))
|
mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED))
|
||||||
|
|
@ -122,7 +122,7 @@ static int snd_pcm_multi_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = _snd_pcm_hw_params_set(params, 1, SND_PCM_HW_PARAM_CHANNELS,
|
err = _snd_pcm_hw_param_set(params, 1, SND_PCM_HW_PARAM_CHANNELS,
|
||||||
multi->channels_count);
|
multi->channels_count);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
@ -131,10 +131,10 @@ static int snd_pcm_multi_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
for (k = 0; k < multi->slaves_count; ++k) {
|
for (k = 0; k < multi->slaves_count; ++k) {
|
||||||
snd_pcm_t *slave = multi->slaves[k].pcm;
|
snd_pcm_t *slave = multi->slaves[k].pcm;
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0,
|
_snd_pcm_hw_param_mask(&sparams, 0,
|
||||||
SND_PCM_HW_PARAM_ACCESS,
|
SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0,
|
_snd_pcm_hw_param_set(&sparams, 0,
|
||||||
SND_PCM_HW_PARAM_CHANNELS,
|
SND_PCM_HW_PARAM_CHANNELS,
|
||||||
multi->slaves[k].channels_count);
|
multi->slaves[k].channels_count);
|
||||||
err = snd_pcm_hw_refine2(params, &sparams,
|
err = snd_pcm_hw_refine2(params, &sparams,
|
||||||
|
|
@ -161,7 +161,7 @@ static int snd_pcm_multi_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
snd_pcm_multi_t *multi = pcm->private;
|
snd_pcm_multi_t *multi = pcm->private;
|
||||||
unsigned int k;
|
unsigned int k;
|
||||||
int err;
|
int err;
|
||||||
const mask_t *access_mask = snd_pcm_hw_params_value_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
const mask_t *access_mask = snd_pcm_hw_param_value_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
||||||
mask_t *saccess_mask = alloca(mask_sizeof());
|
mask_t *saccess_mask = alloca(mask_sizeof());
|
||||||
if (mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) ||
|
if (mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) ||
|
||||||
mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED))
|
mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED))
|
||||||
|
|
@ -183,9 +183,9 @@ static int snd_pcm_multi_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
snd_pcm_t *slave = multi->slaves[k].pcm;
|
snd_pcm_t *slave = multi->slaves[k].pcm;
|
||||||
snd_pcm_hw_params_t sparams;
|
snd_pcm_hw_params_t sparams;
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_CHANNELS,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_CHANNELS,
|
||||||
multi->slaves[k].channels_count);
|
multi->slaves[k].channels_count);
|
||||||
err = snd_pcm_hw_params2(params, &sparams,
|
err = snd_pcm_hw_params2(params, &sparams,
|
||||||
snd_pcm_hw_params, slave,
|
snd_pcm_hw_params, slave,
|
||||||
|
|
@ -347,12 +347,6 @@ static ssize_t snd_pcm_multi_mmap_forward(snd_pcm_t *pcm, size_t size)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_multi_set_avail_min(snd_pcm_t *pcm, size_t frames)
|
|
||||||
{
|
|
||||||
snd_pcm_multi_t *multi = pcm->private;
|
|
||||||
return snd_pcm_set_avail_min(multi->slaves[0].pcm, frames);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int snd_pcm_multi_mmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
|
static int snd_pcm_multi_mmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -425,7 +419,6 @@ snd_pcm_fast_ops_t snd_pcm_multi_fast_ops = {
|
||||||
rewind: snd_pcm_multi_rewind,
|
rewind: snd_pcm_multi_rewind,
|
||||||
avail_update: snd_pcm_multi_avail_update,
|
avail_update: snd_pcm_multi_avail_update,
|
||||||
mmap_forward: snd_pcm_multi_mmap_forward,
|
mmap_forward: snd_pcm_multi_mmap_forward,
|
||||||
set_avail_min: snd_pcm_multi_set_avail_min,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int snd_pcm_multi_open(snd_pcm_t **pcmp, char *name,
|
int snd_pcm_multi_open(snd_pcm_t **pcmp, char *name,
|
||||||
|
|
|
||||||
|
|
@ -229,17 +229,11 @@ static ssize_t snd_pcm_null_avail_update(snd_pcm_t *pcm)
|
||||||
return pcm->buffer_size;
|
return pcm->buffer_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_null_set_avail_min(snd_pcm_t *pcm, size_t frames)
|
|
||||||
{
|
|
||||||
pcm->avail_min = frames;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int snd_pcm_null_hw_refine(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params)
|
static int snd_pcm_null_hw_refine(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params)
|
||||||
{
|
{
|
||||||
_snd_pcm_hw_refine(params);
|
int err = _snd_pcm_hw_refine(params);
|
||||||
params->fifo_size = 0;
|
params->fifo_size = 0;
|
||||||
return 0;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_null_hw_params(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t * params ATTRIBUTE_UNUSED)
|
static int snd_pcm_null_hw_params(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t * params ATTRIBUTE_UNUSED)
|
||||||
|
|
@ -247,20 +241,8 @@ static int snd_pcm_null_hw_params(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_pa
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_null_sw_params(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t * params)
|
static int snd_pcm_null_sw_params(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t * params ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
if (params->start_mode > SND_PCM_START_LAST) {
|
|
||||||
params->fail_mask = 1 << SND_PCM_SW_PARAM_START_MODE;
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
if (params->ready_mode > SND_PCM_READY_LAST) {
|
|
||||||
params->fail_mask = 1 << SND_PCM_SW_PARAM_READY_MODE;
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
if (params->xrun_mode > SND_PCM_XRUN_LAST) {
|
|
||||||
params->fail_mask = 1 << SND_PCM_SW_PARAM_XRUN_MODE;
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -330,7 +312,6 @@ snd_pcm_fast_ops_t snd_pcm_null_fast_ops = {
|
||||||
readn: snd_pcm_null_readn,
|
readn: snd_pcm_null_readn,
|
||||||
avail_update: snd_pcm_null_avail_update,
|
avail_update: snd_pcm_null_avail_update,
|
||||||
mmap_forward: snd_pcm_null_mmap_forward,
|
mmap_forward: snd_pcm_null_mmap_forward,
|
||||||
set_avail_min: snd_pcm_null_set_avail_min,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int snd_pcm_null_open(snd_pcm_t **pcmp, char *name, int stream, int mode)
|
int snd_pcm_null_open(snd_pcm_t **pcmp, char *name, int stream, int mode)
|
||||||
|
|
|
||||||
1072
src/pcm/pcm_params.c
1072
src/pcm/pcm_params.c
File diff suppressed because it is too large
Load diff
|
|
@ -214,13 +214,13 @@ static int snd_pcm_plug_hw_refine1(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
mask_load(mmap_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(mmap_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
mask_load(fmtplug_mask, SND_PCM_FMTBIT_PLUG);
|
mask_load(fmtplug_mask, SND_PCM_FMTBIT_PLUG);
|
||||||
|
|
||||||
err = _snd_pcm_hw_params_min(params, 1, SND_PCM_HW_PARAM_CHANNELS, 1);
|
err = _snd_pcm_hw_param_min(params, 1, SND_PCM_HW_PARAM_CHANNELS, 1);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = _snd_pcm_hw_params_min(params, 1, SND_PCM_HW_PARAM_RATE, RATE_MIN);
|
err = _snd_pcm_hw_param_min(params, 1, SND_PCM_HW_PARAM_RATE, RATE_MIN);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = _snd_pcm_hw_params_max(params, 1, SND_PCM_HW_PARAM_RATE, RATE_MAX);
|
err = _snd_pcm_hw_param_max(params, 1, SND_PCM_HW_PARAM_RATE, RATE_MAX);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
|
@ -230,41 +230,41 @@ static int snd_pcm_plug_hw_refine1(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
rate_min = snd_pcm_hw_params_value_min(params, SND_PCM_HW_PARAM_RATE);
|
rate_min = snd_pcm_hw_param_value_min(params, SND_PCM_HW_PARAM_RATE);
|
||||||
rate_max = snd_pcm_hw_params_value_max(params, SND_PCM_HW_PARAM_RATE);
|
rate_max = snd_pcm_hw_param_value_max(params, SND_PCM_HW_PARAM_RATE);
|
||||||
tmp = *sparams;
|
tmp = *sparams;
|
||||||
srate_min = snd_pcm_hw_params_near(slave, &tmp,
|
srate_min = snd_pcm_hw_param_near(slave, &tmp,
|
||||||
SND_PCM_HW_PARAM_RATE, rate_min);
|
SND_PCM_HW_PARAM_RATE, rate_min);
|
||||||
if (srate_min < rate_max) {
|
if (srate_min < rate_max) {
|
||||||
tmp = *sparams;
|
tmp = *sparams;
|
||||||
srate_max = snd_pcm_hw_params_near(slave, &tmp,
|
srate_max = snd_pcm_hw_param_near(slave, &tmp,
|
||||||
SND_PCM_HW_PARAM_RATE, rate_max);
|
SND_PCM_HW_PARAM_RATE, rate_max);
|
||||||
} else
|
} else
|
||||||
srate_max = srate_min;
|
srate_max = srate_min;
|
||||||
err = snd_pcm_hw_params_minmax(slave, sparams,
|
err = snd_pcm_hw_param_minmax(slave, sparams,
|
||||||
SND_PCM_HW_PARAM_RATE,
|
SND_PCM_HW_PARAM_RATE,
|
||||||
srate_min, srate_max);
|
srate_min, srate_max);
|
||||||
assert(err >= 0);
|
assert(err >= 0);
|
||||||
|
|
||||||
channels_min = snd_pcm_hw_params_value_min(params, SND_PCM_HW_PARAM_CHANNELS);
|
channels_min = snd_pcm_hw_param_value_min(params, SND_PCM_HW_PARAM_CHANNELS);
|
||||||
channels_max = snd_pcm_hw_params_value_max(params, SND_PCM_HW_PARAM_CHANNELS);
|
channels_max = snd_pcm_hw_param_value_max(params, SND_PCM_HW_PARAM_CHANNELS);
|
||||||
tmp = *sparams;
|
tmp = *sparams;
|
||||||
schannels_min = snd_pcm_hw_params_near(slave, &tmp,
|
schannels_min = snd_pcm_hw_param_near(slave, &tmp,
|
||||||
SND_PCM_HW_PARAM_CHANNELS, channels_min);
|
SND_PCM_HW_PARAM_CHANNELS, channels_min);
|
||||||
if (schannels_min < channels_max) {
|
if (schannels_min < channels_max) {
|
||||||
tmp = *sparams;
|
tmp = *sparams;
|
||||||
schannels_max = snd_pcm_hw_params_near(slave, &tmp,
|
schannels_max = snd_pcm_hw_param_near(slave, &tmp,
|
||||||
SND_PCM_HW_PARAM_CHANNELS, channels_max);
|
SND_PCM_HW_PARAM_CHANNELS, channels_max);
|
||||||
} else
|
} else
|
||||||
schannels_max = schannels_min;
|
schannels_max = schannels_min;
|
||||||
err = snd_pcm_hw_params_minmax(slave, sparams,
|
err = snd_pcm_hw_param_minmax(slave, sparams,
|
||||||
SND_PCM_HW_PARAM_CHANNELS,
|
SND_PCM_HW_PARAM_CHANNELS,
|
||||||
schannels_min, schannels_max);
|
schannels_min, schannels_max);
|
||||||
assert(err >= 0);
|
assert(err >= 0);
|
||||||
|
|
||||||
format_mask = snd_pcm_hw_params_value_mask(params,
|
format_mask = snd_pcm_hw_param_value_mask(params,
|
||||||
SND_PCM_HW_PARAM_FORMAT);
|
SND_PCM_HW_PARAM_FORMAT);
|
||||||
sformat_mask = snd_pcm_hw_params_value_mask(sparams,
|
sformat_mask = snd_pcm_hw_param_value_mask(sparams,
|
||||||
SND_PCM_HW_PARAM_FORMAT);
|
SND_PCM_HW_PARAM_FORMAT);
|
||||||
mask_none(tmp_mask);
|
mask_none(tmp_mask);
|
||||||
for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) {
|
for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) {
|
||||||
|
|
@ -279,7 +279,7 @@ static int snd_pcm_plug_hw_refine1(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
mask_t *m = alloca(mask_sizeof());
|
mask_t *m = alloca(mask_sizeof());
|
||||||
mask_all(m);
|
mask_all(m);
|
||||||
mask_reset(m, format);
|
mask_reset(m, format);
|
||||||
err = _snd_pcm_hw_params_mask(params, 1, SND_PCM_HW_PARAM_FORMAT, m);
|
err = _snd_pcm_hw_param_mask(params, 1, SND_PCM_HW_PARAM_FORMAT, m);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -288,10 +288,10 @@ static int snd_pcm_plug_hw_refine1(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
mask_set(tmp_mask, f);
|
mask_set(tmp_mask, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = _snd_pcm_hw_params_mask(sparams, 0,
|
err = _snd_pcm_hw_param_mask(sparams, 0,
|
||||||
SND_PCM_HW_PARAM_FORMAT, tmp_mask);
|
SND_PCM_HW_PARAM_FORMAT, tmp_mask);
|
||||||
assert(err >= 0);
|
assert(err >= 0);
|
||||||
sformat_mask = snd_pcm_hw_params_value_mask(sparams,
|
sformat_mask = snd_pcm_hw_param_value_mask(sparams,
|
||||||
SND_PCM_HW_PARAM_FORMAT);
|
SND_PCM_HW_PARAM_FORMAT);
|
||||||
|
|
||||||
same_rate = (rate_min == rate_max &&
|
same_rate = (rate_min == rate_max &&
|
||||||
|
|
@ -321,30 +321,30 @@ static int snd_pcm_plug_hw_refine1(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (same_rate && same_channels && same_format) {
|
if (same_rate && same_channels && same_format) {
|
||||||
const mask_t *access_mask = snd_pcm_hw_params_value_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
const mask_t *access_mask = snd_pcm_hw_param_value_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
||||||
mask_copy(tmp_mask, snd_pcm_hw_params_value_mask(sparams, SND_PCM_HW_PARAM_ACCESS));
|
mask_copy(tmp_mask, snd_pcm_hw_param_value_mask(sparams, SND_PCM_HW_PARAM_ACCESS));
|
||||||
mask_intersect(tmp_mask, access_mask);
|
mask_intersect(tmp_mask, access_mask);
|
||||||
if (!mask_empty(tmp_mask))
|
if (!mask_empty(tmp_mask))
|
||||||
_snd_pcm_hw_params_mask(sparams, 0,
|
_snd_pcm_hw_param_mask(sparams, 0,
|
||||||
SND_PCM_HW_PARAM_ACCESS,
|
SND_PCM_HW_PARAM_ACCESS,
|
||||||
access_mask);
|
access_mask);
|
||||||
else
|
else
|
||||||
_snd_pcm_hw_params_mask(sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
mmap_mask);
|
mmap_mask);
|
||||||
} else {
|
} else {
|
||||||
err = _snd_pcm_hw_params_mask(params, 1,
|
err = _snd_pcm_hw_param_mask(params, 1,
|
||||||
SND_PCM_HW_PARAM_ACCESS,
|
SND_PCM_HW_PARAM_ACCESS,
|
||||||
accplug_mask);
|
accplug_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = _snd_pcm_hw_params_mask(params, 1,
|
err = _snd_pcm_hw_param_mask(params, 1,
|
||||||
SND_PCM_HW_PARAM_FORMAT,
|
SND_PCM_HW_PARAM_FORMAT,
|
||||||
fmtplug_mask);
|
fmtplug_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
_snd_pcm_hw_params_mask(sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
mmap_mask);
|
mmap_mask);
|
||||||
_snd_pcm_hw_params_mask(sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
_snd_pcm_hw_param_mask(sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
||||||
fmtplug_mask);
|
fmtplug_mask);
|
||||||
}
|
}
|
||||||
err = snd_pcm_hw_refine2(params, sparams,
|
err = snd_pcm_hw_refine2(params, sparams,
|
||||||
|
|
@ -584,15 +584,15 @@ static int snd_pcm_plug_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
int err = snd_pcm_plug_hw_refine1(pcm, params, &sparams);
|
int err = snd_pcm_plug_hw_refine1(pcm, params, &sparams);
|
||||||
assert(err >= 0);
|
assert(err >= 0);
|
||||||
|
|
||||||
clt_params.access = snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_ACCESS);
|
clt_params.access = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_ACCESS);
|
||||||
clt_params.format = snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_FORMAT);
|
clt_params.format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT);
|
||||||
clt_params.channels = snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_CHANNELS);
|
clt_params.channels = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_CHANNELS);
|
||||||
clt_params.rate = snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_RATE);
|
clt_params.rate = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_RATE);
|
||||||
|
|
||||||
slv_params.access = snd_pcm_hw_params_first(slave, &sparams, SND_PCM_HW_PARAM_ACCESS);
|
slv_params.access = snd_pcm_hw_param_first(slave, &sparams, SND_PCM_HW_PARAM_ACCESS);
|
||||||
slv_params.format = snd_pcm_hw_params_value(&sparams, SND_PCM_HW_PARAM_FORMAT);
|
slv_params.format = snd_pcm_hw_param_value(&sparams, SND_PCM_HW_PARAM_FORMAT);
|
||||||
slv_params.channels = snd_pcm_hw_params_value(&sparams, SND_PCM_HW_PARAM_CHANNELS);
|
slv_params.channels = snd_pcm_hw_param_value(&sparams, SND_PCM_HW_PARAM_CHANNELS);
|
||||||
slv_params.rate = snd_pcm_hw_params_value(&sparams, SND_PCM_HW_PARAM_RATE);
|
slv_params.rate = snd_pcm_hw_param_value(&sparams, SND_PCM_HW_PARAM_RATE);
|
||||||
|
|
||||||
snd_pcm_plug_clear(pcm);
|
snd_pcm_plug_clear(pcm);
|
||||||
err = snd_pcm_plug_insert_plugins(pcm, &clt_params, &slv_params);
|
err = snd_pcm_plug_insert_plugins(pcm, &clt_params, &slv_params);
|
||||||
|
|
@ -612,18 +612,21 @@ static int snd_pcm_plug_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
|
||||||
{
|
{
|
||||||
snd_pcm_plug_t *plug = pcm->private;
|
snd_pcm_plug_t *plug = pcm->private;
|
||||||
snd_pcm_t *slave = plug->req_slave;
|
snd_pcm_t *slave = plug->req_slave;
|
||||||
size_t avail_min, xfer_min, xfer_align;
|
size_t avail_min, xfer_align, silence_threshold, silence_size;
|
||||||
int err;
|
int err;
|
||||||
avail_min = params->avail_min;
|
avail_min = params->avail_min;
|
||||||
xfer_min = params->xfer_min;
|
|
||||||
xfer_align = params->xfer_align;
|
xfer_align = params->xfer_align;
|
||||||
|
silence_threshold = params->silence_threshold;
|
||||||
|
silence_size = params->silence_size;
|
||||||
params->avail_min = muldiv_near(params->avail_min, slave->rate, pcm->rate);
|
params->avail_min = muldiv_near(params->avail_min, slave->rate, pcm->rate);
|
||||||
params->xfer_min = muldiv_near(params->xfer_min, slave->rate, pcm->rate);
|
|
||||||
params->xfer_align = muldiv_near(params->xfer_align, slave->rate, pcm->rate);
|
params->xfer_align = muldiv_near(params->xfer_align, slave->rate, pcm->rate);
|
||||||
|
params->silence_threshold = muldiv_near(params->silence_threshold, slave->rate, pcm->rate);
|
||||||
|
params->silence_size = muldiv_near(params->silence_size, slave->rate, pcm->rate);
|
||||||
err = snd_pcm_sw_params(slave, params);
|
err = snd_pcm_sw_params(slave, params);
|
||||||
params->avail_min = avail_min;
|
params->avail_min = avail_min;
|
||||||
params->xfer_min = xfer_min;
|
|
||||||
params->xfer_align = xfer_align;
|
params->xfer_align = xfer_align;
|
||||||
|
params->silence_threshold = silence_threshold;
|
||||||
|
params->silence_size = silence_size;
|
||||||
params->boundary = LONG_MAX - pcm->buffer_size * 2 - LONG_MAX % pcm->buffer_size;
|
params->boundary = LONG_MAX - pcm->buffer_size * 2 - LONG_MAX % pcm->buffer_size;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,11 @@ ssize_t snd_pcm_plugin_rewind(snd_pcm_t *pcm, size_t frames)
|
||||||
frames -= n;
|
frames -= n;
|
||||||
}
|
}
|
||||||
if (frames > 0) {
|
if (frames > 0) {
|
||||||
ssize_t err = snd_pcm_rewind(plugin->slave, frames);
|
ssize_t err;
|
||||||
|
/* FIXME: rate plugin */
|
||||||
|
if (plugin->slave_frames)
|
||||||
|
frames = plugin->slave_frames(pcm, frames);
|
||||||
|
err = snd_pcm_rewind(plugin->slave, frames);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
@ -305,13 +309,6 @@ ssize_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int snd_pcm_plugin_set_avail_min(snd_pcm_t *pcm, size_t frames)
|
|
||||||
{
|
|
||||||
snd_pcm_plugin_t *plugin = pcm->private;
|
|
||||||
snd_pcm_t *slave = plugin->slave;
|
|
||||||
return snd_pcm_set_avail_min(slave, frames);
|
|
||||||
}
|
|
||||||
|
|
||||||
int snd_pcm_plugin_mmap(snd_pcm_t *pcm)
|
int snd_pcm_plugin_mmap(snd_pcm_t *pcm)
|
||||||
{
|
{
|
||||||
snd_pcm_plugin_t *plug = pcm->private;
|
snd_pcm_plugin_t *plug = pcm->private;
|
||||||
|
|
@ -415,6 +412,5 @@ snd_pcm_fast_ops_t snd_pcm_plugin_fast_ops = {
|
||||||
readn: snd_pcm_plugin_readn,
|
readn: snd_pcm_plugin_readn,
|
||||||
avail_update: snd_pcm_plugin_avail_update,
|
avail_update: snd_pcm_plugin_avail_update,
|
||||||
mmap_forward: snd_pcm_plugin_mmap_forward,
|
mmap_forward: snd_pcm_plugin_mmap_forward,
|
||||||
set_avail_min: snd_pcm_plugin_set_avail_min,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ typedef struct {
|
||||||
snd_pcm_xfer_areas_func_t read;
|
snd_pcm_xfer_areas_func_t read;
|
||||||
snd_pcm_xfer_areas_func_t write;
|
snd_pcm_xfer_areas_func_t write;
|
||||||
ssize_t (*client_frames)(snd_pcm_t *pcm, ssize_t frames);
|
ssize_t (*client_frames)(snd_pcm_t *pcm, ssize_t frames);
|
||||||
|
ssize_t (*slave_frames)(snd_pcm_t *pcm, ssize_t frames);
|
||||||
int (*init)(snd_pcm_t *pcm);
|
int (*init)(snd_pcm_t *pcm);
|
||||||
int shmid;
|
int shmid;
|
||||||
size_t appl_ptr, hw_ptr;
|
size_t appl_ptr, hw_ptr;
|
||||||
|
|
@ -35,6 +36,7 @@ int snd_pcm_plugin_card(snd_pcm_t *pcm);
|
||||||
int snd_pcm_plugin_nonblock(snd_pcm_t *pcm, int nonblock);
|
int snd_pcm_plugin_nonblock(snd_pcm_t *pcm, int nonblock);
|
||||||
int snd_pcm_plugin_async(snd_pcm_t *pcm, int sig, pid_t pid);
|
int snd_pcm_plugin_async(snd_pcm_t *pcm, int sig, pid_t pid);
|
||||||
int snd_pcm_plugin_info(snd_pcm_t *pcm, snd_pcm_info_t * info);
|
int snd_pcm_plugin_info(snd_pcm_t *pcm, snd_pcm_info_t * info);
|
||||||
|
int snd_pcm_plugin_sw_refine(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
|
||||||
int snd_pcm_plugin_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
|
int snd_pcm_plugin_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
|
||||||
int snd_pcm_plugin_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info);
|
int snd_pcm_plugin_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info);
|
||||||
int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status);
|
int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status);
|
||||||
|
|
|
||||||
|
|
@ -249,37 +249,37 @@ static int snd_pcm_rate_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||||
mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
err = _snd_pcm_hw_params_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
err = _snd_pcm_hw_param_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
||||||
access_mask);
|
access_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = _snd_pcm_hw_params_mask(params, 1, SND_PCM_HW_PARAM_FORMAT,
|
err = _snd_pcm_hw_param_mask(params, 1, SND_PCM_HW_PARAM_FORMAT,
|
||||||
format_mask);
|
format_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = _snd_pcm_hw_params_min(params, 1,
|
err = _snd_pcm_hw_param_min(params, 1,
|
||||||
SND_PCM_HW_PARAM_RATE, RATE_MIN);
|
SND_PCM_HW_PARAM_RATE, RATE_MIN);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = _snd_pcm_hw_params_max(params, 1,
|
err = _snd_pcm_hw_param_max(params, 1,
|
||||||
SND_PCM_HW_PARAM_RATE, RATE_MAX);
|
SND_PCM_HW_PARAM_RATE, RATE_MAX);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
if (rate->sformat >= 0) {
|
if (rate->sformat >= 0) {
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
||||||
rate->sformat);
|
rate->sformat);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
} else
|
} else
|
||||||
links |= (SND_PCM_HW_PARBIT_FORMAT |
|
links |= (SND_PCM_HW_PARBIT_FORMAT |
|
||||||
SND_PCM_HW_PARBIT_SUBFORMAT |
|
SND_PCM_HW_PARBIT_SUBFORMAT |
|
||||||
SND_PCM_HW_PARBIT_SAMPLE_BITS |
|
SND_PCM_HW_PARBIT_SAMPLE_BITS |
|
||||||
SND_PCM_HW_PARBIT_FRAME_BITS);
|
SND_PCM_HW_PARBIT_FRAME_BITS);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_RATE,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_RATE,
|
||||||
rate->srate);
|
rate->srate);
|
||||||
|
|
||||||
err = snd_pcm_hw_refine2(params, &sparams,
|
err = snd_pcm_hw_refine2(params, &sparams,
|
||||||
|
|
@ -306,19 +306,19 @@ static int snd_pcm_rate_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
if (rate->sformat >= 0) {
|
if (rate->sformat >= 0) {
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
||||||
rate->sformat);
|
rate->sformat);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
} else
|
} else
|
||||||
links |= (SND_PCM_HW_PARBIT_FORMAT |
|
links |= (SND_PCM_HW_PARBIT_FORMAT |
|
||||||
SND_PCM_HW_PARBIT_SUBFORMAT |
|
SND_PCM_HW_PARBIT_SUBFORMAT |
|
||||||
SND_PCM_HW_PARBIT_SAMPLE_BITS |
|
SND_PCM_HW_PARBIT_SAMPLE_BITS |
|
||||||
SND_PCM_HW_PARBIT_FRAME_BITS);
|
SND_PCM_HW_PARBIT_FRAME_BITS);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_RATE,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_RATE,
|
||||||
rate->srate);
|
rate->srate);
|
||||||
|
|
||||||
err = snd_pcm_hw_params2(params, &sparams,
|
err = snd_pcm_hw_params2(params, &sparams,
|
||||||
|
|
@ -327,15 +327,15 @@ static int snd_pcm_rate_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
return err;
|
return err;
|
||||||
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
||||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||||
src_format = snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_FORMAT);
|
src_format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT);
|
||||||
dst_format = slave->format;
|
dst_format = slave->format;
|
||||||
src_rate = snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_RATE);
|
src_rate = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_RATE);
|
||||||
dst_rate = slave->rate;
|
dst_rate = slave->rate;
|
||||||
} else {
|
} else {
|
||||||
src_format = slave->format;
|
src_format = slave->format;
|
||||||
dst_format = snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_FORMAT);
|
dst_format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT);
|
||||||
src_rate = slave->rate;
|
src_rate = slave->rate;
|
||||||
dst_rate = snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_RATE);
|
dst_rate = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_RATE);
|
||||||
}
|
}
|
||||||
rate->get_idx = get_index(src_format, SND_PCM_FORMAT_S16);
|
rate->get_idx = get_index(src_format, SND_PCM_FORMAT_S16);
|
||||||
rate->put_idx = put_index(SND_PCM_FORMAT_S16, dst_format);
|
rate->put_idx = put_index(SND_PCM_FORMAT_S16, dst_format);
|
||||||
|
|
@ -349,7 +349,7 @@ static int snd_pcm_rate_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
rate->pitch = (((u_int64_t)dst_rate * DIV) + src_rate / 2) / src_rate;
|
rate->pitch = (((u_int64_t)dst_rate * DIV) + src_rate / 2) / src_rate;
|
||||||
if (rate->states)
|
if (rate->states)
|
||||||
free(rate->states);
|
free(rate->states);
|
||||||
rate->states = malloc(snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_CHANNELS) * sizeof(*rate->states));
|
rate->states = malloc(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_CHANNELS) * sizeof(*rate->states));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -357,18 +357,21 @@ static int snd_pcm_rate_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
|
||||||
{
|
{
|
||||||
snd_pcm_rate_t *rate = pcm->private;
|
snd_pcm_rate_t *rate = pcm->private;
|
||||||
snd_pcm_t *slave = rate->plug.slave;
|
snd_pcm_t *slave = rate->plug.slave;
|
||||||
size_t avail_min, xfer_min, xfer_align;
|
size_t avail_min, xfer_align, silence_threshold, silence_size;
|
||||||
int err;
|
int err;
|
||||||
avail_min = params->avail_min;
|
avail_min = params->avail_min;
|
||||||
xfer_min = params->xfer_min;
|
|
||||||
xfer_align = params->xfer_align;
|
xfer_align = params->xfer_align;
|
||||||
|
silence_threshold = params->silence_threshold;
|
||||||
|
silence_size = params->silence_size;
|
||||||
params->avail_min = muldiv_near(params->avail_min, slave->rate, pcm->rate);
|
params->avail_min = muldiv_near(params->avail_min, slave->rate, pcm->rate);
|
||||||
params->xfer_min = muldiv_near(params->xfer_min, slave->rate, pcm->rate);
|
|
||||||
params->xfer_align = muldiv_near(params->xfer_align, slave->rate, pcm->rate);
|
params->xfer_align = muldiv_near(params->xfer_align, slave->rate, pcm->rate);
|
||||||
|
params->silence_threshold = muldiv_near(params->silence_threshold, slave->rate, pcm->rate);
|
||||||
|
params->silence_size = muldiv_near(params->silence_size, slave->rate, pcm->rate);
|
||||||
err = snd_pcm_sw_params(slave, params);
|
err = snd_pcm_sw_params(slave, params);
|
||||||
params->avail_min = avail_min;
|
params->avail_min = avail_min;
|
||||||
params->xfer_min = xfer_min;
|
|
||||||
params->xfer_align = xfer_align;
|
params->xfer_align = xfer_align;
|
||||||
|
params->silence_threshold = silence_threshold;
|
||||||
|
params->silence_size = silence_size;
|
||||||
params->boundary = LONG_MAX - pcm->buffer_size * 2 - LONG_MAX % pcm->buffer_size;
|
params->boundary = LONG_MAX - pcm->buffer_size * 2 - LONG_MAX % pcm->buffer_size;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
@ -502,6 +505,16 @@ ssize_t snd_pcm_rate_client_frames(snd_pcm_t *pcm, ssize_t frames)
|
||||||
return muldiv_down(frames, rate->pitch, DIV);
|
return muldiv_down(frames, rate->pitch, DIV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssize_t snd_pcm_rate_slave_frames(snd_pcm_t *pcm, ssize_t frames)
|
||||||
|
{
|
||||||
|
snd_pcm_rate_t *rate = pcm->private;
|
||||||
|
/* Round toward zero */
|
||||||
|
if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
|
||||||
|
return muldiv_down(frames, rate->pitch, DIV);
|
||||||
|
else
|
||||||
|
return muldiv_down(frames, DIV, rate->pitch);
|
||||||
|
}
|
||||||
|
|
||||||
static void snd_pcm_rate_dump(snd_pcm_t *pcm, FILE *fp)
|
static void snd_pcm_rate_dump(snd_pcm_t *pcm, FILE *fp)
|
||||||
{
|
{
|
||||||
snd_pcm_rate_t *rate = pcm->private;
|
snd_pcm_rate_t *rate = pcm->private;
|
||||||
|
|
@ -551,6 +564,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, int sformat, int srate, snd_
|
||||||
rate->plug.read = snd_pcm_rate_read_areas;
|
rate->plug.read = snd_pcm_rate_read_areas;
|
||||||
rate->plug.write = snd_pcm_rate_write_areas;
|
rate->plug.write = snd_pcm_rate_write_areas;
|
||||||
rate->plug.client_frames = snd_pcm_rate_client_frames;
|
rate->plug.client_frames = snd_pcm_rate_client_frames;
|
||||||
|
rate->plug.slave_frames = snd_pcm_rate_slave_frames;
|
||||||
rate->plug.init = snd_pcm_rate_init;
|
rate->plug.init = snd_pcm_rate_init;
|
||||||
rate->plug.slave = slave;
|
rate->plug.slave = slave;
|
||||||
rate->plug.close_slave = close_slave;
|
rate->plug.close_slave = close_slave;
|
||||||
|
|
|
||||||
|
|
@ -443,32 +443,32 @@ static int snd_pcm_route_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||||
mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
err = _snd_pcm_hw_params_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
err = _snd_pcm_hw_param_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
||||||
access_mask);
|
access_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = _snd_pcm_hw_params_mask(params, 1, SND_PCM_HW_PARAM_FORMAT,
|
err = _snd_pcm_hw_param_mask(params, 1, SND_PCM_HW_PARAM_FORMAT,
|
||||||
format_mask);
|
format_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = _snd_pcm_hw_params_min(params, 1, SND_PCM_HW_PARAM_CHANNELS, 1);
|
err = _snd_pcm_hw_param_min(params, 1, SND_PCM_HW_PARAM_CHANNELS, 1);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
if (route->sformat >= 0) {
|
if (route->sformat >= 0) {
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
||||||
route->sformat);
|
route->sformat);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
} else
|
} else
|
||||||
links |= (SND_PCM_HW_PARBIT_FORMAT |
|
links |= (SND_PCM_HW_PARBIT_FORMAT |
|
||||||
SND_PCM_HW_PARBIT_SUBFORMAT |
|
SND_PCM_HW_PARBIT_SUBFORMAT |
|
||||||
SND_PCM_HW_PARBIT_SAMPLE_BITS);
|
SND_PCM_HW_PARBIT_SAMPLE_BITS);
|
||||||
if (route->schannels >= 0) {
|
if (route->schannels >= 0) {
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_CHANNELS,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_CHANNELS,
|
||||||
route->schannels);
|
route->schannels);
|
||||||
} else {
|
} else {
|
||||||
links |= SND_PCM_HW_PARBIT_CHANNELS;
|
links |= SND_PCM_HW_PARBIT_CHANNELS;
|
||||||
|
|
@ -502,20 +502,20 @@ static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
if (route->sformat >= 0) {
|
if (route->sformat >= 0) {
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_FORMAT,
|
||||||
route->sformat);
|
route->sformat);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
SND_PCM_SUBFORMAT_STD);
|
SND_PCM_SUBFORMAT_STD);
|
||||||
} else
|
} else
|
||||||
links |= (SND_PCM_HW_PARBIT_FORMAT |
|
links |= (SND_PCM_HW_PARBIT_FORMAT |
|
||||||
SND_PCM_HW_PARBIT_SUBFORMAT |
|
SND_PCM_HW_PARBIT_SUBFORMAT |
|
||||||
SND_PCM_HW_PARBIT_SAMPLE_BITS);
|
SND_PCM_HW_PARBIT_SAMPLE_BITS);
|
||||||
if (route->schannels >= 0) {
|
if (route->schannels >= 0) {
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_CHANNELS,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_CHANNELS,
|
||||||
route->schannels);
|
route->schannels);
|
||||||
} else {
|
} else {
|
||||||
links |= SND_PCM_HW_PARBIT_CHANNELS;
|
links |= SND_PCM_HW_PARBIT_CHANNELS;
|
||||||
if (route->sformat < 0)
|
if (route->sformat < 0)
|
||||||
|
|
@ -530,11 +530,11 @@ static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
return err;
|
return err;
|
||||||
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
||||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||||
src_format = snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_FORMAT);
|
src_format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT);
|
||||||
dst_format = slave->format;
|
dst_format = slave->format;
|
||||||
} else {
|
} else {
|
||||||
src_format = slave->format;
|
src_format = slave->format;
|
||||||
dst_format = snd_pcm_hw_params_value(params, SND_PCM_HW_PARAM_FORMAT);
|
dst_format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT);
|
||||||
}
|
}
|
||||||
route->params.get_idx = get_index(src_format, SND_PCM_FORMAT_U16);
|
route->params.get_idx = get_index(src_format, SND_PCM_FORMAT_U16);
|
||||||
route->params.put_idx = put_index(SND_PCM_FORMAT_U32, dst_format);
|
route->params.put_idx = put_index(SND_PCM_FORMAT_U32, dst_format);
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ typedef struct {
|
||||||
size_t running_count;
|
size_t running_count;
|
||||||
size_t safety_threshold;
|
size_t safety_threshold;
|
||||||
size_t silence_frames;
|
size_t silence_frames;
|
||||||
|
snd_pcm_sw_params_t sw_params;
|
||||||
size_t hw_ptr;
|
size_t hw_ptr;
|
||||||
int poll[2];
|
int poll[2];
|
||||||
int polling;
|
int polling;
|
||||||
|
|
@ -367,8 +368,11 @@ void *snd_pcm_share_slave_thread(void *data)
|
||||||
if (avail_min < 0)
|
if (avail_min < 0)
|
||||||
avail_min += spcm->boundary;
|
avail_min += spcm->boundary;
|
||||||
// printf("avail_min=%d\n", avail_min);
|
// printf("avail_min=%d\n", avail_min);
|
||||||
if ((size_t)avail_min != spcm->avail_min)
|
if ((size_t)avail_min != spcm->avail_min) {
|
||||||
snd_pcm_set_avail_min(spcm, avail_min);
|
snd_pcm_sw_param_near(spcm, &slave->sw_params, SND_PCM_SW_PARAM_AVAIL_MIN, avail_min);
|
||||||
|
err = snd_pcm_sw_params(spcm, &slave->sw_params);
|
||||||
|
assert(err >= 0);
|
||||||
|
}
|
||||||
slave->polling = 1;
|
slave->polling = 1;
|
||||||
Pthread_mutex_unlock(&slave->mutex);
|
Pthread_mutex_unlock(&slave->mutex);
|
||||||
err = poll(pfd, 2, -1);
|
err = poll(pfd, 2, -1);
|
||||||
|
|
@ -402,6 +406,7 @@ static void _snd_pcm_share_update(snd_pcm_t *pcm)
|
||||||
if (missing < INT_MAX) {
|
if (missing < INT_MAX) {
|
||||||
size_t hw_ptr;
|
size_t hw_ptr;
|
||||||
ssize_t avail_min;
|
ssize_t avail_min;
|
||||||
|
int err;
|
||||||
hw_ptr = slave->hw_ptr + missing;
|
hw_ptr = slave->hw_ptr + missing;
|
||||||
hw_ptr += spcm->fragment_size - 1;
|
hw_ptr += spcm->fragment_size - 1;
|
||||||
if (hw_ptr >= spcm->boundary)
|
if (hw_ptr >= spcm->boundary)
|
||||||
|
|
@ -412,8 +417,11 @@ static void _snd_pcm_share_update(snd_pcm_t *pcm)
|
||||||
avail_min += spcm->buffer_size;
|
avail_min += spcm->buffer_size;
|
||||||
if (avail_min < 0)
|
if (avail_min < 0)
|
||||||
avail_min += spcm->boundary;
|
avail_min += spcm->boundary;
|
||||||
if ((size_t)avail_min < spcm->avail_min)
|
if ((size_t)avail_min < spcm->avail_min) {
|
||||||
snd_pcm_set_avail_min(spcm, avail_min);
|
snd_pcm_sw_param_near(spcm, &slave->sw_params, SND_PCM_SW_PARAM_AVAIL_MIN, avail_min);
|
||||||
|
err = snd_pcm_sw_params(spcm, &slave->sw_params);
|
||||||
|
assert(err >= 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -458,29 +466,29 @@ static int snd_pcm_share_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
mask_t *saccess_mask = alloca(mask_sizeof());
|
mask_t *saccess_mask = alloca(mask_sizeof());
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
|
|
||||||
err = _snd_pcm_hw_params_set(params, 1, SND_PCM_HW_PARAM_CHANNELS,
|
err = _snd_pcm_hw_param_set(params, 1, SND_PCM_HW_PARAM_CHANNELS,
|
||||||
share->channels_count);
|
share->channels_count);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (slave->format >= 0) {
|
if (slave->format >= 0) {
|
||||||
err = _snd_pcm_hw_params_set(params, 1, SND_PCM_HW_PARAM_FORMAT,
|
err = _snd_pcm_hw_param_set(params, 1, SND_PCM_HW_PARAM_FORMAT,
|
||||||
slave->format);
|
slave->format);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slave->rate >= 0) {
|
if (slave->rate >= 0) {
|
||||||
err = _snd_pcm_hw_params_set(params, 1, SND_PCM_HW_PARAM_RATE,
|
err = _snd_pcm_hw_param_set(params, 1, SND_PCM_HW_PARAM_RATE,
|
||||||
slave->rate);
|
slave->rate);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_CHANNELS,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_CHANNELS,
|
||||||
slave->channels_count);
|
slave->channels_count);
|
||||||
err = snd_pcm_hw_refine2(params, &sparams,
|
err = snd_pcm_hw_refine2(params, &sparams,
|
||||||
snd_pcm_hw_refine, slave->pcm,
|
snd_pcm_hw_refine, slave->pcm,
|
||||||
|
|
@ -494,7 +502,7 @@ static int snd_pcm_share_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
SND_PCM_HW_PARBIT_FRAGMENTS);
|
SND_PCM_HW_PARBIT_FRAGMENTS);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
mmap_mask = snd_pcm_hw_params_value_mask(&sparams, SND_PCM_HW_PARAM_ACCESS);
|
mmap_mask = snd_pcm_hw_param_value_mask(&sparams, SND_PCM_HW_PARAM_ACCESS);
|
||||||
mask_all(access_mask);
|
mask_all(access_mask);
|
||||||
mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
|
mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
|
||||||
if (!mask_test(mmap_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED))
|
if (!mask_test(mmap_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED))
|
||||||
|
|
@ -502,7 +510,7 @@ static int snd_pcm_share_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
if (!mask_test(mmap_mask, SND_PCM_ACCESS_MMAP_COMPLEX) &&
|
if (!mask_test(mmap_mask, SND_PCM_ACCESS_MMAP_COMPLEX) &&
|
||||||
!mask_test(mmap_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED))
|
!mask_test(mmap_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED))
|
||||||
mask_reset(access_mask, SND_PCM_ACCESS_MMAP_COMPLEX);
|
mask_reset(access_mask, SND_PCM_ACCESS_MMAP_COMPLEX);
|
||||||
err = _snd_pcm_hw_params_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
err = _snd_pcm_hw_param_mask(params, 1, SND_PCM_HW_PARAM_ACCESS,
|
||||||
access_mask);
|
access_mask);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
@ -519,23 +527,23 @@ static int snd_pcm_share_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
Pthread_mutex_lock(&slave->mutex);
|
Pthread_mutex_lock(&slave->mutex);
|
||||||
if (slave->setup_count > 1 ||
|
if (slave->setup_count > 1 ||
|
||||||
(slave->setup_count == 1 && !pcm->setup)) {
|
(slave->setup_count == 1 && !pcm->setup)) {
|
||||||
err = _snd_pcm_hw_params_set(params, 1, SND_PCM_HW_PARAM_FORMAT,
|
err = _snd_pcm_hw_param_set(params, 1, SND_PCM_HW_PARAM_FORMAT,
|
||||||
spcm->format);
|
spcm->format);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto _err;
|
goto _err;
|
||||||
err = _snd_pcm_hw_params_set(params, 1, SND_PCM_HW_PARAM_SUBFORMAT,
|
err = _snd_pcm_hw_param_set(params, 1, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||||
spcm->subformat);
|
spcm->subformat);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto _err;
|
goto _err;
|
||||||
err = _snd_pcm_hw_params_set(params, 1, SND_PCM_HW_PARAM_RATE,
|
err = _snd_pcm_hw_param_set(params, 1, SND_PCM_HW_PARAM_RATE,
|
||||||
spcm->rate);
|
spcm->rate);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto _err;
|
goto _err;
|
||||||
err = _snd_pcm_hw_params_set(params, 1, SND_PCM_HW_PARAM_FRAGMENT_SIZE,
|
err = _snd_pcm_hw_param_set(params, 1, SND_PCM_HW_PARAM_FRAGMENT_SIZE,
|
||||||
spcm->fragment_size);
|
spcm->fragment_size);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto _err;
|
goto _err;
|
||||||
err = _snd_pcm_hw_params_set(params, 1, SND_PCM_HW_PARAM_FRAGMENTS,
|
err = _snd_pcm_hw_param_set(params, 1, SND_PCM_HW_PARAM_FRAGMENTS,
|
||||||
spcm->fragments);
|
spcm->fragments);
|
||||||
_err:
|
_err:
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
|
|
@ -548,9 +556,9 @@ static int snd_pcm_share_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
mask_t *saccess_mask = alloca(mask_sizeof());
|
mask_t *saccess_mask = alloca(mask_sizeof());
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
_snd_pcm_hw_params_set(&sparams, 0, SND_PCM_HW_PARAM_CHANNELS,
|
_snd_pcm_hw_param_set(&sparams, 0, SND_PCM_HW_PARAM_CHANNELS,
|
||||||
share->channels_count);
|
share->channels_count);
|
||||||
err = snd_pcm_hw_params2(params, &sparams,
|
err = snd_pcm_hw_params2(params, &sparams,
|
||||||
snd_pcm_hw_params, slave->pcm,
|
snd_pcm_hw_params, slave->pcm,
|
||||||
|
|
@ -564,6 +572,7 @@ static int snd_pcm_share_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
SND_PCM_HW_PARBIT_FRAGMENTS);
|
SND_PCM_HW_PARBIT_FRAGMENTS);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto _end;
|
goto _end;
|
||||||
|
snd_pcm_sw_params_current(slave->pcm, &slave->sw_params);
|
||||||
/* >= 30 ms */
|
/* >= 30 ms */
|
||||||
slave->safety_threshold = slave->pcm->rate * 30 / 1000;
|
slave->safety_threshold = slave->pcm->rate * 30 / 1000;
|
||||||
slave->safety_threshold += slave->pcm->fragment_size - 1;
|
slave->safety_threshold += slave->pcm->fragment_size - 1;
|
||||||
|
|
@ -579,20 +588,8 @@ static int snd_pcm_share_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_share_sw_params(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params)
|
static int snd_pcm_share_sw_params(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
if (params->start_mode > SND_PCM_START_LAST) {
|
|
||||||
params->fail_mask = 1 << SND_PCM_SW_PARAM_START_MODE;
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
if (params->ready_mode > SND_PCM_READY_LAST) {
|
|
||||||
params->fail_mask = 1 << SND_PCM_SW_PARAM_READY_MODE;
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
if (params->xrun_mode > SND_PCM_XRUN_LAST) {
|
|
||||||
params->fail_mask = 1 << SND_PCM_SW_PARAM_XRUN_MODE;
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -895,18 +892,6 @@ static ssize_t snd_pcm_share_rewind(snd_pcm_t *pcm, size_t frames)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_share_set_avail_min(snd_pcm_t *pcm, size_t frames)
|
|
||||||
{
|
|
||||||
snd_pcm_share_t *share = pcm->private;
|
|
||||||
snd_pcm_share_slave_t *slave = share->slave;
|
|
||||||
Pthread_mutex_lock(&slave->mutex);
|
|
||||||
pcm->avail_min = frames;
|
|
||||||
share->avail_min = frames;
|
|
||||||
_snd_pcm_share_update(pcm);
|
|
||||||
Pthread_mutex_unlock(&slave->mutex);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Warning: take the mutex before to call this */
|
/* Warning: take the mutex before to call this */
|
||||||
static void _snd_pcm_share_stop(snd_pcm_t *pcm, int state)
|
static void _snd_pcm_share_stop(snd_pcm_t *pcm, int state)
|
||||||
{
|
{
|
||||||
|
|
@ -1117,7 +1102,6 @@ snd_pcm_fast_ops_t snd_pcm_share_fast_ops = {
|
||||||
rewind: snd_pcm_share_rewind,
|
rewind: snd_pcm_share_rewind,
|
||||||
avail_update: snd_pcm_share_avail_update,
|
avail_update: snd_pcm_share_avail_update,
|
||||||
mmap_forward: snd_pcm_share_mmap_forward,
|
mmap_forward: snd_pcm_share_mmap_forward,
|
||||||
set_avail_min: snd_pcm_share_set_avail_min,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int snd_pcm_share_open(snd_pcm_t **pcmp, char *name, char *sname,
|
int snd_pcm_share_open(snd_pcm_t **pcmp, char *name, char *sname,
|
||||||
|
|
|
||||||
|
|
@ -171,14 +171,14 @@ static int _snd_pcm_shm_hw_refine(snd_pcm_t *pcm,
|
||||||
static int snd_pcm_shm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
static int snd_pcm_shm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||||
{
|
{
|
||||||
snd_pcm_hw_params_t sparams;
|
snd_pcm_hw_params_t sparams;
|
||||||
const mask_t *access_mask = snd_pcm_hw_params_value_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
const mask_t *access_mask = snd_pcm_hw_param_value_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
||||||
mask_t *saccess_mask = alloca(mask_sizeof());
|
mask_t *saccess_mask = alloca(mask_sizeof());
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
if (!mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) &&
|
if (!mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) &&
|
||||||
!mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED))
|
!mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED))
|
||||||
mask_intersect(saccess_mask, access_mask);
|
mask_intersect(saccess_mask, access_mask);
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
return snd_pcm_hw_refine2(params, &sparams,
|
return snd_pcm_hw_refine2(params, &sparams,
|
||||||
_snd_pcm_shm_hw_refine, pcm,
|
_snd_pcm_shm_hw_refine, pcm,
|
||||||
|
|
@ -201,14 +201,14 @@ static int _snd_pcm_shm_hw_params(snd_pcm_t *pcm,
|
||||||
static int snd_pcm_shm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
static int snd_pcm_shm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
{
|
{
|
||||||
snd_pcm_hw_params_t sparams;
|
snd_pcm_hw_params_t sparams;
|
||||||
const mask_t *access_mask = snd_pcm_hw_params_value_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
const mask_t *access_mask = snd_pcm_hw_param_value_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
||||||
mask_t *saccess_mask = alloca(mask_sizeof());
|
mask_t *saccess_mask = alloca(mask_sizeof());
|
||||||
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||||
if (!mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) &&
|
if (!mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) &&
|
||||||
!mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED))
|
!mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED))
|
||||||
mask_intersect(saccess_mask, access_mask);
|
mask_intersect(saccess_mask, access_mask);
|
||||||
_snd_pcm_hw_params_any(&sparams);
|
_snd_pcm_hw_params_any(&sparams);
|
||||||
_snd_pcm_hw_params_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
_snd_pcm_hw_param_mask(&sparams, 0, SND_PCM_HW_PARAM_ACCESS,
|
||||||
saccess_mask);
|
saccess_mask);
|
||||||
return snd_pcm_hw_params2(params, &sparams,
|
return snd_pcm_hw_params2(params, &sparams,
|
||||||
_snd_pcm_shm_hw_params, pcm,
|
_snd_pcm_shm_hw_params, pcm,
|
||||||
|
|
@ -408,15 +408,6 @@ static ssize_t snd_pcm_shm_mmap_forward(snd_pcm_t *pcm, size_t size)
|
||||||
return snd_pcm_shm_action(pcm);
|
return snd_pcm_shm_action(pcm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_shm_set_avail_min(snd_pcm_t *pcm, size_t frames)
|
|
||||||
{
|
|
||||||
snd_pcm_shm_t *shm = pcm->private;
|
|
||||||
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
|
|
||||||
ctrl->cmd = SND_PCM_IOCTL_SET_AVAIL_MIN;
|
|
||||||
ctrl->u.set_avail_min.frames = frames;
|
|
||||||
return snd_pcm_shm_action(pcm);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int snd_pcm_shm_poll_descriptor(snd_pcm_t *pcm)
|
static int snd_pcm_shm_poll_descriptor(snd_pcm_t *pcm)
|
||||||
{
|
{
|
||||||
snd_pcm_shm_t *shm = pcm->private;
|
snd_pcm_shm_t *shm = pcm->private;
|
||||||
|
|
@ -484,7 +475,6 @@ snd_pcm_fast_ops_t snd_pcm_shm_fast_ops = {
|
||||||
readn: snd_pcm_mmap_readn,
|
readn: snd_pcm_mmap_readn,
|
||||||
avail_update: snd_pcm_shm_avail_update,
|
avail_update: snd_pcm_shm_avail_update,
|
||||||
mmap_forward: snd_pcm_shm_mmap_forward,
|
mmap_forward: snd_pcm_shm_mmap_forward,
|
||||||
set_avail_min: snd_pcm_shm_set_avail_min,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int make_local_socket(const char *filename)
|
static int make_local_socket(const char *filename)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue