Use O_APPEND mode with dmix & co plugins

Use O_APPEND mode (only if available) with dmix, dsnoop and dshare
plugins.  Using this mode, the plugin requires no resource server
any more.
This commit is contained in:
Takashi Iwai 2006-04-28 15:55:32 +02:00
parent 194ff97ea6
commit eafb7ae5d8
7 changed files with 190 additions and 52 deletions

View file

@ -464,8 +464,10 @@ static int snd_pcm_dshare_close(snd_pcm_t *pcm)
snd_pcm_direct_server_discard(dshare);
if (dshare->client)
snd_pcm_direct_client_discard(dshare);
snd_pcm_direct_shm_discard(dshare);
snd_pcm_direct_semaphore_up(dshare, DIRECT_IPC_SEM_CLIENT);
if (snd_pcm_direct_shm_discard(dshare))
snd_pcm_direct_semaphore_discard(dshare);
else
snd_pcm_direct_semaphore_up(dshare, DIRECT_IPC_SEM_CLIENT);
free(dshare->bindings);
pcm->private_data = NULL;
free(dshare);
@ -688,26 +690,53 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
dshare->spcm = spcm;
ret = snd_pcm_direct_server_create(dshare);
if (ret < 0) {
SNDERR("unable to create server");
goto _err;
if (dshare->shmptr->use_server) {
ret = snd_pcm_direct_server_create(dshare);
if (ret < 0) {
SNDERR("unable to create server");
goto _err;
}
}
dshare->shmptr->type = spcm->type;
} else {
/* up semaphore to avoid deadlock */
snd_pcm_direct_semaphore_up(dshare, DIRECT_IPC_SEM_CLIENT);
ret = snd_pcm_direct_client_connect(dshare);
if (ret < 0) {
SNDERR("unable to connect client");
goto _err_nosem;
}
if (dshare->shmptr->use_server) {
/* up semaphore to avoid deadlock */
snd_pcm_direct_semaphore_up(dshare, DIRECT_IPC_SEM_CLIENT);
ret = snd_pcm_direct_client_connect(dshare);
if (ret < 0) {
SNDERR("unable to connect client");
goto _err_nosem;
}
snd_pcm_direct_semaphore_down(dshare, DIRECT_IPC_SEM_CLIENT);
ret = snd_pcm_direct_open_secondary_client(&spcm, dshare, "dshare_client");
if (ret < 0)
goto _err;
snd_pcm_direct_semaphore_down(dshare, DIRECT_IPC_SEM_CLIENT);
ret = snd_pcm_direct_open_secondary_client(&spcm, dshare, "dshare_client");
if (ret < 0)
goto _err;
} else {
ret = snd_pcm_open_slave(&spcm, root, sconf, stream,
mode | SND_PCM_NONBLOCK |
SND_PCM_APPEND,
NULL);
if (ret < 0) {
SNDERR("unable to open slave");
goto _err;
}
if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) {
SNDERR("dshare plugin can be only connected to hw plugin");
ret = -EINVAL;
goto _err;
}
ret = snd_pcm_direct_initialize_secondary_slave(dshare, spcm, params);
if (ret < 0) {
SNDERR("unable to initialize slave");
goto _err;
}
}
dshare->spcm = spcm;
}