mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-10 13:30:01 -05:00
Corrected and completed encapsulation for PCM and rawmidi. Remove SND_PCM_HW_PARAM_* and use functions. Separated rawmidi info between streams
This commit is contained in:
parent
544718f10d
commit
a7561a9c7e
40 changed files with 2733 additions and 1537 deletions
|
|
@ -2,7 +2,7 @@
|
|||
EXTRA_LTLIBRARIES = libpcm.la
|
||||
|
||||
libpcm_la_SOURCES = mask.c interval.c \
|
||||
pcm.c pcm_hw.c pcm_plugin.c pcm_copy.c pcm_linear.c \
|
||||
pcm.c pcm_m4.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_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 \
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
typedef struct _snd_mask snd_mask_t;
|
||||
|
||||
#define SND_MASK_MAX 31
|
||||
|
||||
#ifdef SND_MASK_INLINE
|
||||
|
|
|
|||
256
src/pcm/pcm.c
256
src/pcm/pcm.c
|
|
@ -39,7 +39,7 @@ snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm)
|
|||
return pcm->type;
|
||||
}
|
||||
|
||||
snd_pcm_type_t snd_pcm_stream(snd_pcm_t *pcm)
|
||||
snd_pcm_stream_t snd_pcm_stream(snd_pcm_t *pcm)
|
||||
{
|
||||
assert(pcm);
|
||||
return pcm->stream;
|
||||
|
|
@ -99,7 +99,7 @@ int snd_pcm_status(snd_pcm_t *pcm, snd_pcm_status_t *status)
|
|||
return pcm->fast_ops->status(pcm->fast_op_arg, status);
|
||||
}
|
||||
|
||||
int snd_pcm_state(snd_pcm_t *pcm)
|
||||
snd_pcm_state_t snd_pcm_state(snd_pcm_t *pcm)
|
||||
{
|
||||
assert(pcm);
|
||||
return pcm->fast_ops->state(pcm->fast_op_arg);
|
||||
|
|
@ -287,18 +287,6 @@ char *snd_pcm_hw_param_names[] = {
|
|||
HW_PARAM(TICK_TIME),
|
||||
};
|
||||
|
||||
char *snd_pcm_sw_param_names[] = {
|
||||
SW_PARAM(START_MODE),
|
||||
SW_PARAM(XRUN_MODE),
|
||||
SW_PARAM(TSTAMP_MODE),
|
||||
SW_PARAM(PERIOD_STEP),
|
||||
SW_PARAM(SLEEP_MIN),
|
||||
SW_PARAM(AVAIL_MIN),
|
||||
SW_PARAM(XFER_ALIGN),
|
||||
SW_PARAM(SILENCE_THRESHOLD),
|
||||
SW_PARAM(SILENCE_SIZE),
|
||||
};
|
||||
|
||||
char *snd_pcm_access_names[] = {
|
||||
ACCESS(MMAP_INTERLEAVED),
|
||||
ACCESS(MMAP_NONINTERLEAVED),
|
||||
|
|
@ -391,77 +379,73 @@ char *snd_pcm_tstamp_mode_names[] = {
|
|||
const char *snd_pcm_stream_name(snd_pcm_stream_t stream)
|
||||
{
|
||||
assert(stream <= SND_PCM_STREAM_LAST);
|
||||
return snd_pcm_stream_names[stream];
|
||||
return snd_pcm_stream_names[snd_enum_to_int(stream)];
|
||||
}
|
||||
|
||||
const char *snd_pcm_access_name(snd_pcm_access_t access)
|
||||
{
|
||||
assert(access <= SND_PCM_ACCESS_LAST);
|
||||
return snd_pcm_access_names[access];
|
||||
return snd_pcm_access_names[snd_enum_to_int(access)];
|
||||
}
|
||||
|
||||
const char *snd_pcm_format_name(snd_pcm_format_t format)
|
||||
{
|
||||
assert(format <= SND_PCM_FORMAT_LAST);
|
||||
return snd_pcm_format_names[format];
|
||||
return snd_pcm_format_names[snd_enum_to_int(format)];
|
||||
}
|
||||
|
||||
const char *snd_pcm_format_description(snd_pcm_format_t format)
|
||||
{
|
||||
assert(format <= SND_PCM_FORMAT_LAST);
|
||||
return snd_pcm_format_descriptions[format];
|
||||
return snd_pcm_format_descriptions[snd_enum_to_int(format)];
|
||||
}
|
||||
|
||||
int snd_pcm_format_value(const char* name)
|
||||
snd_pcm_format_t snd_pcm_format_value(const char* name)
|
||||
{
|
||||
unsigned int format;
|
||||
for (format = 0; format <= SND_PCM_FORMAT_LAST; format++)
|
||||
if (snd_pcm_format_names[format] &&
|
||||
strcasecmp(name, snd_pcm_format_names[format]) == 0)
|
||||
snd_pcm_format_t format;
|
||||
for (format = 0; format <= SND_PCM_FORMAT_LAST; snd_enum_incr(format)) {
|
||||
if (snd_pcm_format_names[snd_enum_to_int(format)] &&
|
||||
strcasecmp(name, snd_pcm_format_names[snd_enum_to_int(format)]) == 0) {
|
||||
return format;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return SND_PCM_FORMAT_NONE;
|
||||
}
|
||||
|
||||
const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat)
|
||||
{
|
||||
assert(subformat <= SND_PCM_SUBFORMAT_LAST);
|
||||
return snd_pcm_subformat_names[subformat];
|
||||
return snd_pcm_subformat_names[snd_enum_to_int(subformat)];
|
||||
}
|
||||
|
||||
const char *snd_pcm_hw_param_name(snd_pcm_hw_param_t param)
|
||||
{
|
||||
assert(param <= SND_PCM_HW_PARAM_LAST);
|
||||
return snd_pcm_hw_param_names[param];
|
||||
}
|
||||
|
||||
const char *snd_pcm_sw_param_name(snd_pcm_sw_param_t param)
|
||||
{
|
||||
assert(param <= SND_PCM_SW_PARAM_LAST);
|
||||
return snd_pcm_sw_param_names[param];
|
||||
return snd_pcm_hw_param_names[snd_enum_to_int(param)];
|
||||
}
|
||||
|
||||
const char *snd_pcm_start_mode_name(snd_pcm_start_t mode)
|
||||
{
|
||||
assert(mode <= SND_PCM_START_LAST);
|
||||
return snd_pcm_start_mode_names[mode];
|
||||
return snd_pcm_start_mode_names[snd_enum_to_int(mode)];
|
||||
}
|
||||
|
||||
const char *snd_pcm_xrun_mode_name(snd_pcm_xrun_t mode)
|
||||
{
|
||||
assert(mode <= SND_PCM_XRUN_LAST);
|
||||
return snd_pcm_xrun_mode_names[mode];
|
||||
return snd_pcm_xrun_mode_names[snd_enum_to_int(mode)];
|
||||
}
|
||||
|
||||
const char *snd_pcm_tstamp_mode_name(snd_pcm_tstamp_t mode)
|
||||
{
|
||||
assert(mode <= SND_PCM_TSTAMP_LAST);
|
||||
return snd_pcm_tstamp_mode_names[mode];
|
||||
return snd_pcm_tstamp_mode_names[snd_enum_to_int(mode)];
|
||||
}
|
||||
|
||||
const char *snd_pcm_state_name(snd_pcm_state_t state)
|
||||
{
|
||||
assert(state <= SND_PCM_STATE_LAST);
|
||||
return snd_pcm_state_names[state];
|
||||
return snd_pcm_state_names[snd_enum_to_int(state)];
|
||||
}
|
||||
|
||||
int snd_pcm_dump_hw_setup(snd_pcm_t *pcm, snd_output_t *out)
|
||||
|
|
@ -509,186 +493,10 @@ int snd_pcm_dump_setup(snd_pcm_t *pcm, snd_output_t *out)
|
|||
return 0;
|
||||
}
|
||||
|
||||
size_t snd_pcm_info_sizeof()
|
||||
{
|
||||
return sizeof(snd_pcm_info_t);
|
||||
}
|
||||
|
||||
int snd_pcm_info_malloc(snd_pcm_info_t **infop)
|
||||
{
|
||||
assert(infop);
|
||||
*infop = malloc(sizeof(snd_pcm_info_t));
|
||||
if (!*infop)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void snd_pcm_info_free(snd_pcm_info_t *info)
|
||||
{
|
||||
assert(info);
|
||||
free(info);
|
||||
}
|
||||
|
||||
void snd_pcm_info_copy(snd_pcm_info_t *dst,
|
||||
const snd_pcm_info_t *src)
|
||||
{
|
||||
assert(dst && src);
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
void snd_pcm_info_set_device(snd_pcm_info_t *info, unsigned int device)
|
||||
{
|
||||
assert(info);
|
||||
info->device = device;
|
||||
}
|
||||
|
||||
void snd_pcm_info_set_subdevice(snd_pcm_info_t *info, unsigned int subdevice)
|
||||
{
|
||||
assert(info);
|
||||
info->subdevice = subdevice;
|
||||
}
|
||||
|
||||
void snd_pcm_info_set_stream(snd_pcm_info_t *info, snd_pcm_stream_t stream)
|
||||
{
|
||||
assert(info);
|
||||
info->stream = stream;
|
||||
}
|
||||
|
||||
int snd_pcm_info_card(snd_pcm_info_t *info)
|
||||
{
|
||||
assert(info);
|
||||
return info->card;
|
||||
}
|
||||
|
||||
unsigned int snd_pcm_info_device(snd_pcm_info_t *info)
|
||||
{
|
||||
assert(info);
|
||||
return info->device;
|
||||
}
|
||||
|
||||
unsigned int snd_pcm_info_subdevice(snd_pcm_info_t *info)
|
||||
{
|
||||
assert(info);
|
||||
return info->subdevice;
|
||||
}
|
||||
|
||||
snd_pcm_stream_t snd_pcm_info_stream(snd_pcm_info_t *info)
|
||||
{
|
||||
assert(info);
|
||||
return info->stream;
|
||||
}
|
||||
|
||||
const char *snd_pcm_info_device_id(snd_pcm_info_t *info)
|
||||
{
|
||||
assert(info);
|
||||
return info->id;
|
||||
}
|
||||
|
||||
const char *snd_pcm_info_device_name(snd_pcm_info_t *info)
|
||||
{
|
||||
assert(info);
|
||||
return info->name;
|
||||
}
|
||||
|
||||
const char *snd_pcm_info_subdevice_name(snd_pcm_info_t *info)
|
||||
{
|
||||
assert(info);
|
||||
return info->subname;
|
||||
}
|
||||
|
||||
snd_pcm_class_t snd_pcm_info_device_class(snd_pcm_info_t *info)
|
||||
{
|
||||
assert(info);
|
||||
return info->dev_class;
|
||||
}
|
||||
|
||||
snd_pcm_subclass_t snd_pcm_info_device_subclass(snd_pcm_info_t *info)
|
||||
{
|
||||
assert(info);
|
||||
return info->dev_subclass;
|
||||
}
|
||||
|
||||
unsigned int snd_pcm_info_subdevices_count(snd_pcm_info_t *info)
|
||||
{
|
||||
assert(info);
|
||||
return info->subdevices_count;
|
||||
}
|
||||
|
||||
unsigned int snd_pcm_info_subdevices_avail(snd_pcm_info_t *info)
|
||||
{
|
||||
assert(info);
|
||||
return info->subdevices_avail;
|
||||
}
|
||||
|
||||
size_t snd_pcm_status_sizeof()
|
||||
{
|
||||
return sizeof(snd_pcm_status_t);
|
||||
}
|
||||
|
||||
int snd_pcm_status_malloc(snd_pcm_status_t **statusp)
|
||||
{
|
||||
assert(statusp);
|
||||
*statusp = malloc(sizeof(snd_pcm_status_t));
|
||||
if (!*statusp)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void snd_pcm_status_free(snd_pcm_status_t *status)
|
||||
{
|
||||
assert(status);
|
||||
free(status);
|
||||
}
|
||||
|
||||
void snd_pcm_status_copy(snd_pcm_status_t *dst,
|
||||
const snd_pcm_status_t *src)
|
||||
{
|
||||
assert(dst && src);
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
snd_pcm_state_t snd_pcm_status_state(snd_pcm_status_t *status)
|
||||
{
|
||||
assert(status);
|
||||
return status->state;
|
||||
}
|
||||
|
||||
int snd_pcm_status_delay(snd_pcm_status_t *status)
|
||||
{
|
||||
assert(status);
|
||||
return status->delay;
|
||||
}
|
||||
|
||||
int snd_pcm_status_avail(snd_pcm_status_t *status)
|
||||
{
|
||||
assert(status);
|
||||
return status->avail;
|
||||
}
|
||||
|
||||
int snd_pcm_status_avail_max(snd_pcm_status_t *status)
|
||||
{
|
||||
assert(status);
|
||||
return status->avail_max;
|
||||
}
|
||||
|
||||
void snd_pcm_status_tstamp(snd_pcm_status_t *status,
|
||||
snd_timestamp_t *tstamp)
|
||||
{
|
||||
assert(status && tstamp);
|
||||
*tstamp = status->tstamp;
|
||||
}
|
||||
|
||||
void snd_pcm_status_trigger_tstamp(snd_pcm_status_t *status,
|
||||
snd_timestamp_t *tstamp)
|
||||
{
|
||||
assert(status && tstamp);
|
||||
*tstamp = status->trigger_tstamp;
|
||||
}
|
||||
|
||||
int snd_pcm_status_dump(snd_pcm_status_t *status, snd_output_t *out)
|
||||
{
|
||||
assert(status);
|
||||
snd_output_printf(out, "state : %s\n", snd_pcm_state_name(status->state));
|
||||
snd_output_printf(out, "state : %s\n", snd_pcm_state_name((snd_pcm_state_t) status->state));
|
||||
snd_output_printf(out, "trigger_time: %ld.%06ld\n",
|
||||
status->trigger_tstamp.tv_sec, status->trigger_tstamp.tv_usec);
|
||||
snd_output_printf(out, "tstamp : %ld.%06ld\n",
|
||||
|
|
@ -736,7 +544,7 @@ ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, int samples)
|
|||
}
|
||||
|
||||
int snd_pcm_open(snd_pcm_t **pcmp, char *name,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
char *str;
|
||||
int err;
|
||||
|
|
@ -744,7 +552,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, char *name,
|
|||
snd_config_iterator_t i;
|
||||
char *lib = NULL, *open = NULL;
|
||||
int (*open_func)(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
|
||||
int stream, int mode);
|
||||
snd_pcm_stream_t stream, int mode);
|
||||
void *h;
|
||||
assert(pcmp && name);
|
||||
err = snd_config_update();
|
||||
|
|
@ -903,7 +711,7 @@ int snd_pcm_wait(snd_pcm_t *pcm, int timeout)
|
|||
pfd.events = pcm->stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN;
|
||||
err = poll(&pfd, 1, timeout);
|
||||
if (err < 0)
|
||||
return err;
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -920,7 +728,7 @@ snd_pcm_sframes_t snd_pcm_mmap_forward(snd_pcm_t *pcm, snd_pcm_uframes_t size)
|
|||
}
|
||||
|
||||
int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t dst_offset,
|
||||
unsigned int samples, int format)
|
||||
unsigned int samples, snd_pcm_format_t format)
|
||||
{
|
||||
/* FIXME: sub byte resolution and odd dst_offset */
|
||||
char *dst;
|
||||
|
|
@ -1002,7 +810,7 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes
|
|||
}
|
||||
|
||||
int snd_pcm_areas_silence(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset,
|
||||
unsigned int channels, snd_pcm_uframes_t frames, int format)
|
||||
unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format)
|
||||
{
|
||||
int width = snd_pcm_format_physical_width(format);
|
||||
while (channels > 0) {
|
||||
|
|
@ -1044,7 +852,7 @@ int snd_pcm_areas_silence(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufram
|
|||
|
||||
int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t dst_offset,
|
||||
const snd_pcm_channel_area_t *src_area, snd_pcm_uframes_t src_offset,
|
||||
unsigned int samples, int format)
|
||||
unsigned int samples, snd_pcm_format_t format)
|
||||
{
|
||||
/* FIXME: sub byte resolution and odd dst_offset */
|
||||
char *src, *dst;
|
||||
|
|
@ -1139,7 +947,7 @@ int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t
|
|||
|
||||
int snd_pcm_areas_copy(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset,
|
||||
const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset,
|
||||
unsigned int channels, snd_pcm_uframes_t frames, int format)
|
||||
unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format)
|
||||
{
|
||||
int width = snd_pcm_format_physical_width(format);
|
||||
while (channels > 0) {
|
||||
|
|
@ -1194,14 +1002,14 @@ snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_
|
|||
{
|
||||
snd_pcm_uframes_t xfer = 0;
|
||||
int err = 0;
|
||||
int state = snd_pcm_state(pcm);
|
||||
snd_pcm_state_t state = snd_pcm_state(pcm);
|
||||
|
||||
if (size == 0)
|
||||
return 0;
|
||||
if (size > pcm->xfer_align)
|
||||
size -= size % pcm->xfer_align;
|
||||
|
||||
switch (state) {
|
||||
switch (snd_enum_to_int(state)) {
|
||||
case SND_PCM_STATE_PREPARED:
|
||||
if (pcm->start_mode == SND_PCM_START_DATA) {
|
||||
err = snd_pcm_start(pcm);
|
||||
|
|
@ -1278,14 +1086,14 @@ snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area
|
|||
{
|
||||
snd_pcm_uframes_t xfer = 0;
|
||||
int err = 0;
|
||||
int state = snd_pcm_state(pcm);
|
||||
snd_pcm_state_t state = snd_pcm_state(pcm);
|
||||
|
||||
if (size == 0)
|
||||
return 0;
|
||||
if (size > pcm->xfer_align)
|
||||
size -= size % pcm->xfer_align;
|
||||
|
||||
switch (state) {
|
||||
switch (snd_enum_to_int(state)) {
|
||||
case SND_PCM_STATE_PREPARED:
|
||||
case SND_PCM_STATE_RUNNING:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ typedef struct {
|
|||
snd_pcm_plugin_t plug;
|
||||
int getput_idx;
|
||||
adpcm_f func;
|
||||
int sformat;
|
||||
snd_pcm_format_t sformat;
|
||||
snd_pcm_adpcm_state_t *states;
|
||||
} snd_pcm_adpcm_t;
|
||||
|
||||
|
|
@ -316,26 +316,25 @@ static int snd_pcm_adpcm_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
|
|||
{
|
||||
snd_pcm_adpcm_t *adpcm = pcm->private;
|
||||
int err;
|
||||
snd_mask_t *access_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) {
|
||||
snd_mask_t *format_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof());
|
||||
snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
format_mask);
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
format_mask);
|
||||
} else {
|
||||
err = _snd_pcm_hw_param_set(params,
|
||||
SND_PCM_HW_PARAM_FORMAT,
|
||||
SND_PCM_FORMAT_IMA_ADPCM, 0);
|
||||
err = _snd_pcm_hw_params_set_format(params,
|
||||
SND_PCM_FORMAT_IMA_ADPCM);
|
||||
}
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||
SND_PCM_SUBFORMAT_STD, 0);
|
||||
err = _snd_pcm_hw_params_set_subformat(params,
|
||||
SND_PCM_SUBFORMAT_STD);
|
||||
if (err < 0)
|
||||
return err;
|
||||
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
||||
|
|
@ -345,15 +344,13 @@ static int snd_pcm_adpcm_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
|
|||
static int snd_pcm_adpcm_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
|
||||
{
|
||||
snd_pcm_adpcm_t *adpcm = pcm->private;
|
||||
snd_mask_t *saccess_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||
_snd_pcm_hw_params_any(sparams);
|
||||
_snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
saccess_mask);
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_FORMAT,
|
||||
adpcm->sformat, 0);
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||
SND_PCM_SUBFORMAT_STD, 0);
|
||||
_snd_pcm_hw_params_set_format(sparams, adpcm->sformat);
|
||||
_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -417,7 +414,7 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
|||
|
||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||
if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) {
|
||||
adpcm->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0), SND_PCM_FORMAT_S16);
|
||||
adpcm->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_params_get_format(params), SND_PCM_FORMAT_S16);
|
||||
adpcm->func = snd_pcm_adpcm_encode;
|
||||
} else {
|
||||
adpcm->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, adpcm->sformat);
|
||||
|
|
@ -425,7 +422,7 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
|||
}
|
||||
} else {
|
||||
if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) {
|
||||
adpcm->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0));
|
||||
adpcm->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_params_get_format(params));
|
||||
adpcm->func = snd_pcm_adpcm_decode;
|
||||
} else {
|
||||
adpcm->getput_idx = snd_pcm_linear_get_index(adpcm->sformat, SND_PCM_FORMAT_S16);
|
||||
|
|
@ -433,7 +430,7 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
|||
}
|
||||
}
|
||||
assert(!adpcm->states);
|
||||
adpcm->states = malloc(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_CHANNELS, 0) * sizeof(*adpcm->states));
|
||||
adpcm->states = malloc(snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_CHANNELS, 0) * sizeof(*adpcm->states));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -556,7 +553,7 @@ snd_pcm_ops_t snd_pcm_adpcm_ops = {
|
|||
munmap: snd_pcm_plugin_munmap,
|
||||
};
|
||||
|
||||
int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave)
|
||||
int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave)
|
||||
{
|
||||
snd_pcm_t *pcm;
|
||||
snd_pcm_adpcm_t *adpcm;
|
||||
|
|
@ -600,13 +597,13 @@ int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *sla
|
|||
|
||||
int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name,
|
||||
snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i;
|
||||
char *sname = NULL;
|
||||
int err;
|
||||
snd_pcm_t *spcm;
|
||||
int sformat = -1;
|
||||
snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE;
|
||||
snd_config_foreach(i, conf) {
|
||||
snd_config_t *n = snd_config_entry(i);
|
||||
if (strcmp(n->id, "comment") == 0)
|
||||
|
|
@ -631,7 +628,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name,
|
|||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat < 0) {
|
||||
if (sformat == SND_PCM_FORMAT_NONE) {
|
||||
ERR("Unknown sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -649,7 +646,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name,
|
|||
ERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (sformat < 0) {
|
||||
if (sformat == SND_PCM_FORMAT_NONE) {
|
||||
ERR("sformat is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ typedef struct {
|
|||
snd_pcm_plugin_t plug;
|
||||
int getput_idx;
|
||||
alaw_f func;
|
||||
int sformat;
|
||||
snd_pcm_format_t sformat;
|
||||
} snd_pcm_alaw_t;
|
||||
|
||||
static inline int val_seg(int val)
|
||||
|
|
@ -215,26 +215,24 @@ static int snd_pcm_alaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *
|
|||
{
|
||||
snd_pcm_alaw_t *alaw = pcm->private;
|
||||
int err;
|
||||
snd_mask_t *access_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (alaw->sformat == SND_PCM_FORMAT_A_LAW) {
|
||||
snd_mask_t *format_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof());
|
||||
snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
format_mask);
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
format_mask);
|
||||
} else {
|
||||
err = _snd_pcm_hw_param_set(params,
|
||||
SND_PCM_HW_PARAM_FORMAT,
|
||||
SND_PCM_FORMAT_A_LAW, 0);
|
||||
err = _snd_pcm_hw_params_set_format(params,
|
||||
SND_PCM_FORMAT_A_LAW);
|
||||
}
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||
SND_PCM_SUBFORMAT_STD, 0);
|
||||
err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD);
|
||||
if (err < 0)
|
||||
return err;
|
||||
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
||||
|
|
@ -244,15 +242,13 @@ static int snd_pcm_alaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *
|
|||
static int snd_pcm_alaw_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
|
||||
{
|
||||
snd_pcm_alaw_t *alaw = pcm->private;
|
||||
snd_mask_t *saccess_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||
_snd_pcm_hw_params_any(sparams);
|
||||
_snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
saccess_mask);
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_FORMAT,
|
||||
alaw->sformat, 0);
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||
SND_PCM_SUBFORMAT_STD, 0);
|
||||
_snd_pcm_hw_params_set_format(sparams, alaw->sformat);
|
||||
_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -315,7 +311,7 @@ static int snd_pcm_alaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
|||
|
||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||
if (alaw->sformat == SND_PCM_FORMAT_A_LAW) {
|
||||
alaw->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0), SND_PCM_FORMAT_S16);
|
||||
alaw->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_params_get_format(params), SND_PCM_FORMAT_S16);
|
||||
alaw->func = snd_pcm_alaw_encode;
|
||||
} else {
|
||||
alaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, alaw->sformat);
|
||||
|
|
@ -323,7 +319,7 @@ static int snd_pcm_alaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
|||
}
|
||||
} else {
|
||||
if (alaw->sformat == SND_PCM_FORMAT_A_LAW) {
|
||||
alaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0));
|
||||
alaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_params_get_format(params));
|
||||
alaw->func = snd_pcm_alaw_decode;
|
||||
} else {
|
||||
alaw->getput_idx = snd_pcm_linear_get_index(alaw->sformat, SND_PCM_FORMAT_S16);
|
||||
|
|
@ -431,7 +427,7 @@ snd_pcm_ops_t snd_pcm_alaw_ops = {
|
|||
munmap: snd_pcm_plugin_munmap,
|
||||
};
|
||||
|
||||
int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave)
|
||||
int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave)
|
||||
{
|
||||
snd_pcm_t *pcm;
|
||||
snd_pcm_alaw_t *alaw;
|
||||
|
|
@ -474,13 +470,13 @@ int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slav
|
|||
|
||||
int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name,
|
||||
snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i;
|
||||
char *sname = NULL;
|
||||
int err;
|
||||
snd_pcm_t *spcm;
|
||||
int sformat = -1;
|
||||
snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE;
|
||||
snd_config_foreach(i, conf) {
|
||||
snd_config_t *n = snd_config_entry(i);
|
||||
if (strcmp(n->id, "comment") == 0)
|
||||
|
|
@ -505,7 +501,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name,
|
|||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat < 0) {
|
||||
if (sformat == SND_PCM_FORMAT_NONE) {
|
||||
ERR("Unknown sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -523,7 +519,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name,
|
|||
ERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (sformat < 0) {
|
||||
if (sformat == SND_PCM_FORMAT_NONE) {
|
||||
ERR("sformat is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ typedef struct {
|
|||
static int snd_pcm_copy_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params)
|
||||
{
|
||||
int err;
|
||||
snd_mask_t *access_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
||||
|
|
@ -43,10 +43,10 @@ static int snd_pcm_copy_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_
|
|||
|
||||
static int snd_pcm_copy_hw_refine_sprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *sparams)
|
||||
{
|
||||
snd_mask_t *saccess_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||
_snd_pcm_hw_params_any(sparams);
|
||||
_snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
saccess_mask);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ int snd_pcm_copy_open(snd_pcm_t **pcmp, char *name, snd_pcm_t *slave, int close_
|
|||
|
||||
int _snd_pcm_copy_open(snd_pcm_t **pcmp, char *name,
|
||||
snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i;
|
||||
char *sname = NULL;
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ static int snd_pcm_file_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
|||
return snd_pcm_status(file->slave, status);
|
||||
}
|
||||
|
||||
static int snd_pcm_file_state(snd_pcm_t *pcm)
|
||||
static snd_pcm_state_t snd_pcm_file_state(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_file_t *file = pcm->private;
|
||||
return snd_pcm_state(file->slave);
|
||||
|
|
@ -461,7 +461,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, char *name, char *fname, int fd, char *f
|
|||
|
||||
int _snd_pcm_file_open(snd_pcm_t **pcmp, char *name,
|
||||
snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i;
|
||||
char *sname = NULL;
|
||||
|
|
|
|||
|
|
@ -157,9 +157,9 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
|
|||
{
|
||||
snd_pcm_hw_t *hw = pcm->private;
|
||||
int fd = hw->fd;
|
||||
if (params->start_mode == pcm->start_mode &&
|
||||
params->xrun_mode == pcm->xrun_mode &&
|
||||
params->tstamp_mode == pcm->tstamp_mode &&
|
||||
if ((snd_pcm_start_t) params->start_mode == pcm->start_mode &&
|
||||
(snd_pcm_xrun_t) params->xrun_mode == pcm->xrun_mode &&
|
||||
(snd_pcm_tstamp_t) params->tstamp_mode == pcm->tstamp_mode &&
|
||||
params->period_step == pcm->period_step &&
|
||||
params->sleep_min == pcm->sleep_min &&
|
||||
params->xfer_align == pcm->xfer_align &&
|
||||
|
|
@ -209,10 +209,10 @@ static int snd_pcm_hw_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int snd_pcm_hw_state(snd_pcm_t *pcm)
|
||||
static snd_pcm_state_t snd_pcm_hw_state(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_hw_t *hw = pcm->private;
|
||||
return hw->mmap_status->state;
|
||||
return (snd_pcm_state_t) hw->mmap_status->state;
|
||||
}
|
||||
|
||||
static int snd_pcm_hw_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
|
||||
|
|
@ -541,7 +541,7 @@ snd_pcm_fast_ops_t snd_pcm_hw_fast_ops = {
|
|||
mmap_forward: snd_pcm_hw_mmap_forward,
|
||||
};
|
||||
|
||||
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, snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
char filename[32];
|
||||
char *filefmt;
|
||||
|
|
@ -559,7 +559,7 @@ int snd_pcm_hw_open_subdevice(snd_pcm_t **pcmp, int card, int device, int subdev
|
|||
if ((ret = snd_ctl_hw_open(&ctl, NULL, card)) < 0)
|
||||
return ret;
|
||||
|
||||
switch (stream) {
|
||||
switch (snd_enum_to_int(stream)) {
|
||||
case SND_PCM_STREAM_PLAYBACK:
|
||||
filefmt = SNDRV_FILE_PCM_STREAM_PLAYBACK;
|
||||
break;
|
||||
|
|
@ -659,12 +659,12 @@ int snd_pcm_hw_open_subdevice(snd_pcm_t **pcmp, int card, int device, int subdev
|
|||
return ret;
|
||||
}
|
||||
|
||||
int snd_pcm_hw_open_device(snd_pcm_t **pcmp, int card, int device, int stream, int mode)
|
||||
int snd_pcm_hw_open_device(snd_pcm_t **pcmp, int card, int device, snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
return snd_pcm_hw_open_subdevice(pcmp, card, device, -1, stream, mode);
|
||||
}
|
||||
|
||||
int snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, int card, int device, int subdevice, int stream, int mode)
|
||||
int snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
int err = snd_pcm_hw_open_subdevice(pcmp, card, device, subdevice, stream, mode);
|
||||
if (err < 0)
|
||||
|
|
@ -675,7 +675,7 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, int card, int device, int subd
|
|||
}
|
||||
|
||||
int _snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i;
|
||||
long card = -1, device = 0, subdevice = -1;
|
||||
|
|
|
|||
|
|
@ -27,10 +27,11 @@ typedef struct {
|
|||
/* This field need to be the first */
|
||||
snd_pcm_plugin_t plug;
|
||||
int conv_idx;
|
||||
int sformat;
|
||||
snd_pcm_format_t sformat;
|
||||
} snd_pcm_linear_t;
|
||||
|
||||
int snd_pcm_linear_convert_index(int src_format, int dst_format)
|
||||
int snd_pcm_linear_convert_index(snd_pcm_format_t src_format,
|
||||
snd_pcm_format_t dst_format)
|
||||
{
|
||||
int src_endian, dst_endian, sign, src_width, dst_width;
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ int snd_pcm_linear_convert_index(int src_format, int dst_format)
|
|||
return src_width * 32 + src_endian * 16 + sign * 8 + dst_width * 2 + dst_endian;
|
||||
}
|
||||
|
||||
int snd_pcm_linear_get_index(int src_format, int dst_format)
|
||||
int snd_pcm_linear_get_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format)
|
||||
{
|
||||
int sign, width, endian;
|
||||
sign = (snd_pcm_format_signed(src_format) !=
|
||||
|
|
@ -71,7 +72,7 @@ int snd_pcm_linear_get_index(int src_format, int dst_format)
|
|||
return width * 4 + endian * 2 + sign;
|
||||
}
|
||||
|
||||
int snd_pcm_linear_put_index(int src_format, int dst_format)
|
||||
int snd_pcm_linear_put_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format)
|
||||
{
|
||||
int sign, width, endian;
|
||||
sign = (snd_pcm_format_signed(src_format) !=
|
||||
|
|
@ -132,20 +133,19 @@ void snd_pcm_linear_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufr
|
|||
static int snd_pcm_linear_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params)
|
||||
{
|
||||
int err;
|
||||
snd_mask_t *access_mask = alloca(snd_mask_sizeof());
|
||||
snd_mask_t *format_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof());
|
||||
snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||
snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
format_mask);
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
format_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||
SND_PCM_SUBFORMAT_STD, 0);
|
||||
err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD);
|
||||
if (err < 0)
|
||||
return err;
|
||||
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
||||
|
|
@ -155,15 +155,13 @@ static int snd_pcm_linear_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, sn
|
|||
static int snd_pcm_linear_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
|
||||
{
|
||||
snd_pcm_linear_t *linear = pcm->private;
|
||||
snd_mask_t *saccess_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||
_snd_pcm_hw_params_any(sparams);
|
||||
_snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
saccess_mask);
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_FORMAT,
|
||||
linear->sformat, 0);
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||
SND_PCM_SUBFORMAT_STD, 0);
|
||||
_snd_pcm_hw_params_set_format(sparams, linear->sformat);
|
||||
_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -224,11 +222,11 @@ static int snd_pcm_linear_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
|||
if (err < 0)
|
||||
return err;
|
||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
|
||||
linear->conv_idx = snd_pcm_linear_convert_index(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0),
|
||||
linear->conv_idx = snd_pcm_linear_convert_index(snd_pcm_hw_params_get_format(params),
|
||||
linear->sformat);
|
||||
else
|
||||
linear->conv_idx = snd_pcm_linear_convert_index(linear->sformat,
|
||||
snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0));
|
||||
snd_pcm_hw_params_get_format(params));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -328,7 +326,7 @@ snd_pcm_ops_t snd_pcm_linear_ops = {
|
|||
munmap: snd_pcm_plugin_munmap,
|
||||
};
|
||||
|
||||
int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave)
|
||||
int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave)
|
||||
{
|
||||
snd_pcm_t *pcm;
|
||||
snd_pcm_linear_t *linear;
|
||||
|
|
@ -370,13 +368,13 @@ int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *sl
|
|||
|
||||
int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name,
|
||||
snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i;
|
||||
char *sname = NULL;
|
||||
int err;
|
||||
snd_pcm_t *spcm;
|
||||
int sformat = -1;
|
||||
snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE;
|
||||
snd_config_foreach(i, conf) {
|
||||
snd_config_t *n = snd_config_entry(i);
|
||||
if (strcmp(n->id, "comment") == 0)
|
||||
|
|
@ -401,9 +399,9 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name,
|
|||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat < 0) {
|
||||
ERR("Unknown sformat");
|
||||
return -EINVAL;
|
||||
if (sformat == SND_PCM_FORMAT_NONE) {
|
||||
ERR("Unknown sformat %s", f);
|
||||
return err;
|
||||
}
|
||||
if (snd_pcm_format_linear(sformat) != 1) {
|
||||
ERR("sformat is not linear");
|
||||
|
|
@ -418,7 +416,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name,
|
|||
ERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (sformat < 0) {
|
||||
if (sformat == SND_PCM_FORMAT_NONE) {
|
||||
ERR("sformat is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,12 +20,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define _snd_interval sndrv_interval
|
||||
#define _snd_pcm_info sndrv_pcm_info
|
||||
#define _snd_pcm_hw_params sndrv_pcm_hw_params
|
||||
#define _snd_pcm_sw_params sndrv_pcm_sw_params
|
||||
#define _snd_pcm_status sndrv_pcm_status
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -33,6 +27,10 @@
|
|||
#include <sys/uio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define _snd_pcm_access_mask _snd_mask
|
||||
#define _snd_pcm_format_mask _snd_mask
|
||||
#define _snd_pcm_subformat_mask _snd_mask
|
||||
|
||||
#include "local.h"
|
||||
|
||||
#define SND_INTERVAL_INLINE
|
||||
|
|
@ -41,6 +39,32 @@
|
|||
#define SND_MASK_INLINE
|
||||
#include "mask.h"
|
||||
|
||||
typedef enum sndrv_pcm_hw_param snd_pcm_hw_param_t;
|
||||
#define SND_PCM_HW_PARAM_ACCESS SNDRV_PCM_HW_PARAM_ACCESS
|
||||
#define SND_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_FIRST_MASK
|
||||
#define SND_PCM_HW_PARAM_FORMAT SNDRV_PCM_HW_PARAM_FORMAT
|
||||
#define SND_PCM_HW_PARAM_SUBFORMAT SNDRV_PCM_HW_PARAM_SUBFORMAT
|
||||
#define SND_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_LAST_MASK
|
||||
#define SND_PCM_HW_PARAM_SAMPLE_BITS SNDRV_PCM_HW_PARAM_SAMPLE_BITS
|
||||
#define SND_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_FIRST_INTERVAL
|
||||
#define SND_PCM_HW_PARAM_FRAME_BITS SNDRV_PCM_HW_PARAM_FRAME_BITS
|
||||
#define SND_PCM_HW_PARAM_CHANNELS SNDRV_PCM_HW_PARAM_CHANNELS
|
||||
#define SND_PCM_HW_PARAM_RATE SNDRV_PCM_HW_PARAM_RATE
|
||||
#define SND_PCM_HW_PARAM_PERIOD_TIME SNDRV_PCM_HW_PARAM_PERIOD_TIME
|
||||
#define SND_PCM_HW_PARAM_PERIOD_SIZE SNDRV_PCM_HW_PARAM_PERIOD_SIZE
|
||||
#define SND_PCM_HW_PARAM_PERIOD_BYTES SNDRV_PCM_HW_PARAM_PERIOD_BYTES
|
||||
#define SND_PCM_HW_PARAM_PERIODS SNDRV_PCM_HW_PARAM_PERIODS
|
||||
#define SND_PCM_HW_PARAM_BUFFER_TIME SNDRV_PCM_HW_PARAM_BUFFER_TIME
|
||||
#define SND_PCM_HW_PARAM_BUFFER_SIZE SNDRV_PCM_HW_PARAM_BUFFER_SIZE
|
||||
#define SND_PCM_HW_PARAM_BUFFER_BYTES SNDRV_PCM_HW_PARAM_BUFFER_BYTES
|
||||
#define SND_PCM_HW_PARAM_TICK_TIME SNDRV_PCM_HW_PARAM_TICK_TIME
|
||||
#define SND_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_LAST_INTERVAL
|
||||
#define SND_PCM_HW_PARAM_LAST SNDRV_PCM_HW_PARAM_LAST
|
||||
#define SND_PCM_HW_PARAMS_RUNTIME SNDRV_PCM_HW_PARAMS_RUNTIME
|
||||
#define SND_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_LAST_MASK
|
||||
#define SND_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_FIRST_MASK
|
||||
#define SND_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_LAST_INTERVAL
|
||||
#define SND_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_FIRST_INTERVAL
|
||||
|
||||
typedef struct _snd_pcm_channel_info {
|
||||
unsigned int channel;
|
||||
|
|
@ -83,7 +107,7 @@ typedef struct {
|
|||
int (*drop)(snd_pcm_t *pcm);
|
||||
int (*drain)(snd_pcm_t *pcm);
|
||||
int (*pause)(snd_pcm_t *pcm, int enable);
|
||||
int (*state)(snd_pcm_t *pcm);
|
||||
snd_pcm_state_t (*state)(snd_pcm_t *pcm);
|
||||
int (*delay)(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp);
|
||||
snd_pcm_sframes_t (*rewind)(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
|
||||
snd_pcm_sframes_t (*writei)(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
|
||||
|
|
@ -143,11 +167,11 @@ struct _snd_pcm {
|
|||
void *private;
|
||||
};
|
||||
|
||||
int snd_pcm_hw_open(snd_pcm_t **pcm, char *name, int card, int device, int subdevice, int stream, int mode);
|
||||
int snd_pcm_plug_open_hw(snd_pcm_t **pcm, char *name, int card, int device, int subdevice, int stream, int mode);
|
||||
int snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, char *socket, char *sname, int stream, int mode);
|
||||
int snd_pcm_hw_open(snd_pcm_t **pcm, char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode);
|
||||
int snd_pcm_plug_open_hw(snd_pcm_t **pcm, char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode);
|
||||
int snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, char *socket, char *sname, snd_pcm_stream_t stream, int mode);
|
||||
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_null_open(snd_pcm_t **pcmp, char *name, int stream, int mode);
|
||||
int snd_pcm_null_open(snd_pcm_t **pcmp, char *name, snd_pcm_stream_t stream, int mode);
|
||||
|
||||
|
||||
void snd_pcm_areas_from_buf(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas, void *buf);
|
||||
|
|
@ -340,27 +364,41 @@ int snd_pcm_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
|||
|
||||
|
||||
void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params);
|
||||
void _snd_pcm_hw_param_setempty(snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var);
|
||||
int _snd_pcm_hw_param_refine_interval(snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var,
|
||||
const snd_interval_t *val);
|
||||
int _snd_pcm_hw_param_mask(snd_pcm_hw_params_t *params,
|
||||
unsigned int var, const snd_mask_t *mask);
|
||||
void _snd_pcm_hw_param_set_empty(snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var);
|
||||
int _snd_pcm_hw_param_set_interval(snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var,
|
||||
const snd_interval_t *val);
|
||||
int _snd_pcm_hw_param_set_mask(snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var, const snd_mask_t *mask);
|
||||
int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params,
|
||||
unsigned int var);
|
||||
snd_pcm_hw_param_t var);
|
||||
int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params,
|
||||
unsigned int var);
|
||||
snd_pcm_hw_param_t var);
|
||||
int _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params,
|
||||
unsigned int var, unsigned int val, int dir);
|
||||
int _snd_pcm_hw_param_min(snd_pcm_hw_params_t *params,
|
||||
unsigned int var, unsigned int val, int dir);
|
||||
int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params,
|
||||
unsigned int var, unsigned int val, int dir);
|
||||
int _snd_pcm_hw_param_minmax(snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var,
|
||||
unsigned int min, int mindir,
|
||||
unsigned int max, int maxdir);
|
||||
snd_pcm_hw_param_t var, unsigned int val, int dir);
|
||||
static inline int _snd_pcm_hw_params_set_format(snd_pcm_hw_params_t *params,
|
||||
snd_pcm_format_t val)
|
||||
{
|
||||
return _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
(unsigned long) val, 0);
|
||||
}
|
||||
|
||||
static inline int _snd_pcm_hw_params_set_subformat(snd_pcm_hw_params_t *params,
|
||||
snd_pcm_subformat_t val)
|
||||
{
|
||||
return _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
(unsigned long) val, 0);
|
||||
}
|
||||
|
||||
int _snd_pcm_hw_param_set_min(snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var, unsigned int val, int dir);
|
||||
int _snd_pcm_hw_param_set_max(snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var, unsigned int val, int dir);
|
||||
int _snd_pcm_hw_param_set_minmax(snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var,
|
||||
unsigned int min, int mindir,
|
||||
unsigned int max, int maxdir);
|
||||
int _snd_pcm_hw_param_refine(snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var,
|
||||
const snd_pcm_hw_params_t *src);
|
||||
|
|
@ -377,11 +415,57 @@ int snd_pcm_hw_param_always_eq(const snd_pcm_hw_params_t *params,
|
|||
int snd_pcm_hw_param_never_eq(const snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var,
|
||||
const snd_pcm_hw_params_t *params1);
|
||||
const snd_mask_t *snd_pcm_hw_param_value_mask(const snd_pcm_hw_params_t *params,
|
||||
const snd_mask_t *snd_pcm_hw_param_get_mask(const snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var);
|
||||
const snd_interval_t *snd_pcm_hw_param_value_interval(const snd_pcm_hw_params_t *params,
|
||||
const snd_interval_t *snd_pcm_hw_param_get_interval(const snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var);
|
||||
|
||||
int snd_pcm_hw_param_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var);
|
||||
int snd_pcm_hw_param_set_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||
snd_set_mode_t mode,
|
||||
snd_pcm_hw_param_t var);
|
||||
unsigned int snd_pcm_hw_param_set_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var, int *dir);
|
||||
unsigned int snd_pcm_hw_param_set_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var, int *dir);
|
||||
unsigned int snd_pcm_hw_param_set_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var, unsigned int val,
|
||||
int *dir);
|
||||
int snd_pcm_hw_param_set_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||
snd_set_mode_t mode,
|
||||
snd_pcm_hw_param_t var,
|
||||
unsigned int *val, int *dir);
|
||||
int snd_pcm_hw_param_set_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||
snd_set_mode_t mode,
|
||||
snd_pcm_hw_param_t var, unsigned int *val, int *dir);
|
||||
int snd_pcm_hw_param_set_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||
snd_set_mode_t mode,
|
||||
snd_pcm_hw_param_t var,
|
||||
unsigned int *min, int *mindir,
|
||||
unsigned int *max, int *maxdir);
|
||||
int snd_pcm_hw_param_set(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||
snd_set_mode_t mode,
|
||||
snd_pcm_hw_param_t var, unsigned int val, int dir);
|
||||
int snd_pcm_hw_param_set_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
||||
snd_set_mode_t mode,
|
||||
snd_pcm_hw_param_t var, const snd_mask_t *mask);
|
||||
unsigned int snd_pcm_hw_param_get(const snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var, int *dir);
|
||||
unsigned int snd_pcm_hw_param_get_min(const snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var, int *dir);
|
||||
unsigned int snd_pcm_hw_param_get_max(const snd_pcm_hw_params_t *params,
|
||||
snd_pcm_hw_param_t var, int *dir);
|
||||
const char *snd_pcm_hw_param_name(snd_pcm_hw_param_t var);
|
||||
int snd_pcm_hw_strategy_simple_near(snd_pcm_hw_strategy_t *strategy, int order,
|
||||
snd_pcm_hw_param_t var,
|
||||
unsigned int best,
|
||||
unsigned int mul);
|
||||
int snd_pcm_hw_strategy_simple_choices(snd_pcm_hw_strategy_t *strategy, int order,
|
||||
snd_pcm_hw_param_t var,
|
||||
unsigned int count,
|
||||
snd_pcm_hw_strategy_simple_choices_list_t *choices);
|
||||
|
||||
#define SND_PCM_HW_PARBIT_ACCESS (1 << SND_PCM_HW_PARAM_ACCESS)
|
||||
#define SND_PCM_HW_PARBIT_FORMAT (1 << SND_PCM_HW_PARAM_FORMAT)
|
||||
#define SND_PCM_HW_PARBIT_SUBFORMAT (1 << SND_PCM_HW_PARAM_SUBFORMAT)
|
||||
|
|
@ -399,6 +483,6 @@ const snd_interval_t *snd_pcm_hw_param_value_interval(const snd_pcm_hw_params_t
|
|||
#define SND_PCM_HW_PARBIT_TICK_TIME (1 << SND_PCM_HW_PARAM_TICK_TIME)
|
||||
|
||||
|
||||
#define SND_PCM_ACCBIT_MMAP ((1 << SND_PCM_ACCESS_MMAP_INTERLEAVED) | \
|
||||
(1 << SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \
|
||||
(1 << SND_PCM_ACCESS_MMAP_COMPLEX))
|
||||
#define SND_PCM_ACCBIT_MMAP ((1 << (unsigned long) SND_PCM_ACCESS_MMAP_INTERLEAVED) | \
|
||||
(1 << (unsigned long) SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \
|
||||
(1 << (unsigned long) SND_PCM_ACCESS_MMAP_COMPLEX))
|
||||
|
|
|
|||
1047
src/pcm/pcm_m4.c
Normal file
1047
src/pcm/pcm_m4.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -26,6 +26,9 @@
|
|||
#define bswap_16 swab16
|
||||
#define bswap_32 swab32
|
||||
#define bswap_64 swab64
|
||||
#define SND_PCM_FORMAT_NONE (-1)
|
||||
#define snd_enum_to_int(v) (v)
|
||||
#define snd_int_to_enum(v) (v)
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -36,9 +39,9 @@
|
|||
#include "pcm_local.h"
|
||||
#endif
|
||||
|
||||
int snd_pcm_format_signed(int format)
|
||||
int snd_pcm_format_signed(snd_pcm_format_t format)
|
||||
{
|
||||
switch (format) {
|
||||
switch (snd_enum_to_int(format)) {
|
||||
case SNDRV_PCM_FORMAT_S8:
|
||||
case SNDRV_PCM_FORMAT_S16_LE:
|
||||
case SNDRV_PCM_FORMAT_S16_BE:
|
||||
|
|
@ -60,7 +63,7 @@ int snd_pcm_format_signed(int format)
|
|||
}
|
||||
}
|
||||
|
||||
int snd_pcm_format_unsigned(int format)
|
||||
int snd_pcm_format_unsigned(snd_pcm_format_t format)
|
||||
{
|
||||
int val;
|
||||
|
||||
|
|
@ -70,14 +73,14 @@ int snd_pcm_format_unsigned(int format)
|
|||
return !val;
|
||||
}
|
||||
|
||||
int snd_pcm_format_linear(int format)
|
||||
int snd_pcm_format_linear(snd_pcm_format_t format)
|
||||
{
|
||||
return snd_pcm_format_signed(format) >= 0;
|
||||
}
|
||||
|
||||
int snd_pcm_format_little_endian(int format)
|
||||
int snd_pcm_format_little_endian(snd_pcm_format_t format)
|
||||
{
|
||||
switch (format) {
|
||||
switch (snd_enum_to_int(format)) {
|
||||
case SNDRV_PCM_FORMAT_S16_LE:
|
||||
case SNDRV_PCM_FORMAT_U16_LE:
|
||||
case SNDRV_PCM_FORMAT_S24_LE:
|
||||
|
|
@ -103,7 +106,7 @@ int snd_pcm_format_little_endian(int format)
|
|||
}
|
||||
}
|
||||
|
||||
int snd_pcm_format_big_endian(int format)
|
||||
int snd_pcm_format_big_endian(snd_pcm_format_t format)
|
||||
{
|
||||
int val;
|
||||
|
||||
|
|
@ -113,7 +116,7 @@ int snd_pcm_format_big_endian(int format)
|
|||
return !val;
|
||||
}
|
||||
|
||||
int snd_pcm_format_cpu_endian(int format)
|
||||
int snd_pcm_format_cpu_endian(snd_pcm_format_t format)
|
||||
{
|
||||
#ifdef SNDRV_LITTLE_ENDIAN
|
||||
return snd_pcm_format_little_endian(format);
|
||||
|
|
@ -122,9 +125,9 @@ int snd_pcm_format_cpu_endian(int format)
|
|||
#endif
|
||||
}
|
||||
|
||||
int snd_pcm_format_width(int format)
|
||||
int snd_pcm_format_width(snd_pcm_format_t format)
|
||||
{
|
||||
switch (format) {
|
||||
switch (snd_enum_to_int(format)) {
|
||||
case SNDRV_PCM_FORMAT_S8:
|
||||
case SNDRV_PCM_FORMAT_U8:
|
||||
return 8;
|
||||
|
|
@ -161,9 +164,9 @@ int snd_pcm_format_width(int format)
|
|||
}
|
||||
}
|
||||
|
||||
int snd_pcm_format_physical_width(int format)
|
||||
int snd_pcm_format_physical_width(snd_pcm_format_t format)
|
||||
{
|
||||
switch (format) {
|
||||
switch (snd_enum_to_int(format)) {
|
||||
case SNDRV_PCM_FORMAT_S8:
|
||||
case SNDRV_PCM_FORMAT_U8:
|
||||
return 8;
|
||||
|
|
@ -198,9 +201,9 @@ int snd_pcm_format_physical_width(int format)
|
|||
}
|
||||
}
|
||||
|
||||
ssize_t snd_pcm_format_size(int format, size_t samples)
|
||||
ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples)
|
||||
{
|
||||
switch (format) {
|
||||
switch (snd_enum_to_int(format)) {
|
||||
case SNDRV_PCM_FORMAT_S8:
|
||||
case SNDRV_PCM_FORMAT_U8:
|
||||
return samples;
|
||||
|
|
@ -238,9 +241,9 @@ ssize_t snd_pcm_format_size(int format, size_t samples)
|
|||
}
|
||||
}
|
||||
|
||||
u_int64_t snd_pcm_format_silence_64(int format)
|
||||
u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format)
|
||||
{
|
||||
switch (format) {
|
||||
switch (snd_enum_to_int(format)) {
|
||||
case SNDRV_PCM_FORMAT_S8:
|
||||
case SNDRV_PCM_FORMAT_S16_LE:
|
||||
case SNDRV_PCM_FORMAT_S16_BE:
|
||||
|
|
@ -340,27 +343,28 @@ u_int64_t snd_pcm_format_silence_64(int format)
|
|||
case SNDRV_PCM_FORMAT_IMA_ADPCM: /* special case */
|
||||
case SNDRV_PCM_FORMAT_MPEG:
|
||||
case SNDRV_PCM_FORMAT_GSM:
|
||||
case SNDRV_PCM_FORMAT_SPECIAL:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
u_int32_t snd_pcm_format_silence_32(int format)
|
||||
u_int32_t snd_pcm_format_silence_32(snd_pcm_format_t format)
|
||||
{
|
||||
return (u_int32_t)snd_pcm_format_silence_64(format);
|
||||
}
|
||||
|
||||
u_int16_t snd_pcm_format_silence_16(int format)
|
||||
u_int16_t snd_pcm_format_silence_16(snd_pcm_format_t format)
|
||||
{
|
||||
return (u_int16_t)snd_pcm_format_silence_64(format);
|
||||
}
|
||||
|
||||
u_int8_t snd_pcm_format_silence(int format)
|
||||
u_int8_t snd_pcm_format_silence(snd_pcm_format_t format)
|
||||
{
|
||||
return (u_int8_t)snd_pcm_format_silence_64(format);
|
||||
}
|
||||
|
||||
int snd_pcm_format_set_silence(int format, void *data, unsigned int samples)
|
||||
int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int samples)
|
||||
{
|
||||
if (samples == 0)
|
||||
return 0;
|
||||
|
|
@ -422,7 +426,7 @@ static int linear_formats[4*2*2] = {
|
|||
SNDRV_PCM_FORMAT_U32_BE
|
||||
};
|
||||
|
||||
int snd_pcm_build_linear_format(int width, int unsignd, int big_endian)
|
||||
snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_endian)
|
||||
{
|
||||
switch (width) {
|
||||
case 8:
|
||||
|
|
@ -438,7 +442,7 @@ int snd_pcm_build_linear_format(int width, int unsignd, int big_endian)
|
|||
width = 3;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
return SND_PCM_FORMAT_NONE;
|
||||
}
|
||||
return ((int(*)[2][2])linear_formats)[width][!!unsignd][!!big_endian];
|
||||
return snd_int_to_enum(((int(*)[2][2])linear_formats)[width][!!unsignd][!!big_endian]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ 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)
|
||||
{
|
||||
switch (pcm->access) {
|
||||
switch (snd_enum_to_int(pcm->access)) {
|
||||
case SND_PCM_ACCESS_MMAP_INTERLEAVED:
|
||||
case SND_PCM_ACCESS_RW_INTERLEAVED:
|
||||
info->first = info->channel * pcm->sample_bits;
|
||||
|
|
@ -432,7 +432,7 @@ snd_pcm_sframes_t snd_pcm_write_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t size)
|
|||
snd_pcm_uframes_t cont = pcm->buffer_size - offset;
|
||||
if (cont < frames)
|
||||
frames = cont;
|
||||
switch (pcm->access) {
|
||||
switch (snd_enum_to_int(pcm->access)) {
|
||||
case SND_PCM_ACCESS_MMAP_INTERLEAVED:
|
||||
{
|
||||
const snd_pcm_channel_area_t *a = snd_pcm_mmap_areas(pcm);
|
||||
|
|
@ -478,7 +478,7 @@ snd_pcm_sframes_t snd_pcm_read_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t size)
|
|||
snd_pcm_uframes_t cont = pcm->buffer_size - offset;
|
||||
if (cont < frames)
|
||||
frames = cont;
|
||||
switch (pcm->access) {
|
||||
switch (snd_enum_to_int(pcm->access)) {
|
||||
case SND_PCM_ACCESS_MMAP_INTERLEAVED:
|
||||
{
|
||||
const snd_pcm_channel_area_t *a = snd_pcm_mmap_areas(pcm);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ typedef struct {
|
|||
snd_pcm_plugin_t plug;
|
||||
int getput_idx;
|
||||
mulaw_f func;
|
||||
int sformat;
|
||||
snd_pcm_format_t sformat;
|
||||
} snd_pcm_mulaw_t;
|
||||
|
||||
static inline int val_seg(int val)
|
||||
|
|
@ -232,24 +232,22 @@ static int snd_pcm_mulaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
|
|||
{
|
||||
snd_pcm_mulaw_t *mulaw = pcm->private;
|
||||
int err;
|
||||
snd_mask_t *access_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) {
|
||||
snd_mask_t *format_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof());
|
||||
snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
format_mask);
|
||||
} else {
|
||||
err = _snd_pcm_hw_param_set(params,
|
||||
SND_PCM_HW_PARAM_FORMAT,
|
||||
SND_PCM_FORMAT_MU_LAW, 0);
|
||||
err = _snd_pcm_hw_params_set_format(params,
|
||||
SND_PCM_FORMAT_MU_LAW);
|
||||
}
|
||||
err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||
SND_PCM_SUBFORMAT_STD, 0);
|
||||
err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD);
|
||||
if (err < 0)
|
||||
return err;
|
||||
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
||||
|
|
@ -259,15 +257,13 @@ static int snd_pcm_mulaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
|
|||
static int snd_pcm_mulaw_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
|
||||
{
|
||||
snd_pcm_mulaw_t *mulaw = pcm->private;
|
||||
snd_mask_t *saccess_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||
_snd_pcm_hw_params_any(sparams);
|
||||
_snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
saccess_mask);
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_FORMAT,
|
||||
mulaw->sformat, 0);
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||
SND_PCM_SUBFORMAT_STD, 0);
|
||||
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
saccess_mask);
|
||||
_snd_pcm_hw_params_set_format(sparams, mulaw->sformat);
|
||||
_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -330,7 +326,7 @@ static int snd_pcm_mulaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
|||
|
||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||
if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) {
|
||||
mulaw->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0), SND_PCM_FORMAT_S16);
|
||||
mulaw->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_params_get_format(params), SND_PCM_FORMAT_S16);
|
||||
mulaw->func = snd_pcm_mulaw_encode;
|
||||
} else {
|
||||
mulaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, mulaw->sformat);
|
||||
|
|
@ -338,7 +334,7 @@ static int snd_pcm_mulaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
|||
}
|
||||
} else {
|
||||
if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) {
|
||||
mulaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0));
|
||||
mulaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_params_get_format(params));
|
||||
mulaw->func = snd_pcm_mulaw_decode;
|
||||
} else {
|
||||
mulaw->getput_idx = snd_pcm_linear_get_index(mulaw->sformat, SND_PCM_FORMAT_S16);
|
||||
|
|
@ -446,7 +442,7 @@ snd_pcm_ops_t snd_pcm_mulaw_ops = {
|
|||
munmap: snd_pcm_plugin_munmap,
|
||||
};
|
||||
|
||||
int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave)
|
||||
int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave)
|
||||
{
|
||||
snd_pcm_t *pcm;
|
||||
snd_pcm_mulaw_t *mulaw;
|
||||
|
|
@ -489,13 +485,13 @@ int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *sla
|
|||
|
||||
int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name,
|
||||
snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i;
|
||||
char *sname = NULL;
|
||||
int err;
|
||||
snd_pcm_t *spcm;
|
||||
int sformat = -1;
|
||||
snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE;
|
||||
snd_config_foreach(i, conf) {
|
||||
snd_config_t *n = snd_config_entry(i);
|
||||
if (strcmp(n->id, "comment") == 0)
|
||||
|
|
@ -520,7 +516,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name,
|
|||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat < 0) {
|
||||
if (sformat == SND_PCM_FORMAT_NONE) {
|
||||
ERR("Unknown sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -538,7 +534,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name,
|
|||
ERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (sformat < 0) {
|
||||
if (sformat == SND_PCM_FORMAT_NONE) {
|
||||
ERR("sformat is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ static int snd_pcm_multi_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
|
|||
if (multi->slaves_count == 1)
|
||||
return snd_pcm_info(multi->slaves[0].pcm, info);
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->stream = pcm->stream;
|
||||
info->stream = snd_enum_to_int(pcm->stream);
|
||||
info->card = -1;
|
||||
strcpy(info->id, "multi");
|
||||
strcpy(info->name, "multi");
|
||||
|
|
@ -96,11 +96,11 @@ static int snd_pcm_multi_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
|
|||
static int snd_pcm_multi_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||
{
|
||||
snd_pcm_multi_t *multi = pcm->private;
|
||||
snd_mask_t *access_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
int err;
|
||||
snd_mask_any(access_mask);
|
||||
snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
snd_pcm_access_mask_any(access_mask);
|
||||
snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -117,10 +117,10 @@ static int snd_pcm_multi_hw_refine_sprepare(snd_pcm_t *pcm, int slave_idx,
|
|||
{
|
||||
snd_pcm_multi_t *multi = pcm->private;
|
||||
snd_pcm_multi_slave_t *slave = &multi->slaves[slave_idx];
|
||||
snd_mask_t *saccess_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||
_snd_pcm_hw_params_any(sparams);
|
||||
_snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
saccess_mask);
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_CHANNELS,
|
||||
slave->channels_count, 0);
|
||||
|
|
@ -142,14 +142,14 @@ static int snd_pcm_multi_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
|
|||
SND_PCM_HW_PARBIT_BUFFER_SIZE |
|
||||
SND_PCM_HW_PARBIT_BUFFER_TIME |
|
||||
SND_PCM_HW_PARBIT_TICK_TIME);
|
||||
const snd_mask_t *access_mask = snd_pcm_hw_param_value_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
||||
if (!snd_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) &&
|
||||
!snd_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED) &&
|
||||
!snd_mask_test(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) {
|
||||
snd_mask_t *saccess_mask = alloca(snd_mask_sizeof());
|
||||
snd_mask_any(saccess_mask);
|
||||
snd_mask_reset(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
|
||||
err = _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
const snd_pcm_access_mask_t *access_mask = snd_pcm_hw_param_get_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
||||
if (!snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) &&
|
||||
!snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED) &&
|
||||
!snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) {
|
||||
snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_pcm_access_mask_any(saccess_mask);
|
||||
snd_pcm_access_mask_reset(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
|
||||
err = _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
saccess_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -175,16 +175,16 @@ static int snd_pcm_multi_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
|
|||
SND_PCM_HW_PARBIT_BUFFER_SIZE |
|
||||
SND_PCM_HW_PARBIT_BUFFER_TIME |
|
||||
SND_PCM_HW_PARBIT_TICK_TIME);
|
||||
snd_mask_t *access_mask = alloca(snd_mask_sizeof());
|
||||
const snd_mask_t *saccess_mask = snd_pcm_hw_param_value_mask(sparams, SND_PCM_HW_PARAM_ACCESS);
|
||||
snd_mask_any(access_mask);
|
||||
snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
|
||||
if (!snd_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED))
|
||||
snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
|
||||
if (!snd_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_COMPLEX) &&
|
||||
!snd_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED))
|
||||
snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_COMPLEX);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
const snd_pcm_access_mask_t *saccess_mask = snd_pcm_hw_param_get_mask(sparams, SND_PCM_HW_PARAM_ACCESS);
|
||||
snd_pcm_access_mask_any(access_mask);
|
||||
snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
|
||||
if (!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED))
|
||||
snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
|
||||
if (!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_COMPLEX) &&
|
||||
!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED))
|
||||
snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_COMPLEX);
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -320,7 +320,7 @@ static int snd_pcm_multi_status(snd_pcm_t *pcm, snd_pcm_status_t *status)
|
|||
return snd_pcm_status(slave, status);
|
||||
}
|
||||
|
||||
static int snd_pcm_multi_state(snd_pcm_t *pcm)
|
||||
static snd_pcm_state_t snd_pcm_multi_state(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_multi_t *multi = pcm->private;
|
||||
snd_pcm_t *slave = multi->slaves[0].pcm;
|
||||
|
|
@ -519,7 +519,7 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, char *name,
|
|||
snd_pcm_t *pcm;
|
||||
snd_pcm_multi_t *multi;
|
||||
unsigned int i;
|
||||
int stream;
|
||||
snd_pcm_stream_t stream;
|
||||
char slave_map[32][32] = { { 0 } };
|
||||
|
||||
assert(pcmp);
|
||||
|
|
@ -583,7 +583,7 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, char *name,
|
|||
}
|
||||
|
||||
int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i, j;
|
||||
snd_config_t *slave = NULL;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
typedef struct {
|
||||
snd_timestamp_t trigger_tstamp;
|
||||
int state;
|
||||
snd_pcm_state_t state;
|
||||
int shmid;
|
||||
snd_pcm_uframes_t appl_ptr;
|
||||
snd_pcm_uframes_t hw_ptr;
|
||||
|
|
@ -55,7 +55,7 @@ static int snd_pcm_null_async(snd_pcm_t *pcm ATTRIBUTE_UNUSED, int sig ATTRIBUTE
|
|||
static int snd_pcm_null_info(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_info_t * info)
|
||||
{
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->stream = pcm->stream;
|
||||
info->stream = snd_enum_to_int(pcm->stream);
|
||||
info->card = -1;
|
||||
strcpy(info->id, "null");
|
||||
strcpy(info->name, "null");
|
||||
|
|
@ -74,7 +74,7 @@ static int snd_pcm_null_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
|||
{
|
||||
snd_pcm_null_t *null = pcm->private;
|
||||
memset(status, 0, sizeof(*status));
|
||||
status->state = null->state;
|
||||
status->state = snd_enum_to_int(null->state);
|
||||
status->trigger_tstamp = null->trigger_tstamp;
|
||||
gettimeofday(&status->tstamp, 0);
|
||||
status->avail = pcm->buffer_size;
|
||||
|
|
@ -82,7 +82,7 @@ static int snd_pcm_null_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int snd_pcm_null_state(snd_pcm_t *pcm)
|
||||
static snd_pcm_state_t snd_pcm_null_state(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_null_t *null = pcm->private;
|
||||
return null->state;
|
||||
|
|
@ -152,7 +152,7 @@ static int snd_pcm_null_pause(snd_pcm_t *pcm, int enable)
|
|||
static snd_pcm_sframes_t snd_pcm_null_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
|
||||
{
|
||||
snd_pcm_null_t *null = pcm->private;
|
||||
switch (null->state) {
|
||||
switch (snd_enum_to_int(null->state)) {
|
||||
case SND_PCM_STATE_PREPARED:
|
||||
case SND_PCM_STATE_RUNNING:
|
||||
snd_pcm_mmap_appl_backward(pcm, frames);
|
||||
|
|
@ -166,7 +166,7 @@ static snd_pcm_sframes_t snd_pcm_null_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t f
|
|||
static snd_pcm_sframes_t snd_pcm_null_fwd(snd_pcm_t *pcm, snd_pcm_uframes_t size)
|
||||
{
|
||||
snd_pcm_null_t *null = pcm->private;
|
||||
switch (null->state) {
|
||||
switch (snd_enum_to_int(null->state)) {
|
||||
case SND_PCM_STATE_PREPARED:
|
||||
case SND_PCM_STATE_RUNNING:
|
||||
snd_pcm_mmap_appl_forward(pcm, size);
|
||||
|
|
@ -319,7 +319,7 @@ snd_pcm_fast_ops_t snd_pcm_null_fast_ops = {
|
|||
mmap_forward: snd_pcm_null_mmap_forward,
|
||||
};
|
||||
|
||||
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, snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_pcm_t *pcm;
|
||||
snd_pcm_null_t *null;
|
||||
|
|
@ -372,7 +372,7 @@ 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,
|
||||
snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i;
|
||||
snd_config_foreach(i, conf) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -69,7 +69,7 @@ static int snd_pcm_plug_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int linear_preferred_formats[] = {
|
||||
static snd_pcm_format_t linear_preferred_formats[] = {
|
||||
#ifdef SND_LITTLE_ENDIAN
|
||||
SND_PCM_FORMAT_S16_LE,
|
||||
SND_PCM_FORMAT_U16_LE,
|
||||
|
|
@ -107,33 +107,33 @@ static unsigned int linear_preferred_formats[] = {
|
|||
SND_PCM_FORMAT_U8
|
||||
};
|
||||
|
||||
static unsigned int nonlinear_preferred_formats[] = {
|
||||
static snd_pcm_format_t nonlinear_preferred_formats[] = {
|
||||
SND_PCM_FORMAT_MU_LAW,
|
||||
SND_PCM_FORMAT_A_LAW,
|
||||
SND_PCM_FORMAT_IMA_ADPCM,
|
||||
};
|
||||
|
||||
static int snd_pcm_plug_slave_format(int format, const snd_mask_t *format_mask)
|
||||
static snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format, const snd_pcm_format_mask_t *format_mask)
|
||||
{
|
||||
int w, u, e, wid, w1, dw;
|
||||
snd_mask_t *lin = alloca(snd_mask_sizeof());
|
||||
if (snd_mask_test(format_mask, format))
|
||||
if (snd_pcm_format_mask_test(format_mask, format))
|
||||
return format;
|
||||
snd_mask_load(lin, SND_PCM_FMTBIT_LINEAR);
|
||||
if (!snd_mask_test(lin, format)) {
|
||||
if (!snd_pcm_format_mask_test(lin, format)) {
|
||||
unsigned int i;
|
||||
switch (format) {
|
||||
switch (snd_enum_to_int(format)) {
|
||||
case SND_PCM_FORMAT_MU_LAW:
|
||||
case SND_PCM_FORMAT_A_LAW:
|
||||
case SND_PCM_FORMAT_IMA_ADPCM:
|
||||
for (i = 0; i < sizeof(linear_preferred_formats) / sizeof(linear_preferred_formats[0]); ++i) {
|
||||
unsigned int f = linear_preferred_formats[i];
|
||||
if (snd_mask_test(format_mask, f))
|
||||
snd_pcm_format_t f = linear_preferred_formats[i];
|
||||
if (snd_pcm_format_mask_test(format_mask, f))
|
||||
return f;
|
||||
}
|
||||
/* Fall through */
|
||||
default:
|
||||
return -EINVAL;
|
||||
return SND_PCM_FORMAT_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -141,11 +141,11 @@ static int snd_pcm_plug_slave_format(int format, const snd_mask_t *format_mask)
|
|||
if (snd_mask_empty(lin)) {
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof(nonlinear_preferred_formats) / sizeof(nonlinear_preferred_formats[0]); ++i) {
|
||||
unsigned int f = nonlinear_preferred_formats[i];
|
||||
if (snd_mask_test(format_mask, f))
|
||||
snd_pcm_format_t f = nonlinear_preferred_formats[i];
|
||||
if (snd_pcm_format_mask_test(format_mask, f))
|
||||
return f;
|
||||
}
|
||||
return -EINVAL;
|
||||
return SND_PCM_FORMAT_NONE;
|
||||
}
|
||||
w = snd_pcm_format_width(format);
|
||||
u = snd_pcm_format_unsigned(format);
|
||||
|
|
@ -157,9 +157,10 @@ static int snd_pcm_plug_slave_format(int format, const snd_mask_t *format_mask)
|
|||
for (end = 0; end < 2; ++end) {
|
||||
int sgn, u1 = u;
|
||||
for (sgn = 0; sgn < 2; ++sgn) {
|
||||
int f;
|
||||
snd_pcm_format_t f;
|
||||
f = snd_pcm_build_linear_format(w1, u1, e1);
|
||||
if (f >= 0 && snd_mask_test(format_mask, f))
|
||||
assert(f != SND_PCM_FORMAT_NONE);
|
||||
if (snd_pcm_format_mask_test(format_mask, f))
|
||||
return f;
|
||||
u1 = !u1;
|
||||
}
|
||||
|
|
@ -172,13 +173,13 @@ static int snd_pcm_plug_slave_format(int format, const snd_mask_t *format_mask)
|
|||
dw = -8;
|
||||
}
|
||||
}
|
||||
return -EINVAL;
|
||||
return SND_PCM_FORMAT_NONE;
|
||||
}
|
||||
|
||||
#define SND_PCM_FMTBIT_PLUG (SND_PCM_FMTBIT_LINEAR | \
|
||||
(1 << SND_PCM_FORMAT_MU_LAW) | \
|
||||
(1 << SND_PCM_FORMAT_A_LAW) | \
|
||||
(1 << SND_PCM_FORMAT_IMA_ADPCM))
|
||||
(1 << snd_enum_to_int(SND_PCM_FORMAT_MU_LAW)) | \
|
||||
(1 << snd_enum_to_int(SND_PCM_FORMAT_A_LAW)) | \
|
||||
(1 << snd_enum_to_int(SND_PCM_FORMAT_IMA_ADPCM)))
|
||||
|
||||
|
||||
static void snd_pcm_plug_clear(snd_pcm_t *pcm)
|
||||
|
|
@ -286,8 +287,9 @@ static int snd_pcm_plug_change_channels(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm
|
|||
static int snd_pcm_plug_change_format(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_plug_params_t *clt, snd_pcm_plug_params_t *slv)
|
||||
{
|
||||
snd_pcm_plug_t *plug = pcm->private;
|
||||
int err, cfmt;
|
||||
int (*f)(snd_pcm_t **pcm, char *name, int sformat, snd_pcm_t *slave, int close_slave);
|
||||
int err;
|
||||
snd_pcm_format_t cfmt;
|
||||
int (*f)(snd_pcm_t **pcm, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
|
||||
if (snd_pcm_format_linear(slv->format)) {
|
||||
/* Conversion is done in another plugin */
|
||||
if (clt->format == slv->format ||
|
||||
|
|
@ -295,7 +297,7 @@ static int snd_pcm_plug_change_format(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_p
|
|||
clt->channels != slv->channels)
|
||||
return 0;
|
||||
cfmt = clt->format;
|
||||
switch (clt->format) {
|
||||
switch (snd_enum_to_int(clt->format)) {
|
||||
case SND_PCM_FORMAT_MU_LAW:
|
||||
f = snd_pcm_mulaw_open;
|
||||
break;
|
||||
|
|
@ -316,7 +318,7 @@ static int snd_pcm_plug_change_format(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_p
|
|||
clt->rate == slv->rate &&
|
||||
clt->channels == clt->channels)
|
||||
return 0;
|
||||
switch (slv->format) {
|
||||
switch (snd_enum_to_int(slv->format)) {
|
||||
case SND_PCM_FORMAT_MU_LAW:
|
||||
f = snd_pcm_mulaw_open;
|
||||
break;
|
||||
|
|
@ -412,54 +414,54 @@ static int snd_pcm_plug_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p
|
|||
snd_pcm_t *slave = plug->req_slave;
|
||||
unsigned int links = (SND_PCM_HW_PARBIT_PERIOD_TIME |
|
||||
SND_PCM_HW_PARBIT_TICK_TIME);
|
||||
const snd_mask_t *format_mask, *sformat_mask;
|
||||
const snd_pcm_format_mask_t *format_mask, *sformat_mask;
|
||||
snd_mask_t *sfmt_mask = alloca(snd_mask_sizeof());
|
||||
int err;
|
||||
unsigned int format;
|
||||
snd_pcm_format_t format;
|
||||
snd_interval_t t, buffer_size;
|
||||
const snd_interval_t *srate, *crate;
|
||||
snd_pcm_hw_param_refine_near(slave, sparams, SND_PCM_HW_PARAM_RATE,
|
||||
params);
|
||||
snd_pcm_hw_param_refine_near(slave, sparams, SND_PCM_HW_PARAM_CHANNELS,
|
||||
params);
|
||||
format_mask = snd_pcm_hw_param_value_mask(params,
|
||||
format_mask = snd_pcm_hw_param_get_mask(params,
|
||||
SND_PCM_HW_PARAM_FORMAT);
|
||||
sformat_mask = snd_pcm_hw_param_value_mask(sparams,
|
||||
sformat_mask = snd_pcm_hw_param_get_mask(sparams,
|
||||
SND_PCM_HW_PARAM_FORMAT);
|
||||
snd_mask_none(sfmt_mask);
|
||||
for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) {
|
||||
int f;
|
||||
if (!snd_mask_test(format_mask, format))
|
||||
for (format = 0; format <= SND_PCM_FORMAT_LAST; snd_enum_incr(format)) {
|
||||
snd_pcm_format_t f;
|
||||
if (!snd_pcm_format_mask_test(format_mask, format))
|
||||
continue;
|
||||
if (snd_mask_test(sformat_mask, format))
|
||||
if (snd_pcm_format_mask_test(sformat_mask, format))
|
||||
f = format;
|
||||
else {
|
||||
f = snd_pcm_plug_slave_format(format, sformat_mask);
|
||||
if (f < 0)
|
||||
if (f == SND_PCM_FORMAT_NONE)
|
||||
continue;
|
||||
}
|
||||
snd_mask_set(sfmt_mask, f);
|
||||
snd_pcm_format_mask_set(sfmt_mask, f);
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_param_mask(slave, sparams,
|
||||
SND_PCM_HW_PARAM_FORMAT, sfmt_mask);
|
||||
err = snd_pcm_hw_param_set_mask(slave, sparams, SND_CHANGE,
|
||||
SND_PCM_HW_PARAM_FORMAT, sfmt_mask);
|
||||
assert(err >= 0);
|
||||
|
||||
if (snd_pcm_hw_param_never_eq(params, SND_PCM_HW_PARAM_FORMAT, sparams) ||
|
||||
snd_pcm_hw_param_never_eq(params, SND_PCM_HW_PARAM_CHANNELS, sparams) ||
|
||||
snd_pcm_hw_param_never_eq(params, SND_PCM_HW_PARAM_RATE, sparams) ||
|
||||
snd_pcm_hw_param_never_eq(params, SND_PCM_HW_PARAM_ACCESS, sparams)) {
|
||||
snd_mask_t *access_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(access_mask, SND_PCM_ACCBIT_MMAP);
|
||||
_snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
}
|
||||
snd_interval_copy(&buffer_size, snd_pcm_hw_param_value_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE));
|
||||
snd_interval_copy(&buffer_size, snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE));
|
||||
snd_interval_unfloor(&buffer_size);
|
||||
crate = snd_pcm_hw_param_value_interval(params, SND_PCM_HW_PARAM_RATE);
|
||||
srate = snd_pcm_hw_param_value_interval(sparams, SND_PCM_HW_PARAM_RATE);
|
||||
crate = snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE);
|
||||
srate = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE);
|
||||
snd_interval_muldiv(&buffer_size, srate, crate, &t);
|
||||
err = _snd_pcm_hw_param_refine_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE, &t);
|
||||
err = _snd_pcm_hw_param_set_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE, &t);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_params_refine(sparams, links, params);
|
||||
|
|
@ -474,54 +476,54 @@ static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
|
|||
{
|
||||
unsigned int links = (SND_PCM_HW_PARBIT_PERIOD_TIME |
|
||||
SND_PCM_HW_PARBIT_TICK_TIME);
|
||||
const snd_mask_t *format_mask, *sformat_mask;
|
||||
const snd_pcm_format_mask_t *format_mask, *sformat_mask;
|
||||
snd_mask_t *fmt_mask = alloca(snd_mask_sizeof());
|
||||
int err;
|
||||
unsigned int format;
|
||||
snd_pcm_format_t format;
|
||||
snd_interval_t t;
|
||||
const snd_interval_t *sbuffer_size;
|
||||
const snd_interval_t *srate, *crate;
|
||||
unsigned int rate_min, srate_min;
|
||||
int rate_mindir, srate_mindir;
|
||||
format_mask = snd_pcm_hw_param_value_mask(params,
|
||||
format_mask = snd_pcm_hw_param_get_mask(params,
|
||||
SND_PCM_HW_PARAM_FORMAT);
|
||||
sformat_mask = snd_pcm_hw_param_value_mask(sparams,
|
||||
sformat_mask = snd_pcm_hw_param_get_mask(sparams,
|
||||
SND_PCM_HW_PARAM_FORMAT);
|
||||
snd_mask_none(fmt_mask);
|
||||
for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) {
|
||||
int f;
|
||||
if (!snd_mask_test(format_mask, format))
|
||||
for (format = 0; format <= SND_PCM_FORMAT_LAST; snd_enum_incr(format)) {
|
||||
snd_pcm_format_t f;
|
||||
if (!snd_pcm_format_mask_test(format_mask, format))
|
||||
continue;
|
||||
if (snd_mask_test(sformat_mask, format))
|
||||
if (snd_pcm_format_mask_test(sformat_mask, format))
|
||||
f = format;
|
||||
else {
|
||||
f = snd_pcm_plug_slave_format(format, sformat_mask);
|
||||
if (f < 0)
|
||||
if (f == SND_PCM_FORMAT_NONE)
|
||||
continue;
|
||||
}
|
||||
snd_mask_set(fmt_mask, format);
|
||||
snd_pcm_format_mask_set(fmt_mask, format);
|
||||
}
|
||||
|
||||
err = _snd_pcm_hw_param_mask(params,
|
||||
err = _snd_pcm_hw_param_set_mask(params,
|
||||
SND_PCM_HW_PARAM_FORMAT, fmt_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
/* This is a temporary hack, waiting for a better solution */
|
||||
rate_min = snd_pcm_hw_param_value_min(params, SND_PCM_HW_PARAM_RATE, &rate_mindir);
|
||||
srate_min = snd_pcm_hw_param_value_min(sparams, SND_PCM_HW_PARAM_RATE, &srate_mindir);
|
||||
rate_min = snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_RATE, &rate_mindir);
|
||||
srate_min = snd_pcm_hw_param_get_min(sparams, SND_PCM_HW_PARAM_RATE, &srate_mindir);
|
||||
if (rate_min == srate_min && srate_mindir > rate_mindir) {
|
||||
err = _snd_pcm_hw_param_min(params, SND_PCM_HW_PARAM_RATE, srate_min, srate_mindir);
|
||||
err = _snd_pcm_hw_param_set_min(params, SND_PCM_HW_PARAM_RATE, srate_min, srate_mindir);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
|
||||
sbuffer_size = snd_pcm_hw_param_value_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE);
|
||||
crate = snd_pcm_hw_param_value_interval(params, SND_PCM_HW_PARAM_RATE);
|
||||
srate = snd_pcm_hw_param_value_interval(sparams, SND_PCM_HW_PARAM_RATE);
|
||||
sbuffer_size = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE);
|
||||
crate = snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE);
|
||||
srate = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE);
|
||||
snd_interval_muldiv(sbuffer_size, crate, srate, &t);
|
||||
snd_interval_floor(&t);
|
||||
err = _snd_pcm_hw_param_refine_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE, &t);
|
||||
err = _snd_pcm_hw_param_set_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE, &t);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_params_refine(params, links, sparams);
|
||||
|
|
@ -563,21 +565,21 @@ static int snd_pcm_plug_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
|||
err = snd_pcm_hw_refine_soft(slave, &sparams);
|
||||
assert(err >= 0);
|
||||
|
||||
clt_params.access = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_ACCESS, 0);
|
||||
clt_params.format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0);
|
||||
clt_params.channels = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_CHANNELS, 0);
|
||||
clt_params.rate = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_RATE, 0);
|
||||
clt_params.access = snd_pcm_hw_params_get_access(params);
|
||||
clt_params.format = snd_pcm_hw_params_get_format(params);
|
||||
clt_params.channels = snd_pcm_hw_params_get_channels(params);
|
||||
clt_params.rate = snd_pcm_hw_params_get_rate(params, 0);
|
||||
|
||||
slv_params.format = snd_pcm_hw_param_value(&sparams, SND_PCM_HW_PARAM_FORMAT, 0);
|
||||
slv_params.channels = snd_pcm_hw_param_value(&sparams, SND_PCM_HW_PARAM_CHANNELS, 0);
|
||||
slv_params.rate = snd_pcm_hw_param_value(&sparams, SND_PCM_HW_PARAM_RATE, 0);
|
||||
slv_params.format = snd_pcm_hw_params_get_format(&sparams);
|
||||
slv_params.channels = snd_pcm_hw_params_get_channels(&sparams);
|
||||
slv_params.rate = snd_pcm_hw_params_get_rate(&sparams, 0);
|
||||
snd_pcm_plug_clear(pcm);
|
||||
if (!(clt_params.format == slv_params.format &&
|
||||
clt_params.channels == slv_params.channels &&
|
||||
clt_params.rate == slv_params.rate &&
|
||||
snd_pcm_hw_param_test(&sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
clt_params.access))) {
|
||||
slv_params.access = snd_pcm_hw_param_first(slave, &sparams, SND_PCM_HW_PARAM_ACCESS, 0);
|
||||
snd_pcm_hw_params_set_access(slave, &sparams, SND_TEST,
|
||||
clt_params.access))) {
|
||||
slv_params.access = snd_pcm_hw_params_set_access_first(slave, &sparams);
|
||||
err = snd_pcm_plug_insert_plugins(pcm, &clt_params, &slv_params);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -689,7 +691,7 @@ int snd_pcm_plug_open(snd_pcm_t **pcmp,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_pcm_plug_open_hw(snd_pcm_t **pcmp, char *name, int card, int device, int subdevice, int stream, int mode)
|
||||
int snd_pcm_plug_open_hw(snd_pcm_t **pcmp, char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_pcm_t *slave;
|
||||
int err;
|
||||
|
|
@ -703,7 +705,7 @@ int snd_pcm_plug_open_hw(snd_pcm_t **pcmp, char *name, int card, int device, int
|
|||
|
||||
int _snd_pcm_plug_open(snd_pcm_t **pcmp, char *name,
|
||||
snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i;
|
||||
char *sname = NULL;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_state(snd_pcm_t *pcm)
|
||||
snd_pcm_state_t snd_pcm_plugin_state(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private;
|
||||
return snd_pcm_state(plugin->slave);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ 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_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_state(snd_pcm_t *pcm);
|
||||
snd_pcm_state_t snd_pcm_plugin_state(snd_pcm_t *pcm);
|
||||
int snd_pcm_plugin_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp);
|
||||
int snd_pcm_plugin_prepare(snd_pcm_t *pcm);
|
||||
int snd_pcm_plugin_start(snd_pcm_t *pcm);
|
||||
|
|
@ -66,13 +66,20 @@ int snd_pcm_plugin_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
|
|||
int snd_pcm_plugin_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
|
||||
|
||||
#define SND_PCM_FMTBIT_LINEAR \
|
||||
((1 << SND_PCM_FORMAT_S8 ) | (1 << SND_PCM_FORMAT_U8) | \
|
||||
(1 << SND_PCM_FORMAT_S16_LE) | (1 << SND_PCM_FORMAT_S16_BE) | \
|
||||
(1 << SND_PCM_FORMAT_U16_LE) | (1 << SND_PCM_FORMAT_U16_BE) | \
|
||||
(1 << SND_PCM_FORMAT_S24_LE) | (1 << SND_PCM_FORMAT_S24_BE) | \
|
||||
(1 << SND_PCM_FORMAT_U24_LE) | (1 << SND_PCM_FORMAT_U24_BE) | \
|
||||
(1 << SND_PCM_FORMAT_S32_LE) | (1 << SND_PCM_FORMAT_S32_BE) | \
|
||||
(1 << SND_PCM_FORMAT_U32_LE) | (1 << SND_PCM_FORMAT_U32_BE))
|
||||
((1 << (unsigned long) SND_PCM_FORMAT_S8) | \
|
||||
(1 << (unsigned long) SND_PCM_FORMAT_U8) | \
|
||||
(1 << (unsigned long) SND_PCM_FORMAT_S16_LE) | \
|
||||
(1 << (unsigned long) SND_PCM_FORMAT_S16_BE) | \
|
||||
(1 << (unsigned long) SND_PCM_FORMAT_U16_LE) | \
|
||||
(1 << (unsigned long) SND_PCM_FORMAT_U16_BE) | \
|
||||
(1 << (unsigned long) SND_PCM_FORMAT_S24_LE) | \
|
||||
(1 << (unsigned long) SND_PCM_FORMAT_S24_BE) | \
|
||||
(1 << (unsigned long) SND_PCM_FORMAT_U24_LE) | \
|
||||
(1 << (unsigned long) SND_PCM_FORMAT_U24_BE) | \
|
||||
(1 << (unsigned long) SND_PCM_FORMAT_S32_LE) | \
|
||||
(1 << (unsigned long) SND_PCM_FORMAT_S32_BE) | \
|
||||
(1 << (unsigned long) SND_PCM_FORMAT_U32_LE) | \
|
||||
(1 << (unsigned long) SND_PCM_FORMAT_U32_BE))
|
||||
|
||||
extern snd_pcm_fast_ops_t snd_pcm_plugin_fast_ops;
|
||||
|
||||
|
|
@ -92,31 +99,31 @@ typedef int snd_pcm_route_ttable_entry_t;
|
|||
#define FULL ROUTE_PLUGIN_RESOLUTION
|
||||
#endif
|
||||
|
||||
int snd_pcm_linear_get_index(int src_format, int dst_format);
|
||||
int snd_pcm_linear_put_index(int src_format, int dst_format);
|
||||
int snd_pcm_linear_convert_index(int src_format, int dst_format);
|
||||
int snd_pcm_linear_get_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format);
|
||||
int snd_pcm_linear_put_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format);
|
||||
int snd_pcm_linear_convert_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format);
|
||||
int snd_pcm_copy_open(snd_pcm_t **pcmp, char *name, snd_pcm_t *slave, int close_slave);
|
||||
int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave);
|
||||
int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave);
|
||||
int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave);
|
||||
int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave);
|
||||
int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
|
||||
int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
|
||||
int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
|
||||
int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
|
||||
int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *ttable,
|
||||
unsigned int tt_csize, unsigned int tt_ssize,
|
||||
unsigned int *tt_cused, unsigned int *tt_sused,
|
||||
int schannels);
|
||||
int snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
|
||||
int sformat, unsigned int schannels,
|
||||
snd_pcm_format_t sformat, unsigned int schannels,
|
||||
snd_pcm_route_ttable_entry_t *ttable,
|
||||
unsigned int tt_ssize,
|
||||
unsigned int tt_cused, unsigned int tt_sused,
|
||||
snd_pcm_t *slave, int close_slave);
|
||||
int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, int sformat, int srate, snd_pcm_t *slave, int close_slave);
|
||||
int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, int srate, snd_pcm_t *slave, int close_slave);
|
||||
|
||||
|
||||
#define SND_PCM_ACCBIT_PLUGIN ((1 << SND_PCM_ACCESS_MMAP_INTERLEAVED) | \
|
||||
(1 << SND_PCM_ACCESS_RW_INTERLEAVED) | \
|
||||
(1 << SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \
|
||||
(1 << SND_PCM_ACCESS_RW_NONINTERLEAVED))
|
||||
#define SND_PCM_ACCBIT_PLUGIN ((1 << (unsigned long) SND_PCM_ACCESS_MMAP_INTERLEAVED) | \
|
||||
(1 << (unsigned long) SND_PCM_ACCESS_RW_INTERLEAVED) | \
|
||||
(1 << (unsigned long) SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \
|
||||
(1 << (unsigned long) SND_PCM_ACCESS_RW_NONINTERLEAVED))
|
||||
|
||||
void snd_pcm_linear_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset,
|
||||
const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset,
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ typedef struct {
|
|||
int put_idx;
|
||||
unsigned int pitch;
|
||||
rate_f func;
|
||||
int sformat;
|
||||
snd_pcm_format_t sformat;
|
||||
int srate;
|
||||
snd_pcm_rate_state_t *states;
|
||||
} snd_pcm_rate_t;
|
||||
|
|
@ -226,28 +226,27 @@ snd_pcm_uframes_t snd_pcm_rate_shrink(const snd_pcm_channel_area_t *dst_areas,
|
|||
static int snd_pcm_rate_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params)
|
||||
{
|
||||
int err;
|
||||
snd_mask_t *access_mask = alloca(snd_mask_sizeof());
|
||||
snd_mask_t *format_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof());
|
||||
snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||
snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
format_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||
SND_PCM_SUBFORMAT_STD, 0);
|
||||
err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_param_min(params,
|
||||
SND_PCM_HW_PARAM_RATE, RATE_MIN, 0);
|
||||
err = _snd_pcm_hw_param_set_min(params,
|
||||
SND_PCM_HW_PARAM_RATE, RATE_MIN, 0);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_param_max(params,
|
||||
SND_PCM_HW_PARAM_RATE, RATE_MAX, 0);
|
||||
err = _snd_pcm_hw_param_set_max(params,
|
||||
SND_PCM_HW_PARAM_RATE, RATE_MAX, 0);
|
||||
if (err < 0)
|
||||
return err;
|
||||
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
||||
|
|
@ -257,19 +256,17 @@ static int snd_pcm_rate_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_
|
|||
static int snd_pcm_rate_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
|
||||
{
|
||||
snd_pcm_rate_t *rate = pcm->private;
|
||||
snd_mask_t *saccess_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||
_snd_pcm_hw_params_any(sparams);
|
||||
_snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
saccess_mask);
|
||||
if (rate->sformat >= 0) {
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_FORMAT,
|
||||
rate->sformat, 0);
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||
SND_PCM_SUBFORMAT_STD, 0);
|
||||
if (rate->sformat != SND_PCM_FORMAT_NONE) {
|
||||
_snd_pcm_hw_params_set_format(sparams, rate->sformat);
|
||||
_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);
|
||||
}
|
||||
_snd_pcm_hw_param_minmax(sparams, SND_PCM_HW_PARAM_RATE,
|
||||
rate->srate, 0, rate->srate + 1, -1);
|
||||
_snd_pcm_hw_param_set_minmax(sparams, SND_PCM_HW_PARAM_RATE,
|
||||
rate->srate, 0, rate->srate + 1, -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -283,17 +280,17 @@ static int snd_pcm_rate_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p
|
|||
unsigned int links = (SND_PCM_HW_PARBIT_CHANNELS |
|
||||
SND_PCM_HW_PARBIT_PERIOD_TIME |
|
||||
SND_PCM_HW_PARBIT_TICK_TIME);
|
||||
if (rate->sformat < 0)
|
||||
if (rate->sformat == SND_PCM_FORMAT_NONE)
|
||||
links |= (SND_PCM_HW_PARBIT_FORMAT |
|
||||
SND_PCM_HW_PARBIT_SUBFORMAT |
|
||||
SND_PCM_HW_PARBIT_SAMPLE_BITS |
|
||||
SND_PCM_HW_PARBIT_FRAME_BITS);
|
||||
snd_interval_copy(&buffer_size, snd_pcm_hw_param_value_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE));
|
||||
snd_interval_copy(&buffer_size, snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE));
|
||||
snd_interval_unfloor(&buffer_size);
|
||||
crate = snd_pcm_hw_param_value_interval(params, SND_PCM_HW_PARAM_RATE);
|
||||
srate = snd_pcm_hw_param_value_interval(sparams, SND_PCM_HW_PARAM_RATE);
|
||||
crate = snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE);
|
||||
srate = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE);
|
||||
snd_interval_muldiv(&buffer_size, srate, crate, &t);
|
||||
err = _snd_pcm_hw_param_refine_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE, &t);
|
||||
err = _snd_pcm_hw_param_set_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE, &t);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_params_refine(sparams, links, params);
|
||||
|
|
@ -313,17 +310,17 @@ static int snd_pcm_rate_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p
|
|||
unsigned int links = (SND_PCM_HW_PARBIT_CHANNELS |
|
||||
SND_PCM_HW_PARBIT_PERIOD_TIME |
|
||||
SND_PCM_HW_PARBIT_TICK_TIME);
|
||||
if (rate->sformat < 0)
|
||||
if (rate->sformat == SND_PCM_FORMAT_NONE)
|
||||
links |= (SND_PCM_HW_PARBIT_FORMAT |
|
||||
SND_PCM_HW_PARBIT_SUBFORMAT |
|
||||
SND_PCM_HW_PARBIT_SAMPLE_BITS |
|
||||
SND_PCM_HW_PARBIT_FRAME_BITS);
|
||||
sbuffer_size = snd_pcm_hw_param_value_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE);
|
||||
crate = snd_pcm_hw_param_value_interval(params, SND_PCM_HW_PARAM_RATE);
|
||||
srate = snd_pcm_hw_param_value_interval(sparams, SND_PCM_HW_PARAM_RATE);
|
||||
sbuffer_size = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE);
|
||||
crate = snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE);
|
||||
srate = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE);
|
||||
snd_interval_muldiv(sbuffer_size, crate, srate, &t);
|
||||
snd_interval_floor(&t);
|
||||
err = _snd_pcm_hw_param_refine_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE, &t);
|
||||
err = _snd_pcm_hw_param_set_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE, &t);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_params_refine(params, links, sparams);
|
||||
|
|
@ -347,7 +344,7 @@ static int snd_pcm_rate_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
|||
{
|
||||
snd_pcm_rate_t *rate = pcm->private;
|
||||
snd_pcm_t *slave = rate->plug.slave;
|
||||
unsigned int src_format, dst_format;
|
||||
snd_pcm_format_t src_format, dst_format;
|
||||
unsigned int src_rate, dst_rate;
|
||||
int err = snd_pcm_hw_params_slave(pcm, params,
|
||||
snd_pcm_rate_hw_refine_cchange,
|
||||
|
|
@ -358,15 +355,15 @@ static int snd_pcm_rate_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
|||
return err;
|
||||
|
||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||
src_format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0);
|
||||
src_format = snd_pcm_hw_params_get_format(params);
|
||||
dst_format = slave->format;
|
||||
src_rate = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_RATE, 0);
|
||||
src_rate = snd_pcm_hw_params_get_rate(params, 0);
|
||||
dst_rate = slave->rate;
|
||||
} else {
|
||||
src_format = slave->format;
|
||||
dst_format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0);
|
||||
dst_format = snd_pcm_hw_params_get_format(params);
|
||||
src_rate = slave->rate;
|
||||
dst_rate = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_RATE, 0);
|
||||
dst_rate = snd_pcm_hw_params_get_rate(params, 0);
|
||||
}
|
||||
rate->get_idx = snd_pcm_linear_get_index(src_format, SND_PCM_FORMAT_S16);
|
||||
rate->put_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, dst_format);
|
||||
|
|
@ -379,7 +376,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;
|
||||
assert(!rate->states);
|
||||
rate->states = malloc(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_CHANNELS, 0) * sizeof(*rate->states));
|
||||
rate->states = malloc(snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_CHANNELS, 0) * sizeof(*rate->states));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -548,7 +545,7 @@ snd_pcm_sframes_t snd_pcm_rate_slave_frames(snd_pcm_t *pcm, snd_pcm_sframes_t fr
|
|||
static void snd_pcm_rate_dump(snd_pcm_t *pcm, snd_output_t *out)
|
||||
{
|
||||
snd_pcm_rate_t *rate = pcm->private;
|
||||
if (rate->sformat < 0)
|
||||
if (rate->sformat == SND_PCM_FORMAT_NONE)
|
||||
snd_output_printf(out, "Rate conversion PCM (%d)\n",
|
||||
rate->srate);
|
||||
else
|
||||
|
|
@ -578,12 +575,13 @@ snd_pcm_ops_t snd_pcm_rate_ops = {
|
|||
munmap: snd_pcm_plugin_munmap,
|
||||
};
|
||||
|
||||
int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, int sformat, int srate, snd_pcm_t *slave, int close_slave)
|
||||
int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, int srate, snd_pcm_t *slave, int close_slave)
|
||||
{
|
||||
snd_pcm_t *pcm;
|
||||
snd_pcm_rate_t *rate;
|
||||
assert(pcmp && slave);
|
||||
if (sformat >= 0 && snd_pcm_format_linear(sformat) != 1)
|
||||
if (sformat != SND_PCM_FORMAT_NONE &&
|
||||
snd_pcm_format_linear(sformat) != 1)
|
||||
return -EINVAL;
|
||||
rate = calloc(1, sizeof(snd_pcm_rate_t));
|
||||
if (!rate) {
|
||||
|
|
@ -624,13 +622,13 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, int sformat, int srate, snd_
|
|||
|
||||
int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name,
|
||||
snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i;
|
||||
char *sname = NULL;
|
||||
int err;
|
||||
snd_pcm_t *spcm;
|
||||
int sformat = -1;
|
||||
snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE;
|
||||
long srate = -1;
|
||||
snd_config_foreach(i, conf) {
|
||||
snd_config_t *n = snd_config_entry(i);
|
||||
|
|
@ -656,7 +654,7 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name,
|
|||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat < 0) {
|
||||
if (sformat == SND_PCM_FORMAT_NONE) {
|
||||
ERR("Unknown sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ typedef struct {
|
|||
int put_idx;
|
||||
int conv_idx;
|
||||
int src_size;
|
||||
int dst_sfmt;
|
||||
snd_pcm_format_t dst_sfmt;
|
||||
unsigned int ndsts;
|
||||
snd_pcm_route_ttable_dst_t *dsts;
|
||||
} snd_pcm_route_params_t;
|
||||
|
|
@ -81,7 +81,7 @@ typedef union {
|
|||
typedef struct {
|
||||
/* This field need to be the first */
|
||||
snd_pcm_plugin_t plug;
|
||||
int sformat;
|
||||
snd_pcm_format_t sformat;
|
||||
int schannels;
|
||||
snd_pcm_route_params_t params;
|
||||
} snd_pcm_route_t;
|
||||
|
|
@ -438,23 +438,22 @@ static int snd_pcm_route_close(snd_pcm_t *pcm)
|
|||
static int snd_pcm_route_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params)
|
||||
{
|
||||
int err;
|
||||
snd_mask_t *access_mask = alloca(snd_mask_sizeof());
|
||||
snd_mask_t *format_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof());
|
||||
snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
|
||||
snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
format_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||
SND_PCM_SUBFORMAT_STD, 0);
|
||||
err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = _snd_pcm_hw_param_min(params, SND_PCM_HW_PARAM_CHANNELS, 1, 0);
|
||||
err = _snd_pcm_hw_param_set_min(params, SND_PCM_HW_PARAM_CHANNELS, 1, 0);
|
||||
if (err < 0)
|
||||
return err;
|
||||
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
|
||||
|
|
@ -464,16 +463,14 @@ static int snd_pcm_route_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd
|
|||
static int snd_pcm_route_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
|
||||
{
|
||||
snd_pcm_route_t *route = pcm->private;
|
||||
snd_mask_t *saccess_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||
_snd_pcm_hw_params_any(sparams);
|
||||
_snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
saccess_mask);
|
||||
if (route->sformat >= 0) {
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_FORMAT,
|
||||
route->sformat, 0);
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||
SND_PCM_SUBFORMAT_STD, 0);
|
||||
if (route->sformat != SND_PCM_FORMAT_NONE) {
|
||||
_snd_pcm_hw_params_set_format(sparams, route->sformat);
|
||||
_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);
|
||||
}
|
||||
if (route->schannels >= 0) {
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_CHANNELS,
|
||||
|
|
@ -494,7 +491,7 @@ static int snd_pcm_route_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *
|
|||
SND_PCM_HW_PARBIT_BUFFER_SIZE |
|
||||
SND_PCM_HW_PARBIT_BUFFER_TIME |
|
||||
SND_PCM_HW_PARBIT_TICK_TIME);
|
||||
if (route->sformat < 0)
|
||||
if (route->sformat == SND_PCM_FORMAT_NONE)
|
||||
links |= (SND_PCM_HW_PARBIT_FORMAT |
|
||||
SND_PCM_HW_PARBIT_SUBFORMAT |
|
||||
SND_PCM_HW_PARBIT_SAMPLE_BITS);
|
||||
|
|
@ -518,7 +515,7 @@ static int snd_pcm_route_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t *
|
|||
SND_PCM_HW_PARBIT_BUFFER_SIZE |
|
||||
SND_PCM_HW_PARBIT_BUFFER_TIME |
|
||||
SND_PCM_HW_PARBIT_TICK_TIME);
|
||||
if (route->sformat < 0)
|
||||
if (route->sformat == SND_PCM_FORMAT_NONE)
|
||||
links |= (SND_PCM_HW_PARBIT_FORMAT |
|
||||
SND_PCM_HW_PARBIT_SUBFORMAT |
|
||||
SND_PCM_HW_PARBIT_SAMPLE_BITS);
|
||||
|
|
@ -544,7 +541,7 @@ static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
|||
{
|
||||
snd_pcm_route_t *route = pcm->private;
|
||||
snd_pcm_t *slave = route->plug.slave;
|
||||
unsigned int src_format, dst_format;
|
||||
snd_pcm_format_t src_format, dst_format;
|
||||
int err = snd_pcm_hw_params_slave(pcm, params,
|
||||
snd_pcm_route_hw_refine_cchange,
|
||||
snd_pcm_route_hw_refine_sprepare,
|
||||
|
|
@ -554,11 +551,11 @@ static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
|||
return err;
|
||||
|
||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||
src_format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0);
|
||||
src_format = snd_pcm_hw_params_get_format(params);
|
||||
dst_format = slave->format;
|
||||
} else {
|
||||
src_format = slave->format;
|
||||
dst_format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0);
|
||||
dst_format = snd_pcm_hw_params_get_format(params);
|
||||
}
|
||||
route->params.get_idx = snd_pcm_linear_get_index(src_format, SND_PCM_FORMAT_U16);
|
||||
route->params.put_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_U32, dst_format);
|
||||
|
|
@ -648,7 +645,7 @@ static void snd_pcm_route_dump(snd_pcm_t *pcm, snd_output_t *out)
|
|||
{
|
||||
snd_pcm_route_t *route = pcm->private;
|
||||
unsigned int dst;
|
||||
if (route->sformat < 0)
|
||||
if (route->sformat == SND_PCM_FORMAT_NONE)
|
||||
snd_output_printf(out, "Route conversion PCM\n");
|
||||
else
|
||||
snd_output_printf(out, "Route conversion PCM (sformat=%s)\n",
|
||||
|
|
@ -697,7 +694,7 @@ snd_pcm_ops_t snd_pcm_route_ops = {
|
|||
munmap: snd_pcm_plugin_munmap,
|
||||
};
|
||||
|
||||
int route_load_ttable(snd_pcm_route_params_t *params, int stream,
|
||||
int route_load_ttable(snd_pcm_route_params_t *params, snd_pcm_stream_t stream,
|
||||
unsigned int tt_ssize,
|
||||
snd_pcm_route_ttable_entry_t *ttable,
|
||||
unsigned int tt_cused, unsigned int tt_sused)
|
||||
|
|
@ -770,7 +767,7 @@ int route_load_ttable(snd_pcm_route_params_t *params, int stream,
|
|||
|
||||
|
||||
int snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
|
||||
int sformat, unsigned int schannels,
|
||||
snd_pcm_format_t sformat, unsigned int schannels,
|
||||
snd_pcm_route_ttable_entry_t *ttable,
|
||||
unsigned int tt_ssize,
|
||||
unsigned int tt_cused, unsigned int tt_sused,
|
||||
|
|
@ -780,7 +777,8 @@ int snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
|
|||
snd_pcm_route_t *route;
|
||||
int err;
|
||||
assert(pcmp && slave && ttable);
|
||||
if (sformat >= 0 && snd_pcm_format_linear(sformat) != 1)
|
||||
if (sformat != SND_PCM_FORMAT_NONE &&
|
||||
snd_pcm_format_linear(sformat) != 1)
|
||||
return -EINVAL;
|
||||
route = calloc(1, sizeof(snd_pcm_route_t));
|
||||
if (!route) {
|
||||
|
|
@ -885,13 +883,13 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt
|
|||
|
||||
int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
|
||||
snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i;
|
||||
char *sname = NULL;
|
||||
int err;
|
||||
snd_pcm_t *spcm;
|
||||
int sformat = -1;
|
||||
snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE;
|
||||
long schannels = -1;
|
||||
snd_config_t *tt = NULL;
|
||||
snd_pcm_route_ttable_entry_t ttable[MAX_CHANNELS*MAX_CHANNELS];
|
||||
|
|
@ -920,7 +918,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
|
|||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat < 0) {
|
||||
if (sformat == SND_PCM_FORMAT_NONE) {
|
||||
ERR("Unknown sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ typedef struct {
|
|||
struct list_head clients;
|
||||
struct list_head list;
|
||||
snd_pcm_t *pcm;
|
||||
int format;
|
||||
snd_pcm_format_t format;
|
||||
int rate;
|
||||
unsigned int channels_count;
|
||||
unsigned int open_count;
|
||||
|
|
@ -100,7 +100,7 @@ typedef struct {
|
|||
pid_t async_pid;
|
||||
int drain_silenced;
|
||||
struct timeval trigger_tstamp;
|
||||
int state;
|
||||
snd_pcm_state_t state;
|
||||
snd_pcm_uframes_t hw_ptr;
|
||||
snd_pcm_uframes_t appl_ptr;
|
||||
int ready;
|
||||
|
|
@ -108,7 +108,7 @@ typedef struct {
|
|||
int slave_socket;
|
||||
} snd_pcm_share_t;
|
||||
|
||||
static void _snd_pcm_share_stop(snd_pcm_t *pcm, int state);
|
||||
static void _snd_pcm_share_stop(snd_pcm_t *pcm, snd_pcm_state_t state);
|
||||
|
||||
static snd_pcm_uframes_t snd_pcm_share_slave_avail(snd_pcm_share_slave_t *slave)
|
||||
{
|
||||
|
|
@ -142,7 +142,7 @@ static snd_pcm_uframes_t _snd_pcm_share_slave_forward(snd_pcm_share_slave_t *sla
|
|||
for (i = slave->clients.next; i != &slave->clients; i = i->next) {
|
||||
snd_pcm_share_t *share = list_entry(i, snd_pcm_share_t, list);
|
||||
snd_pcm_t *pcm = share->pcm;
|
||||
switch (share->state) {
|
||||
switch (snd_enum_to_int(share->state)) {
|
||||
case SND_PCM_STATE_RUNNING:
|
||||
break;
|
||||
case SND_PCM_STATE_DRAINING:
|
||||
|
|
@ -199,7 +199,7 @@ static snd_pcm_uframes_t _snd_pcm_share_missing(snd_pcm_t *pcm, int slave_xrun)
|
|||
snd_pcm_uframes_t missing = INT_MAX;
|
||||
snd_pcm_sframes_t ready_missing;
|
||||
// printf("state=%d hw_ptr=%d appl_ptr=%d slave appl_ptr=%d safety=%d silence=%d\n", share->state, slave->hw_ptr, share->appl_ptr, *slave->pcm->appl_ptr, slave->safety_threshold, slave->silence_frames);
|
||||
switch (share->state) {
|
||||
switch (snd_enum_to_int(share->state)) {
|
||||
case SND_PCM_STATE_RUNNING:
|
||||
break;
|
||||
case SND_PCM_STATE_DRAINING:
|
||||
|
|
@ -238,7 +238,7 @@ static snd_pcm_uframes_t _snd_pcm_share_missing(snd_pcm_t *pcm, int slave_xrun)
|
|||
missing = safety_missing;
|
||||
}
|
||||
}
|
||||
switch (share->state) {
|
||||
switch (snd_enum_to_int(share->state)) {
|
||||
case SND_PCM_STATE_DRAINING:
|
||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||
if (hw_avail <= 0) {
|
||||
|
|
@ -268,6 +268,9 @@ static snd_pcm_uframes_t _snd_pcm_share_missing(snd_pcm_t *pcm, int slave_xrun)
|
|||
}
|
||||
running = 1;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
|
||||
update_poll:
|
||||
|
|
@ -369,7 +372,7 @@ void *snd_pcm_share_slave_thread(void *data)
|
|||
avail_min += spcm->boundary;
|
||||
// printf("avail_min=%d\n", avail_min);
|
||||
if ((snd_pcm_uframes_t)avail_min != spcm->avail_min) {
|
||||
snd_pcm_sw_param_near(spcm, &slave->sw_params, SND_PCM_SW_PARAM_AVAIL_MIN, avail_min);
|
||||
snd_pcm_sw_params_set_avail_min(spcm, &slave->sw_params, avail_min);
|
||||
err = snd_pcm_sw_params(spcm, &slave->sw_params);
|
||||
assert(err >= 0);
|
||||
}
|
||||
|
|
@ -406,7 +409,6 @@ static void _snd_pcm_share_update(snd_pcm_t *pcm)
|
|||
if (missing < INT_MAX) {
|
||||
snd_pcm_uframes_t hw_ptr;
|
||||
snd_pcm_sframes_t avail_min;
|
||||
int err;
|
||||
hw_ptr = slave->hw_ptr + missing;
|
||||
hw_ptr += spcm->period_size - 1;
|
||||
if (hw_ptr >= spcm->boundary)
|
||||
|
|
@ -418,7 +420,8 @@ static void _snd_pcm_share_update(snd_pcm_t *pcm)
|
|||
if (avail_min < 0)
|
||||
avail_min += spcm->boundary;
|
||||
if ((snd_pcm_uframes_t)avail_min < spcm->avail_min) {
|
||||
snd_pcm_sw_param_near(spcm, &slave->sw_params, SND_PCM_SW_PARAM_AVAIL_MIN, avail_min);
|
||||
int err;
|
||||
snd_pcm_sw_params_set_avail_min(spcm, &slave->sw_params, avail_min);
|
||||
err = snd_pcm_sw_params(spcm, &slave->sw_params);
|
||||
assert(err >= 0);
|
||||
}
|
||||
|
|
@ -454,11 +457,11 @@ static int snd_pcm_share_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
|
|||
{
|
||||
snd_pcm_share_t *share = pcm->private;
|
||||
snd_pcm_share_slave_t *slave = share->slave;
|
||||
snd_mask_t *access_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
int err;
|
||||
snd_mask_any(access_mask);
|
||||
snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
snd_pcm_access_mask_any(access_mask);
|
||||
snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -466,9 +469,8 @@ static int snd_pcm_share_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
|
|||
share->channels_count, 0);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (slave->format >= 0) {
|
||||
err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
slave->format, 0);
|
||||
if (slave->format != SND_PCM_FORMAT_NONE) {
|
||||
err = _snd_pcm_hw_params_set_format(params, slave->format);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
|
|
@ -487,10 +489,10 @@ static int snd_pcm_share_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
|
|||
{
|
||||
snd_pcm_share_t *share = pcm->private;
|
||||
snd_pcm_share_slave_t *slave = share->slave;
|
||||
snd_mask_t *saccess_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||
_snd_pcm_hw_params_any(sparams);
|
||||
_snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
saccess_mask);
|
||||
_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_CHANNELS,
|
||||
slave->channels_count, 0);
|
||||
|
|
@ -510,14 +512,14 @@ static int snd_pcm_share_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_
|
|||
SND_PCM_HW_PARBIT_BUFFER_TIME |
|
||||
SND_PCM_HW_PARBIT_PERIODS |
|
||||
SND_PCM_HW_PARBIT_TICK_TIME);
|
||||
const snd_mask_t *access_mask = snd_pcm_hw_param_value_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
||||
if (!snd_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) &&
|
||||
!snd_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED) &&
|
||||
!snd_mask_test(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) {
|
||||
snd_mask_t *saccess_mask = alloca(snd_mask_sizeof());
|
||||
snd_mask_any(saccess_mask);
|
||||
snd_mask_reset(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
|
||||
err = _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
const snd_pcm_access_mask_t *access_mask = snd_pcm_hw_param_get_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
||||
if (!snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) &&
|
||||
!snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED) &&
|
||||
!snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) {
|
||||
snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_pcm_access_mask_any(saccess_mask);
|
||||
snd_pcm_access_mask_reset(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
|
||||
err = _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
saccess_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -541,16 +543,16 @@ static int snd_pcm_share_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_
|
|||
SND_PCM_HW_PARBIT_BUFFER_TIME |
|
||||
SND_PCM_HW_PARBIT_PERIODS |
|
||||
SND_PCM_HW_PARBIT_TICK_TIME);
|
||||
snd_mask_t *access_mask = alloca(snd_mask_sizeof());
|
||||
const snd_mask_t *saccess_mask = snd_pcm_hw_param_value_mask(sparams, SND_PCM_HW_PARAM_ACCESS);
|
||||
snd_mask_any(access_mask);
|
||||
snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
|
||||
if (!snd_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED))
|
||||
snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
|
||||
if (!snd_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_COMPLEX) &&
|
||||
!snd_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED))
|
||||
snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_COMPLEX);
|
||||
err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
const snd_pcm_access_mask_t *saccess_mask = snd_pcm_hw_param_get_mask(sparams, SND_PCM_HW_PARAM_ACCESS);
|
||||
snd_pcm_access_mask_any(access_mask);
|
||||
snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
|
||||
if (!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED))
|
||||
snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
|
||||
if (!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_COMPLEX) &&
|
||||
!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED))
|
||||
snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_COMPLEX);
|
||||
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -591,12 +593,10 @@ static int snd_pcm_share_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
|||
Pthread_mutex_lock(&slave->mutex);
|
||||
if (slave->setup_count > 1 ||
|
||||
(slave->setup_count == 1 && !pcm->setup)) {
|
||||
err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_FORMAT,
|
||||
spcm->format, 0);
|
||||
err = _snd_pcm_hw_params_set_format(params, spcm->format);
|
||||
if (err < 0)
|
||||
goto _err;
|
||||
err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT,
|
||||
spcm->subformat, 0);
|
||||
err = _snd_pcm_hw_params_set_subformat(params, spcm->subformat);
|
||||
if (err < 0)
|
||||
goto _err;
|
||||
err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_RATE,
|
||||
|
|
@ -686,14 +686,14 @@ static int snd_pcm_share_status(snd_pcm_t *pcm, snd_pcm_status_t *status)
|
|||
goto _end;
|
||||
_notrunning:
|
||||
status->delay = sd + d;
|
||||
status->state = share->state;
|
||||
status->state = snd_enum_to_int(share->state);
|
||||
status->trigger_tstamp = share->trigger_tstamp;
|
||||
_end:
|
||||
Pthread_mutex_unlock(&slave->mutex);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int snd_pcm_share_state(snd_pcm_t *pcm)
|
||||
static snd_pcm_state_t snd_pcm_share_state(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_share_t *share = pcm->private;
|
||||
return share->state;
|
||||
|
|
@ -705,7 +705,7 @@ static int _snd_pcm_share_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
|
|||
snd_pcm_share_slave_t *slave = share->slave;
|
||||
int err = 0;
|
||||
snd_pcm_sframes_t sd;
|
||||
switch (share->state) {
|
||||
switch (snd_enum_to_int(share->state)) {
|
||||
case SND_PCM_STATE_XRUN:
|
||||
return -EPIPE;
|
||||
case SND_PCM_STATE_RUNNING:
|
||||
|
|
@ -915,7 +915,7 @@ static snd_pcm_sframes_t _snd_pcm_share_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t
|
|||
snd_pcm_share_t *share = pcm->private;
|
||||
snd_pcm_share_slave_t *slave = share->slave;
|
||||
snd_pcm_sframes_t n;
|
||||
switch (share->state) {
|
||||
switch (snd_enum_to_int(share->state)) {
|
||||
case SND_PCM_STATE_RUNNING:
|
||||
break;
|
||||
case SND_PCM_STATE_PREPARED:
|
||||
|
|
@ -962,7 +962,7 @@ static snd_pcm_sframes_t snd_pcm_share_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t
|
|||
}
|
||||
|
||||
/* 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, snd_pcm_state_t state)
|
||||
{
|
||||
snd_pcm_share_t *share = pcm->private;
|
||||
snd_pcm_share_slave_t *slave = share->slave;
|
||||
|
|
@ -1001,7 +1001,7 @@ static int snd_pcm_share_drain(snd_pcm_t *pcm)
|
|||
snd_pcm_share_slave_t *slave = share->slave;
|
||||
int err = 0;
|
||||
Pthread_mutex_lock(&slave->mutex);
|
||||
switch (share->state) {
|
||||
switch (snd_enum_to_int(share->state)) {
|
||||
case SND_PCM_STATE_OPEN:
|
||||
err = -EBADFD;
|
||||
goto _end;
|
||||
|
|
@ -1010,9 +1010,11 @@ static int snd_pcm_share_drain(snd_pcm_t *pcm)
|
|||
goto _end;
|
||||
case SND_PCM_STATE_SETUP:
|
||||
goto _end;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||
switch (share->state) {
|
||||
switch (snd_enum_to_int(share->state)) {
|
||||
case SND_PCM_STATE_XRUN:
|
||||
share->state = SND_PCM_STATE_SETUP;
|
||||
goto _end;
|
||||
|
|
@ -1024,9 +1026,12 @@ static int snd_pcm_share_drain(snd_pcm_t *pcm)
|
|||
if (!(pcm->mode & SND_PCM_NONBLOCK))
|
||||
snd_pcm_wait(pcm, -1);
|
||||
return 0;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (share->state) {
|
||||
switch (snd_enum_to_int(share->state)) {
|
||||
case SND_PCM_STATE_RUNNING:
|
||||
_snd_pcm_share_stop(pcm, SND_PCM_STATE_DRAINING);
|
||||
_snd_pcm_share_update(pcm);
|
||||
|
|
@ -1038,6 +1043,9 @@ static int snd_pcm_share_drain(snd_pcm_t *pcm)
|
|||
else
|
||||
share->state = SND_PCM_STATE_DRAINING;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
_end:
|
||||
|
|
@ -1051,7 +1059,7 @@ static int snd_pcm_share_drop(snd_pcm_t *pcm)
|
|||
snd_pcm_share_slave_t *slave = share->slave;
|
||||
int err = 0;
|
||||
Pthread_mutex_lock(&slave->mutex);
|
||||
switch (share->state) {
|
||||
switch (snd_enum_to_int(share->state)) {
|
||||
case SND_PCM_STATE_OPEN:
|
||||
err = -EBADFD;
|
||||
goto _end;
|
||||
|
|
@ -1071,6 +1079,9 @@ static int snd_pcm_share_drop(snd_pcm_t *pcm)
|
|||
case SND_PCM_STATE_XRUN:
|
||||
share->state = SND_PCM_STATE_SETUP;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
|
||||
share->appl_ptr = share->hw_ptr = 0;
|
||||
|
|
@ -1172,10 +1183,10 @@ snd_pcm_fast_ops_t snd_pcm_share_fast_ops = {
|
|||
};
|
||||
|
||||
int snd_pcm_share_open(snd_pcm_t **pcmp, char *name, char *sname,
|
||||
int sformat, int srate,
|
||||
snd_pcm_format_t sformat, int srate,
|
||||
unsigned int schannels_count,
|
||||
unsigned int channels_count, int *channels_map,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_pcm_t *pcm;
|
||||
snd_pcm_share_t *share;
|
||||
|
|
@ -1350,7 +1361,7 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, char *name, char *sname,
|
|||
}
|
||||
|
||||
int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i;
|
||||
char *sname = NULL;
|
||||
|
|
@ -1361,7 +1372,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
|
|||
unsigned int channels_count = 0;
|
||||
long schannels_count = -1;
|
||||
unsigned int schannel_max = 0;
|
||||
int sformat = -1;
|
||||
snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE;
|
||||
long srate = -1;
|
||||
|
||||
snd_config_foreach(i, conf) {
|
||||
|
|
@ -1388,7 +1399,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
|
|||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat < 0) {
|
||||
if (sformat == SND_PCM_FORMAT_NONE) {
|
||||
ERR("Unknown format %s", f);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,10 +154,10 @@ static int snd_pcm_shm_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_p
|
|||
|
||||
static int snd_pcm_shm_hw_refine_sprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *sparams)
|
||||
{
|
||||
snd_mask_t *saccess_mask = alloca(snd_mask_sizeof());
|
||||
snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
|
||||
_snd_pcm_hw_params_any(sparams);
|
||||
_snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
saccess_mask);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -167,10 +167,10 @@ static int snd_pcm_shm_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pc
|
|||
{
|
||||
int err;
|
||||
unsigned int links = ~SND_PCM_HW_PARBIT_ACCESS;
|
||||
const snd_mask_t *access_mask = snd_pcm_hw_param_value_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
||||
if (!snd_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) &&
|
||||
!snd_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED)) {
|
||||
err = _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
const snd_pcm_access_mask_t *access_mask = snd_pcm_hw_param_get_mask(params, SND_PCM_HW_PARAM_ACCESS);
|
||||
if (!snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) &&
|
||||
!snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED)) {
|
||||
err = _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -186,11 +186,11 @@ static int snd_pcm_shm_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pc
|
|||
{
|
||||
int err;
|
||||
unsigned int links = ~SND_PCM_HW_PARBIT_ACCESS;
|
||||
snd_mask_t *access_mask = alloca(snd_mask_sizeof());
|
||||
snd_mask_copy(access_mask, snd_pcm_hw_param_value_mask(sparams, SND_PCM_HW_PARAM_ACCESS));
|
||||
snd_mask_set(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED);
|
||||
snd_mask_set(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED);
|
||||
err = _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
|
||||
snd_mask_copy(access_mask, snd_pcm_hw_param_get_mask(sparams, SND_PCM_HW_PARAM_ACCESS));
|
||||
snd_pcm_access_mask_set(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED);
|
||||
snd_pcm_access_mask_set(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED);
|
||||
err = _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
access_mask);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -340,12 +340,12 @@ static int snd_pcm_shm_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
|||
return err;
|
||||
}
|
||||
|
||||
static int snd_pcm_shm_state(snd_pcm_t *pcm)
|
||||
static snd_pcm_state_t snd_pcm_shm_state(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_shm_t *shm = pcm->private;
|
||||
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
|
||||
ctrl->cmd = SND_PCM_IOCTL_STATE;
|
||||
return snd_pcm_shm_action(pcm);
|
||||
return snd_int_to_enum(snd_pcm_shm_action(pcm));
|
||||
}
|
||||
|
||||
static int snd_pcm_shm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
|
||||
|
|
@ -565,7 +565,7 @@ static int make_inet_socket(const char *host, int port)
|
|||
}
|
||||
#endif
|
||||
|
||||
int snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, char *socket, char *sname, int stream, int mode)
|
||||
int snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, char *socket, char *sname, snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_pcm_t *pcm;
|
||||
snd_pcm_shm_t *shm = NULL;
|
||||
|
|
@ -592,7 +592,7 @@ int snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, char *socket, char *sname, in
|
|||
memcpy(req->name, sname, snamelen);
|
||||
req->dev_type = SND_DEV_TYPE_PCM;
|
||||
req->transport_type = SND_TRANSPORT_TYPE_SHM;
|
||||
req->stream = stream;
|
||||
req->stream = snd_enum_to_int(stream);
|
||||
req->mode = mode;
|
||||
req->namelen = snamelen;
|
||||
err = write(sock, req, reqlen);
|
||||
|
|
@ -719,7 +719,7 @@ int is_local(struct hostent *hent)
|
|||
}
|
||||
|
||||
int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
|
||||
int stream, int mode)
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i;
|
||||
char *server = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue