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:
Abramo Bagnara 2001-02-04 17:03:17 +00:00
parent 544718f10d
commit a7561a9c7e
40 changed files with 2733 additions and 1537 deletions

View file

@ -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;
}