alsa/0014-conf.c-use-portable-way-to-initialize-recursive-mute.patch
Takashi Iwai 558ddf7e27 Accepting request 208679 from home:tiwai:branches:multimedia:libs
- Backport upstream fixes: cleanups, non-glibc build fixes, fixes
  and enhancements of pcm_file plugin, etc.
  0010-remove-unnecessary-obsolete-compat-hsearch_r.c.patch
  0011-local.h-include-sys-types.h-to-fix-issues-with-pcm.h.patch
  0012-test-chmap-Add-missing-usage-text-for-s-option.patch
  0013-include-global.h-don-t-define-timeval-and-timespec-s.patch
  0014-conf.c-use-portable-way-to-initialize-recursive-mute.patch
  0015-pcm_file-fix-SEGFAULT-if-file-option-is-missing-whil.patch
  0016-pcm_file-fixed-memory-leak.patch
  0017-pcm_file-don-t-touch-infile-on-playback-and-output-f.patch
  0018-pcm_file-document-new-argument-to-snd_pcm_file_open.patch
- Fix aborting in races at closing dmix streams (bnc#852446):
  0019-dmix-Don-t-use-assert-and-abort.patch
- Don't include modprobe.d hack for 12.2 and older distros, which
  seem broken on them

OBS-URL: https://build.opensuse.org/request/show/208679
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=143
2013-11-27 13:17:10 +00:00

64 lines
1.8 KiB
Diff

From ae035b7fe5620fcaf4f5ea33ecabcf93b8e056cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Fri, 8 Nov 2013 13:17:58 +0100
Subject: [PATCH] conf.c: use portable way to initialize recursive mutex
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP is not in POSIX, as _NP
(non-portable) suggests.
exposing such a symbol in musl libc would lock in the ABI for all
times and makes it impossible to do future changes to the under-
lying struct without hideous symbol versioning hacks.
use the portable way instead: pthread_once was designed for such
cases.
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Tested-by: John Spencer <maillist-alsa@barfooze.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
src/conf.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/conf.c b/src/conf.c
index bfed1c434cab..5ccc8e1a53e5 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -427,8 +427,8 @@ beginning:</P>
#ifndef DOC_HIDDEN
#ifdef HAVE_LIBPTHREAD
-static pthread_mutex_t snd_config_update_mutex =
- PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+static pthread_mutex_t snd_config_update_mutex;
+static pthread_once_t snd_config_update_mutex_once = PTHREAD_ONCE_INIT;
#endif
struct _snd_config {
@@ -472,8 +472,19 @@ typedef struct {
#ifdef HAVE_LIBPTHREAD
+static void snd_config_init_mutex(void)
+{
+ pthread_mutexattr_t attr;
+
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&snd_config_update_mutex, &attr);
+ pthread_mutexattr_destroy(&attr);
+}
+
static inline void snd_config_lock(void)
{
+ pthread_once(&snd_config_update_mutex_once, snd_config_init_mutex);
pthread_mutex_lock(&snd_config_update_mutex);
}
--
1.8.4.3