[1/4] alsa-lib:pcm: returning semop error code for semaphore up/down failures.
diff mbox

Message ID 1484029997-11107-1-git-send-email-sutar.mounesh@gmail.com
State New
Headers show

Commit Message

sutar.mounesh@gmail.com Jan. 10, 2017, 6:33 a.m. UTC
From: Mounesh Sutar <sutar.mounesh@gmail.com>

Signed-off-by: Mounesh Sutar <sutar.mounesh@gmail.com>

Comments

Takashi Iwai Jan. 10, 2017, 8:28 a.m. UTC | #1
On Tue, 10 Jan 2017 07:33:17 +0100,
sutar.mounesh@gmail.com wrote:
> 
> From: Mounesh Sutar <sutar.mounesh@gmail.com>
> 
> Signed-off-by: Mounesh Sutar <sutar.mounesh@gmail.com>

Applied all four patches now.  Thanks!


Takashi

Patch
diff mbox

diff --git a/src/pcm/pcm_direct.h b/src/pcm/pcm_direct.h
index 91e816c..aee38c5 100644
--- a/src/pcm/pcm_direct.h
+++ b/src/pcm/pcm_direct.h
@@ -263,7 +263,10 @@  static inline int snd_pcm_direct_semaphore_down(snd_pcm_direct_t *dmix, int sem_
 {
 	struct sembuf op[2] = { { sem_num, 0, 0 }, { sem_num, 1, SEM_UNDO } };
 	int err = semop(dmix->semid, op, 2);
-	if (err == 0) dmix->locked[sem_num]++;
+	if (err == 0)
+		dmix->locked[sem_num]++;
+	else if (err == -1)
+		err = -errno;
 	return err;
 }
 
@@ -271,7 +274,10 @@  static inline int snd_pcm_direct_semaphore_up(snd_pcm_direct_t *dmix, int sem_nu
 {
 	struct sembuf op = { sem_num, -1, SEM_UNDO | IPC_NOWAIT };
 	int err = semop(dmix->semid, &op, 1);
-	if (err == 0) dmix->locked[sem_num]--;
+	if (err == 0)
+		dmix->locked[sem_num]--;
+	else if (err == -1)
+		err = -errno;
 	return err;
 }