mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-31 22:25:35 -04: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
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue