mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-06 13:29:59 -05:00
pcm: direct - move the direct struct init to _snd_pcm_direct_new()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
446777c67e
commit
27f4a85a95
5 changed files with 78 additions and 131 deletions
|
|
@ -999,9 +999,8 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
|
|||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_pcm_t *pcm = NULL, *spcm = NULL;
|
||||
snd_pcm_direct_t *dmix = NULL;
|
||||
snd_pcm_direct_t *dmix;
|
||||
int ret, first_instance;
|
||||
int fail_sem_loop = 10;
|
||||
|
||||
assert(pcmp);
|
||||
|
||||
|
|
@ -1010,50 +1009,11 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
dmix = calloc(1, sizeof(snd_pcm_direct_t));
|
||||
if (!dmix) {
|
||||
ret = -ENOMEM;
|
||||
goto _err_nosem;
|
||||
}
|
||||
|
||||
ret = snd_pcm_direct_parse_bindings(dmix, params, opts->bindings);
|
||||
ret = _snd_pcm_direct_new(pcmp, &dmix, SND_PCM_TYPE_DMIX, name, opts, params, stream, mode);
|
||||
if (ret < 0)
|
||||
goto _err_nosem;
|
||||
|
||||
dmix->ipc_key = opts->ipc_key;
|
||||
dmix->ipc_perm = opts->ipc_perm;
|
||||
dmix->ipc_gid = opts->ipc_gid;
|
||||
dmix->tstamp_type = opts->tstamp_type;
|
||||
dmix->semid = -1;
|
||||
dmix->shmid = -1;
|
||||
return ret;
|
||||
first_instance = ret;
|
||||
|
||||
ret = snd_pcm_new(&pcm, dmix->type = SND_PCM_TYPE_DMIX, name, stream, mode);
|
||||
if (ret < 0)
|
||||
goto _err;
|
||||
|
||||
|
||||
while (1) {
|
||||
ret = snd_pcm_direct_semaphore_create_or_connect(dmix);
|
||||
if (ret < 0) {
|
||||
SNDERR("unable to create IPC semaphore");
|
||||
goto _err_nosem;
|
||||
}
|
||||
ret = snd_pcm_direct_semaphore_down(dmix, DIRECT_IPC_SEM_CLIENT);
|
||||
if (ret < 0) {
|
||||
snd_pcm_direct_semaphore_discard(dmix);
|
||||
if (--fail_sem_loop <= 0)
|
||||
goto _err_nosem;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
first_instance = ret = snd_pcm_direct_shm_create_or_connect(dmix);
|
||||
if (ret < 0) {
|
||||
SNDERR("unable to create IPC shm instance");
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pcm->ops = &snd_pcm_dmix_ops;
|
||||
pcm->fast_ops = &snd_pcm_dmix_fast_ops;
|
||||
pcm->private_data = dmix;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue