-/* Gnome-Streamer
- * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ * 2000 Wim Taymans <wtay@chello.be>
+ *
+ * gsttrace.h: Header for tracing functions (deprecated)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
#include <glib.h>
-typedef struct _GstTrace GstTrace;
-typedef struct _GstTraceEntry GstTraceEntry;
+G_BEGIN_DECLS
-struct _GstTrace {
- /* where this trace is going */
- gchar *filename;
- int fd;
+/**
+ * GstAllocTraceFlags:
+ * @GST_ALLOC_TRACE_NONE: No tracing specified or desired. Since 0.10.36.
+ * @GST_ALLOC_TRACE_LIVE: Trace number of non-freed memory.
+ * @GST_ALLOC_TRACE_MEM_LIVE: Trace pointers of unfreed memory.
+ *
+ * Flags indicating which tracing feature to enable.
+ */
+typedef enum {
+ GST_ALLOC_TRACE_NONE = 0,
+ GST_ALLOC_TRACE_LIVE = (1 << 0),
+ GST_ALLOC_TRACE_MEM_LIVE = (1 << 1)
+} GstAllocTraceFlags;
- /* current buffer, size, head offset */
- GstTraceEntry *buf;
- gint bufsize;
- gint bufoffset;
-};
+typedef struct _GstAllocTrace GstAllocTrace;
+
+/**
+ * GstAllocTrace:
+ * @name: The name of the tracing object
+ * @flags: Flags for this object
+ * @offset: offset of the GType
+ * @live: counter for live memory
+ * @mem_live: list with pointers to unfreed memory
+ *
+ * The main tracing object
+ */
+struct _GstAllocTrace {
+ gchar *name;
+ gint flags;
-struct _GstTraceEntry {
- guint64 timestamp;
- guint32 sequence;
- guint32 data;
- gchar message[112];
+ goffset offset;
+ gint live;
+ GSList *mem_live;
};
-GstTrace* gst_trace_new (guchar *filename, gint size);
+#ifndef GST_DISABLE_TRACE
+
+GST_EXPORT GMutex _gst_trace_mutex;
+
+void _priv_gst_alloc_trace_initialize (void);
+void _priv_gst_alloc_trace_deinit (void);
+GstAllocTrace* _priv_gst_alloc_trace_register (const gchar *name, goffset offset);
+
+void _priv_gst_alloc_trace_dump (void);
-void gst_trace_destroy (GstTrace *trace);
-void gst_trace_flush (GstTrace *trace);
-#define gst_trace_get_size(trace) ((trace)->bufsize)
-#define gst_trace_get_offset(trace) ((trace)->bufoffset)
-#define gst_trace_get_remaining(trace) ((trace)->bufsize - (trace)->bufoffset)
-void gst_trace_set_default (GstTrace *trace);
+#ifndef GST_DISABLE_ALLOC_TRACE
+/**
+ * gst_alloc_trace_register:
+ * @name: The name of the tracer object
+ *
+ * Register a new alloc tracer with the given name
+ */
+#define _gst_alloc_trace_register(name,offset) _priv_gst_alloc_trace_register (name,offset)
-void _gst_trace_add_entry (GstTrace *trace, guint32 seq,
- guint32 data, gchar *msg);
+#define _gst_alloc_trace_dump _priv_gst_alloc_trace_dump
-void gst_trace_read_tsc (guint64 *dst);
+/**
+ * gst_alloc_trace_new:
+ * @trace: The tracer to use
+ * @mem: The memory allocated
+ *
+ * Use the tracer to trace a new memory allocation
+ */
+#define _gst_alloc_trace_new(trace, mem) \
+G_STMT_START { \
+ if (G_UNLIKELY ((trace)->flags)) { \
+ g_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_mutex_unlock (&_gst_trace_mutex); \
+ } \
+} G_STMT_END
-#define TRACE_ENABLE
+/**
+ * gst_alloc_trace_free:
+ * @trace: The tracer to use
+ * @mem: The memory that is freed
+ *
+ * Trace a memory free operation
+ */
+#define _gst_alloc_trace_free(trace, mem) \
+G_STMT_START { \
+ if (G_UNLIKELY ((trace)->flags)) { \
+ g_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_mutex_unlock (&_gst_trace_mutex); \
+ } \
+} G_STMT_END
-#ifdef TRACE_ENABLE
-extern gint _gst_trace_on;
-#define gst_trace_add_entry(trace,seq,data,msg) \
- if (_gst_trace_on) { \
- _gst_trace_add_entry(trace,(guint32)seq,(guint32)data,msg); \
- }
#else
-#define gst_trace_add_entry(trace,seq,data,msg)
+#define _gst_alloc_trace_register(name) (NULL)
+#define _gst_alloc_trace_new(trace, mem)
+#define _gst_alloc_trace_free(trace, mem)
+#define _gst_alloc_trace_dump()
#endif
+#else /* GST_DISABLE_TRACE */
+
+#define _gst_alloc_trace_register(name, offset) (NULL)
+#define _gst_alloc_trace_new(trace, mem)
+#define _gst_alloc_trace_free(trace, mem)
+#define _gst_alloc_trace_dump()
+
+#endif /* GST_DISABLE_TRACE */
+
+G_END_DECLS
+
#endif /* __GST_TRACE_H__ */