aboutsummaryrefslogtreecommitdiffstats
path: root/main/alsa-utils/alsa-utils_portable-mutex.patch
blob: 5def7830d70dad628687ce68814fb911f6481e8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
--- alsa-utils-1.0.27.2.org/alsaloop/pcmjob.c
+++ alsa-utils-1.0.27.2/alsaloop/pcmjob.c
@@ -62,11 +62,22 @@
 };
 #endif
 
-static pthread_mutex_t pcm_open_mutex =
-                                PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+static pthread_once_t pcm_open_mutex_once = PTHREAD_ONCE_INIT;
+static pthread_mutex_t pcm_open_mutex;
 
+static void pcm_open_init_mutex(void)
+{
+	pthread_mutexattr_t attr;
+
+	pthread_mutexattr_init(&attr);
+	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+	pthread_mutex_init(&pcm_open_mutex, &attr);
+	pthread_mutexattr_destroy(&attr);
+}
+
 static inline void pcm_open_lock(void)
 {
+	pthread_once(&pcm_open_mutex_once, pcm_open_init_mutex);
 	if (workarounds & WORKAROUND_SERIALOPEN)
 	        pthread_mutex_lock(&pcm_open_mutex);
 }