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