]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/thread.h
remove soft volume from pa_sink_input_new_info since it should be handled internally...
[pulseaudio] / src / pulsecore / thread.h
index a0e331beb684821c6c250c8d05db222fa99f6c49..eabe9ba4967163e278c74e2d6e9a4effbc35e18a 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef foopulsethreadhfoo
 #define foopulsethreadhfoo
 
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
 
 #include <pulse/def.h>
 #include <pulsecore/once.h>
+#include <pulsecore/core-util.h>
 
-/* We have to include config.h here (for the __tls stuff), which sucks */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
+#ifndef PACKAGE
+#error "Please include config.h before including this file!"
 #endif
 
 typedef struct pa_thread pa_thread;
@@ -71,8 +69,17 @@ void *pa_tls_set(pa_tls *t, void *userdata);
     }                                                                   \
     static void name##_tls_destructor(void) PA_GCC_DESTRUCTOR;          \
     static void name##_tls_destructor(void) {                           \
-        if (name##_tls.tls)                                             \
-            pa_tls_free(name##_tls.tls);                                \
+        static void (*_free_cb)(void*) = free_cb;                       \
+        if (!pa_in_valgrind())                                          \
+            return;                                                     \
+        if (!name##_tls.tls)                                            \
+            return;                                                     \
+        if (_free_cb) {                                                 \
+            void *p;                                                    \
+            if ((p = pa_tls_get(name##_tls.tls)))                       \
+                _free_cb(p);                                            \
+        }                                                               \
+        pa_tls_free(name##_tls.tls);                                    \
     }                                                                   \
     static inline void* name##_tls_get(void) {                          \
         return pa_tls_get(name##_tls_obj());                            \
@@ -82,11 +89,11 @@ void *pa_tls_set(pa_tls *t, void *userdata);
     }                                                                   \
     struct __stupid_useless_struct_to_allow_trailing_semicolon
 
-#ifdef HAVE_TLS_BUILTIN
+#ifdef SUPPORT_TLS___THREAD
 /* An optimized version of the above that requires no dynamic
  * allocation if the compiler supports __thread */
 #define PA_STATIC_TLS_DECLARE_NO_FREE(name)                             \
-    static __thread void *name##_tls;                                   \
+    static __thread void *name##_tls = NULL;                            \
     static inline void* name##_tls_get(void) {                          \
         return name##_tls;                                              \
     }                                                                   \