summaryrefslogtreecommitdiff
path: root/gst/gsttrace.h
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-06-23 13:44:50 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2009-06-23 13:46:28 +0200
commit3afa91d7aaf4f26b928185a71df4190cab285f28 (patch)
tree8f77b97ab01716a418d644608147abf03ef30630 /gst/gsttrace.h
parent9993022fc4c2b51c04df333f06b5c024976dc304 (diff)
trace: use proper locking in GstTrace
Protect the allocated list of objects with a lock so that trace actually works reliably. Shortcut the alloc trace sooner when disabled.
Diffstat (limited to 'gst/gsttrace.h')
-rw-r--r--gst/gsttrace.h32
1 files changed, 20 insertions, 12 deletions
diff --git a/gst/gsttrace.h b/gst/gsttrace.h
index 45b5b07000..8ef3376f8d 100644
--- a/gst/gsttrace.h
+++ b/gst/gsttrace.h
@@ -88,8 +88,6 @@ struct _GstTraceEntry {
gchar message[112];
};
-
-
GstTrace* gst_trace_new (gchar *filename, gint size);
void gst_trace_destroy (GstTrace *trace);
@@ -124,6 +122,8 @@ void _gst_trace_add_entry (GstTrace *trace, guint32 seq,
void gst_trace_read_tsc (gint64 *dst);
+extern GStaticMutex _gst_trace_mutex;
+
gboolean gst_alloc_trace_available (void);
G_CONST_RETURN GList* gst_alloc_trace_list (void);
GstAllocTrace* _gst_alloc_trace_register (const gchar *name);
@@ -156,11 +156,15 @@ void gst_alloc_trace_set_flags (GstAllocTrace *trace, GstAllocTraceFlags flags
*/
#define gst_alloc_trace_new(trace, mem) \
G_STMT_START { \
- if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
- (trace)->live++; \
- if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
- (trace)->mem_live = \
- g_slist_prepend ((trace)->mem_live, mem); \
+ if (G_UNLIKELY ((trace)->flags)) { \
+ g_static_mutex_lock (&_gst_trace_mutex); \
+ if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
+ (trace)->live++; \
+ if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
+ (trace)->mem_live = \
+ g_slist_prepend ((trace)->mem_live, mem); \
+ g_static_mutex_unlock (&_gst_trace_mutex); \
+ } \
} G_STMT_END
/**
@@ -172,11 +176,15 @@ G_STMT_START { \
*/
#define gst_alloc_trace_free(trace, mem) \
G_STMT_START { \
- if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
- (trace)->live--; \
- if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
- (trace)->mem_live = \
- g_slist_remove ((trace)->mem_live, mem); \
+ if (G_UNLIKELY ((trace)->flags)) { \
+ g_static_mutex_lock (&_gst_trace_mutex); \
+ if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
+ (trace)->live--; \
+ if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
+ (trace)->mem_live = \
+ g_slist_remove ((trace)->mem_live, mem); \
+ g_static_mutex_unlock (&_gst_trace_mutex); \
+ } \
} G_STMT_END
#else