mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-31 22:25:35 -04:00
Added unlink of the communication socket name.
Added retry when the semaphore is lost (server is going down and removes the global semaphore). Now the application creates a new direct server automagically rather than the error return.
This commit is contained in:
parent
0811da2a15
commit
e03aaa1888
4 changed files with 46 additions and 28 deletions
|
|
@ -280,6 +280,7 @@ static void server_job(snd_pcm_direct_t *dmix)
|
|||
close(dmix->hw_fd);
|
||||
if (dmix->server_free)
|
||||
dmix->server_free(dmix);
|
||||
unlink(dmix->shmptr->socket_name);
|
||||
snd_pcm_direct_shm_discard(dmix);
|
||||
snd_pcm_direct_semaphore_discard(dmix);
|
||||
server_printf("DIRECT SERVER EXIT\n");
|
||||
|
|
|
|||
|
|
@ -893,6 +893,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
|
|||
snd_pcm_t *pcm = NULL, *spcm = NULL;
|
||||
snd_pcm_direct_t *dmix = NULL;
|
||||
int ret, first_instance;
|
||||
int fail_sem_loop = 10;
|
||||
|
||||
assert(pcmp);
|
||||
|
||||
|
|
@ -919,16 +920,21 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
|
|||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
first_instance = ret = snd_pcm_direct_shm_create_or_connect(dmix);
|
||||
|
|
|
|||
|
|
@ -684,6 +684,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
|
|||
snd_pcm_direct_t *dshare = NULL;
|
||||
int ret, first_instance;
|
||||
unsigned int chn;
|
||||
int fail_sem_loop = 10;
|
||||
|
||||
assert(pcmp);
|
||||
|
||||
|
|
@ -716,6 +717,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (ret < 0)
|
||||
goto _err;
|
||||
|
||||
while (1) {
|
||||
ret = snd_pcm_direct_semaphore_create_or_connect(dshare);
|
||||
if (ret < 0) {
|
||||
SNDERR("unable to create IPC semaphore");
|
||||
|
|
@ -725,7 +727,11 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
|
|||
ret = snd_pcm_direct_semaphore_down(dshare, DIRECT_IPC_SEM_CLIENT);
|
||||
if (ret < 0) {
|
||||
snd_pcm_direct_semaphore_discard(dshare);
|
||||
if (--fail_sem_loop <= 0)
|
||||
goto _err;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
first_instance = ret = snd_pcm_direct_shm_create_or_connect(dshare);
|
||||
|
|
|
|||
|
|
@ -650,7 +650,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
|
|||
{
|
||||
snd_pcm_t *pcm = NULL, *spcm = NULL;
|
||||
snd_pcm_direct_t *dsnoop = NULL;
|
||||
int ret, first_instance;
|
||||
int ret, first_instance, fail_sem_loop = 10;
|
||||
|
||||
assert(pcmp);
|
||||
|
||||
|
|
@ -677,6 +677,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (ret < 0)
|
||||
goto _err;
|
||||
|
||||
while (1) {
|
||||
ret = snd_pcm_direct_semaphore_create_or_connect(dsnoop);
|
||||
if (ret < 0) {
|
||||
SNDERR("unable to create IPC semaphore");
|
||||
|
|
@ -686,7 +687,11 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
|
|||
ret = snd_pcm_direct_semaphore_down(dsnoop, DIRECT_IPC_SEM_CLIENT);
|
||||
if (ret < 0) {
|
||||
snd_pcm_direct_semaphore_discard(dsnoop);
|
||||
if (--fail_sem_loop <= 0)
|
||||
goto _err;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
first_instance = ret = snd_pcm_direct_shm_create_or_connect(dsnoop);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue