]> git.alsa-project.org Git - alsa-lib.git/commitdiff
snd_pcm_dmix_close: raise semaphore if unable to discard
authorTakashi Iwai <tiwai@suse.de>
Thu, 18 Oct 2007 09:10:35 +0000 (11:10 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 18 Oct 2007 09:10:35 +0000 (11:10 +0200)
This patch causes snd_pcm_dmix_close() to up a semaphore after downing it
if it is unable to discard it.  It prevents some deadlock that I am
getting when a couple of applications interact and one of them closes the
device and later re-opens it.

From: Mike Gorse <mgorse@mgorse.dhs.org>

src/pcm/pcm_dmix.c

index 8ecbdccef3c3f0409785b425beb071ac33b8ad65..63a98d2fd537995127ba32f0663ad26ce061f671 100644 (file)
@@ -652,9 +652,10 @@ static int snd_pcm_dmix_close(snd_pcm_t *pcm)
        if (dmix->client)
                snd_pcm_direct_client_discard(dmix);
        shm_sum_discard(dmix);
-       if (snd_pcm_direct_shm_discard(dmix))
-               snd_pcm_direct_semaphore_discard(dmix);
-       else
+       if (snd_pcm_direct_shm_discard(dmix)) {
+               if (snd_pcm_direct_semaphore_discard(dmix))
+                       snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT);
+       } else
                snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT);
        free(dmix->bindings);
        pcm->private_data = NULL;