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
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue