Skip to contentSkip to conversation

snd_pcm_dmix_close: raise semaphore if unable to discard

PATCH Applied Mike Gorse 2 participants 2 messages Oct 18, 2007

lore
Share & tools
lore

Mike Gorse

author
#0 lore raw

PATCH 1/1 snd_pcm_dmix_close: raise semaphore if unable to discard

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.

--

pcm/pcm_dmix.c renamed from pcm/pcm_dmix.c.orig +5 -2
@@ -652,8 +652,11 @@
   	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);
+	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);
Applied
#1 lore raw

At Wed, 17 Oct 2007 20:55:11 -0400 (EDT),

Quoted 5 lines · Mike Gorse

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.

Thanks, applied to HG tree now.

Takashi

Quoted 24 lines

--

pcm/pcm_dmix.c renamed from pcm/pcm_dmix.c.orig +5 -2
@@ -652,8 +652,11 @@
   	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);
+	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);

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel