mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-25 07:26:29 +00:00
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.
This commit is contained in:
parent
9993022fc4
commit
3afa91d7aa
3 changed files with 23 additions and 12 deletions
|
@ -65,6 +65,8 @@
|
||||||
|
|
||||||
#include "gsttrace.h"
|
#include "gsttrace.h"
|
||||||
|
|
||||||
|
GStaticMutex _gst_trace_mutex = G_STATIC_MUTEX_INIT;
|
||||||
|
|
||||||
static
|
static
|
||||||
#ifdef __inline__
|
#ifdef __inline__
|
||||||
__inline__
|
__inline__
|
||||||
|
|
|
@ -88,8 +88,6 @@ struct _GstTraceEntry {
|
||||||
gchar message[112];
|
gchar message[112];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GstTrace* gst_trace_new (gchar *filename, gint size);
|
GstTrace* gst_trace_new (gchar *filename, gint size);
|
||||||
|
|
||||||
void gst_trace_destroy (GstTrace *trace);
|
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);
|
void gst_trace_read_tsc (gint64 *dst);
|
||||||
|
|
||||||
|
|
||||||
|
extern GStaticMutex _gst_trace_mutex;
|
||||||
|
|
||||||
gboolean gst_alloc_trace_available (void);
|
gboolean gst_alloc_trace_available (void);
|
||||||
G_CONST_RETURN GList* gst_alloc_trace_list (void);
|
G_CONST_RETURN GList* gst_alloc_trace_list (void);
|
||||||
GstAllocTrace* _gst_alloc_trace_register (const gchar *name);
|
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) \
|
#define gst_alloc_trace_new(trace, mem) \
|
||||||
G_STMT_START { \
|
G_STMT_START { \
|
||||||
if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
|
if (G_UNLIKELY ((trace)->flags)) { \
|
||||||
(trace)->live++; \
|
g_static_mutex_lock (&_gst_trace_mutex); \
|
||||||
if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
|
if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
|
||||||
(trace)->mem_live = \
|
(trace)->live++; \
|
||||||
g_slist_prepend ((trace)->mem_live, mem); \
|
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
|
} G_STMT_END
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,11 +176,15 @@ G_STMT_START { \
|
||||||
*/
|
*/
|
||||||
#define gst_alloc_trace_free(trace, mem) \
|
#define gst_alloc_trace_free(trace, mem) \
|
||||||
G_STMT_START { \
|
G_STMT_START { \
|
||||||
if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
|
if (G_UNLIKELY ((trace)->flags)) { \
|
||||||
(trace)->live--; \
|
g_static_mutex_lock (&_gst_trace_mutex); \
|
||||||
if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
|
if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
|
||||||
(trace)->mem_live = \
|
(trace)->live--; \
|
||||||
g_slist_remove ((trace)->mem_live, mem); \
|
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
|
} G_STMT_END
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -44,6 +44,7 @@ EXPORTS
|
||||||
_gst_elementclass_factory DATA
|
_gst_elementclass_factory DATA
|
||||||
_gst_plugin_register_static
|
_gst_plugin_register_static
|
||||||
_gst_trace_add_entry
|
_gst_trace_add_entry
|
||||||
|
_gst_trace_mutex DATA
|
||||||
_gst_trace_on DATA
|
_gst_trace_on DATA
|
||||||
gst_activate_mode_get_type
|
gst_activate_mode_get_type
|
||||||
gst_alloc_trace_available
|
gst_alloc_trace_available
|
||||||
|
|
Loading…
Reference in a new issue