Fixed mmap wrt shm. Renamed pcm_client, control_client to shm. More error messages. Implemented asoundrc as documented.

This commit is contained in:
Abramo Bagnara 2000-10-14 10:31:34 +00:00
parent dcc88ffaa7
commit e5e1ca14d4
30 changed files with 1642 additions and 2555 deletions

View file

@ -259,11 +259,6 @@ static int snd_pcm_alaw_params(snd_pcm_t *pcm, snd_pcm_params_t * params)
params->fail_reason = SND_PCM_PARAMS_FAIL_INVAL;
return -EINVAL;
}
if (slave->mmap_data) {
err = snd_pcm_munmap_data(slave);
if (err < 0)
return err;
}
alaw->cformat = params->format.sfmt;
alaw->cxfer_mode = params->xfer_mode;
alaw->cmmap_shape = params->mmap_shape;
@ -274,10 +269,6 @@ static int snd_pcm_alaw_params(snd_pcm_t *pcm, snd_pcm_params_t * params)
params->format.sfmt = alaw->cformat;
params->xfer_mode = alaw->cxfer_mode;
params->mmap_shape = alaw->cmmap_shape;
if (slave->valid_setup) {
int r = snd_pcm_mmap_data(slave, NULL);
assert(r >= 0);
}
return err;
}
@ -401,7 +392,7 @@ static void snd_pcm_alaw_dump(snd_pcm_t *pcm, FILE *fp)
snd_pcm_dump(alaw->plug.slave, fp);
}
struct snd_pcm_ops snd_pcm_alaw_ops = {
snd_pcm_ops_t snd_pcm_alaw_ops = {
close: snd_pcm_plugin_close,
info: snd_pcm_plugin_info,
params_info: snd_pcm_alaw_params_info,
@ -413,20 +404,15 @@ struct snd_pcm_ops snd_pcm_alaw_ops = {
dump: snd_pcm_alaw_dump,
nonblock: snd_pcm_plugin_nonblock,
async: snd_pcm_plugin_async,
mmap_status: snd_pcm_plugin_mmap_status,
mmap_control: snd_pcm_plugin_mmap_control,
mmap_data: snd_pcm_plugin_mmap_data,
munmap_status: snd_pcm_plugin_munmap_status,
munmap_control: snd_pcm_plugin_munmap_control,
munmap_data: snd_pcm_plugin_munmap_data,
mmap: snd_pcm_plugin_mmap,
munmap: snd_pcm_plugin_munmap,
};
int snd_pcm_alaw_open(snd_pcm_t **handlep, 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)
{
snd_pcm_t *handle;
snd_pcm_t *pcm;
snd_pcm_alaw_t *alaw;
int err;
assert(handlep && slave);
assert(pcmp && slave);
if (snd_pcm_format_linear(sformat) != 1 &&
sformat != SND_PCM_SFMT_A_LAW)
return -EINVAL;
@ -440,27 +426,25 @@ int snd_pcm_alaw_open(snd_pcm_t **handlep, char *name, int sformat, snd_pcm_t *s
alaw->plug.slave = slave;
alaw->plug.close_slave = close_slave;
handle = calloc(1, sizeof(snd_pcm_t));
if (!handle) {
pcm = calloc(1, sizeof(snd_pcm_t));
if (!pcm) {
free(alaw);
return -ENOMEM;
}
if (name)
handle->name = strdup(name);
handle->type = SND_PCM_TYPE_ALAW;
handle->stream = slave->stream;
handle->ops = &snd_pcm_alaw_ops;
handle->op_arg = handle;
handle->fast_ops = &snd_pcm_plugin_fast_ops;
handle->fast_op_arg = handle;
handle->mode = slave->mode;
handle->private = alaw;
err = snd_pcm_init(handle);
if (err < 0) {
snd_pcm_close(handle);
return err;
}
*handlep = handle;
pcm->name = strdup(name);
pcm->type = SND_PCM_TYPE_ALAW;
pcm->stream = slave->stream;
pcm->mode = slave->mode;
pcm->ops = &snd_pcm_alaw_ops;
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_plugin_fast_ops;
pcm->fast_op_arg = pcm;
pcm->private = alaw;
pcm->poll_fd = slave->poll_fd;
pcm->hw_ptr = &alaw->plug.hw_ptr;
pcm->appl_ptr = &alaw->plug.appl_ptr;
*pcmp = pcm;
return 0;
}