patch-src_conf_c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from alpinelinux
  2. http://git.alpinelinux.org/cgit/aports/tree/main/alsa-lib/alsa-lib-portable-mutex.patch
  3. --- alsa-lib-1.0.27.2.orig/src/conf.c 2013-07-08 14:31:36.000000000 +0200
  4. +++ alsa-lib-1.0.27.2/src/conf.c 2013-10-02 14:32:15.000000000 +0200
  5. @@ -427,8 +427,8 @@ beginning:</P>
  6. #ifndef DOC_HIDDEN
  7. #ifdef HAVE_LIBPTHREAD
  8. -static pthread_mutex_t snd_config_update_mutex =
  9. - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
  10. +static pthread_mutex_t snd_config_update_mutex;
  11. +static pthread_once_t snd_config_update_mutex_once = PTHREAD_ONCE_INIT;
  12. #endif
  13. struct _snd_config {
  14. @@ -472,8 +472,19 @@ typedef struct {
  15. #ifdef HAVE_LIBPTHREAD
  16. +static void snd_config_init_mutex(void)
  17. +{
  18. + pthread_mutexattr_t attr;
  19. +
  20. + pthread_mutexattr_init(&attr);
  21. + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  22. + pthread_mutex_init(&snd_config_update_mutex, &attr);
  23. + pthread_mutexattr_destroy(&attr);
  24. +}
  25. +
  26. static inline void snd_config_lock(void)
  27. {
  28. + pthread_once(&snd_config_update_mutex_once, snd_config_init_mutex);
  29. pthread_mutex_lock(&snd_config_update_mutex);
  30. }