2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
2005-09-07 13:22:16 +00:00
|
|
|
* gsttrace.h: Header for tracing functions (deprecated)
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __GST_TRACE_H__
|
|
|
|
#define __GST_TRACE_H__
|
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#include <glib.h>
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
G_BEGIN_DECLS
|
2000-12-28 22:12:02 +00:00
|
|
|
|
2006-07-18 09:42:31 +00:00
|
|
|
/**
|
|
|
|
* GstAllocTraceFlags:
|
2011-08-26 12:09:47 +00:00
|
|
|
* @GST_ALLOC_TRACE_NONE: No tracing specified or desired. Since 0.10.36.
|
2011-08-25 20:05:26 +00:00
|
|
|
* @GST_ALLOC_TRACE_LIVE: Trace number of non-freed memory.
|
|
|
|
* @GST_ALLOC_TRACE_MEM_LIVE: Trace pointers of unfreed memory.
|
2006-07-18 09:42:31 +00:00
|
|
|
*
|
|
|
|
* Flags indicating which tracing feature to enable.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
2011-08-25 20:05:26 +00:00
|
|
|
GST_ALLOC_TRACE_NONE = 0,
|
|
|
|
GST_ALLOC_TRACE_LIVE = (1 << 0),
|
2006-07-18 09:42:31 +00:00
|
|
|
GST_ALLOC_TRACE_MEM_LIVE = (1 << 1)
|
|
|
|
} GstAllocTraceFlags;
|
|
|
|
|
|
|
|
typedef struct _GstAllocTrace GstAllocTrace;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstAllocTrace:
|
|
|
|
* @name: The name of the tracing object
|
|
|
|
* @flags: Flags for this object
|
|
|
|
* @live: counter for live memory
|
|
|
|
* @mem_live: list with pointers to unfreed memory
|
|
|
|
*
|
|
|
|
* The main tracing object
|
|
|
|
*/
|
|
|
|
struct _GstAllocTrace {
|
|
|
|
gchar *name;
|
|
|
|
gint flags;
|
|
|
|
|
|
|
|
gint live;
|
|
|
|
GSList *mem_live;
|
|
|
|
};
|
|
|
|
|
2004-04-05 19:02:39 +00:00
|
|
|
#ifndef GST_DISABLE_TRACE
|
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
typedef struct _GstTrace GstTrace;
|
|
|
|
typedef struct _GstTraceEntry GstTraceEntry;
|
|
|
|
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
|
|
|
* GstTrace:
|
|
|
|
*
|
|
|
|
* Opaque #GstTrace structure.
|
|
|
|
*/
|
2004-03-15 14:43:35 +00:00
|
|
|
struct _GstTrace {
|
2005-11-24 09:44:07 +00:00
|
|
|
/*< private >*/
|
2000-01-30 09:03:00 +00:00
|
|
|
/* where this trace is going */
|
|
|
|
gchar *filename;
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
/* current buffer, size, head offset */
|
|
|
|
GstTraceEntry *buf;
|
|
|
|
gint bufsize;
|
|
|
|
gint bufoffset;
|
|
|
|
};
|
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
struct _GstTraceEntry {
|
2001-08-22 21:45:25 +00:00
|
|
|
gint64 timestamp;
|
2000-01-30 09:03:00 +00:00
|
|
|
guint32 sequence;
|
|
|
|
guint32 data;
|
|
|
|
gchar message[112];
|
|
|
|
};
|
|
|
|
|
2010-03-03 10:45:38 +00:00
|
|
|
GstTrace* gst_trace_new (const gchar *filename, gint size);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
void gst_trace_destroy (GstTrace *trace);
|
|
|
|
void gst_trace_flush (GstTrace *trace);
|
|
|
|
void gst_trace_text_flush (GstTrace *trace);
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
|
|
|
* gst_trace_get_size:
|
|
|
|
* @trace: a #GstTrace
|
|
|
|
*
|
|
|
|
* Retrieve the buffer size of @trace.
|
|
|
|
*/
|
2000-11-04 18:54:07 +00:00
|
|
|
#define gst_trace_get_size(trace) ((trace)->bufsize)
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
|
|
|
* gst_trace_get_offset:
|
|
|
|
* @trace: a #GstTrace
|
|
|
|
*
|
|
|
|
* Retrieve the current buffer offset of @trace.
|
|
|
|
*/
|
2000-11-04 18:54:07 +00:00
|
|
|
#define gst_trace_get_offset(trace) ((trace)->bufoffset)
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
|
|
|
* gst_trace_get_remaining:
|
|
|
|
* @trace: a #GstTrace
|
|
|
|
*
|
|
|
|
* Retrieve the remaining size in the @trace buffer.
|
|
|
|
*/
|
2000-11-04 18:54:07 +00:00
|
|
|
#define gst_trace_get_remaining(trace) ((trace)->bufsize - (trace)->bufoffset)
|
2004-03-15 14:43:35 +00:00
|
|
|
void gst_trace_set_default (GstTrace *trace);
|
2000-11-04 18:54:07 +00:00
|
|
|
|
2005-10-15 15:30:24 +00:00
|
|
|
void _gst_trace_add_entry (GstTrace *trace, guint32 seq,
|
2004-03-15 14:43:35 +00:00
|
|
|
guint32 data, gchar *msg);
|
2000-11-04 18:54:07 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
void gst_trace_read_tsc (gint64 *dst);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
|
2009-06-23 11:44:50 +00:00
|
|
|
extern GStaticMutex _gst_trace_mutex;
|
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
gboolean gst_alloc_trace_available (void);
|
2011-06-09 16:13:35 +00:00
|
|
|
const GList* gst_alloc_trace_list (void);
|
2004-03-15 14:43:35 +00:00
|
|
|
GstAllocTrace* _gst_alloc_trace_register (const gchar *name);
|
2003-02-02 19:10:44 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
int gst_alloc_trace_live_all (void);
|
|
|
|
void gst_alloc_trace_print_all (void);
|
gst/base/gsttypefindhelper.c (gst_type_find_helper): Unref any remaining buffer.
Original commit message from CVS:
2005-06-27 Andy Wingo <wingo@pobox.com>
* gst/base/gsttypefindhelper.c (gst_type_find_helper): Unref any
remaining buffer.
* gst/gsttrace.c (gst_alloc_trace_list_sorted): New helper,
returns a sorted copy of the trace list.
(gst_alloc_trace_print_live): New API, only prints traces with
live objects. Sort the list.
(gst_alloc_trace_print_all): Sort the list.
(gst_alloc_trace_print): Align columns.
* gst/elements/gstttypefindelement.c:
* gst/elements/gsttee.c:
* gst/base/gstbasesrc.c:
* gst/base/gstbasesink.c:
* gst/base/gstbasetransform.c:
* gst/gstqueue.c: Adapt for pad activation changes.
* gst/gstpipeline.c (gst_pipeline_init): Unref after parenting
sched.
(gst_pipeline_dispose): Drop ref on sched.
* gst/gstpad.c (gst_pad_init): Set the default activate func.
(gst_pad_activate_default): Push mode by default.
(pre_activate_switch, post_activate_switch): New stubs, things to
do before and after switching activation modes on pads.
(gst_pad_set_active): Take a boolean and not a mode, dispatch to
the pad's activate function to choose which mode to activate.
Shortcut on deactivation and call the right function directly.
(gst_pad_activate_pull): New API, (de)activates a pad in pull
mode.
(gst_pad_activate_push): New API, same for push mode.
(gst_pad_set_activate_function)
(gst_pad_set_activatepull_function)
(gst_pad_set_activatepush_function): Setters for new API.
* gst/gstminiobject.c (gst_mini_object_new, gst_mini_object_free):
Trace all miniobjects.
(gst_mini_object_make_writable): Unref the arg if we copy, like
gst_caps_make_writable.
* gst/gstmessage.c (_gst_message_initialize): No trace init.
* gst/gstghostpad.c (gst_proxy_pad_do_activate)
(gst_proxy_pad_do_activatepull, gst_proxy_pad_do_activatepush):
Adapt for new pad API.
* gst/gstevent.c (_gst_event_initialize): Don't initialize trace.
* gst/gstelement.h:
* gst/gstelement.c (gst_element_iterate_src_pads)
(gst_element_iterate_sink_pads): New API functions.
* gst/gstelement.c (iterator_fold_with_resync): New utility,
should fold into gstiterator.c in some form.
(gst_element_pads_activate): Simplified via use of fold and
delegation of decisions to gstpad->activate.
* gst/gstbus.c (gst_bus_source_finalize): Set the bus to NULL,
help in debugging.
* gst/gstbuffer.c (_gst_buffer_initialize): Ref the buffer type
class once in init, like gstmessage. Didn't run into this issue
but it seems correct. Don't initialize a trace, gstminiobject does
that.
* check/pipelines/simple_launch_lines.c (test_stop_from_app): New
test, runs fakesrc ! fakesink, stopping on ::handoff via a message
to the bus.
(assert_live_count): New util function, uses alloc traces to check
cleanup.
* check/gst/gstghostpad.c (test_ghost_pads): More refcount checks.
To be modified when unlink drops the internal pad.
2005-06-27 18:35:05 +00:00
|
|
|
void gst_alloc_trace_print_live (void);
|
2004-03-15 14:43:35 +00:00
|
|
|
void gst_alloc_trace_set_flags_all (GstAllocTraceFlags flags);
|
2003-02-02 19:10:44 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
GstAllocTrace* gst_alloc_trace_get (const gchar *name);
|
|
|
|
void gst_alloc_trace_print (const GstAllocTrace *trace);
|
|
|
|
void gst_alloc_trace_set_flags (GstAllocTrace *trace, GstAllocTraceFlags flags);
|
2003-02-02 19:10:44 +00:00
|
|
|
|
|
|
|
|
2003-05-10 12:42:02 +00:00
|
|
|
#ifndef GST_DISABLE_ALLOC_TRACE
|
2005-09-07 13:22:16 +00:00
|
|
|
/**
|
|
|
|
* gst_alloc_trace_register:
|
|
|
|
* @name: The name of the tracer object
|
|
|
|
*
|
|
|
|
* Register a new alloc tracer with the given name
|
|
|
|
*/
|
2003-02-02 19:10:44 +00:00
|
|
|
#define gst_alloc_trace_register(name) _gst_alloc_trace_register (name);
|
2005-09-07 13:22:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_alloc_trace_new:
|
|
|
|
* @trace: The tracer to use
|
|
|
|
* @mem: The memory allocated
|
|
|
|
*
|
|
|
|
* Use the tracer to trace a new memory allocation
|
|
|
|
*/
|
2003-02-02 19:10:44 +00:00
|
|
|
#define gst_alloc_trace_new(trace, mem) \
|
|
|
|
G_STMT_START { \
|
2009-06-23 11:44:50 +00:00
|
|
|
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); \
|
|
|
|
} \
|
2003-02-02 19:10:44 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
2005-09-07 13:22:16 +00:00
|
|
|
/**
|
|
|
|
* gst_alloc_trace_free:
|
|
|
|
* @trace: The tracer to use
|
|
|
|
* @mem: The memory that is freed
|
|
|
|
*
|
|
|
|
* Trace a memory free operation
|
|
|
|
*/
|
2003-02-02 19:10:44 +00:00
|
|
|
#define gst_alloc_trace_free(trace, mem) \
|
|
|
|
G_STMT_START { \
|
2009-06-23 11:44:50 +00:00
|
|
|
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); \
|
|
|
|
} \
|
2003-02-02 19:10:44 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
#else
|
2003-05-10 12:42:02 +00:00
|
|
|
#define gst_alloc_trace_register(name) (NULL)
|
2003-02-02 19:10:44 +00:00
|
|
|
#define gst_alloc_trace_new(trace, mem)
|
|
|
|
#define gst_alloc_trace_free(trace, mem)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
extern gint _gst_trace_on;
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
|
|
|
* gst_trace_add_entry:
|
|
|
|
* @trace: a #GstTrace
|
|
|
|
* @seq: a sequence number
|
|
|
|
* @data: the data to trace
|
|
|
|
* @msg: the trace message
|
|
|
|
*
|
|
|
|
* Add an entry to @trace with sequence number @seq, @data and @msg.
|
|
|
|
* If @trace is NULL, the entry will be added to the default #GstTrace.
|
|
|
|
*/
|
2000-01-30 09:03:00 +00:00
|
|
|
#define gst_trace_add_entry(trace,seq,data,msg) \
|
|
|
|
if (_gst_trace_on) { \
|
|
|
|
_gst_trace_add_entry(trace,(guint32)seq,(guint32)data,msg); \
|
|
|
|
}
|
|
|
|
|
2001-12-15 18:15:13 +00:00
|
|
|
#else /* GST_DISABLE_TRACE */
|
2001-06-25 20:36:02 +00:00
|
|
|
|
2009-08-22 21:22:31 +00:00
|
|
|
#if defined __GNUC__ && __GNUC__ >= 3
|
2005-10-15 15:30:24 +00:00
|
|
|
#pragma GCC poison gst_trace_new
|
2001-06-25 20:36:02 +00:00
|
|
|
#pragma GCC poison gst_trace_destroy
|
|
|
|
#pragma GCC poison gst_trace_flush
|
|
|
|
#pragma GCC poison gst_trace_text_flush
|
|
|
|
#pragma GCC poison gst_trace_get_size
|
|
|
|
#pragma GCC poison gst_trace_get_offset
|
|
|
|
#pragma GCC poison gst_trace_get_remaining
|
|
|
|
#pragma GCC poison gst_trace_set_default
|
|
|
|
#pragma GCC poison _gst_trace_add_entry
|
|
|
|
#pragma GCC poison gst_trace_read_tsc
|
2004-07-03 04:59:12 +00:00
|
|
|
#endif
|
2001-06-25 20:36:02 +00:00
|
|
|
|
2006-07-18 09:42:31 +00:00
|
|
|
#define gst_alloc_trace_register(name) (NULL)
|
2005-10-15 15:30:24 +00:00
|
|
|
#define gst_alloc_trace_new(trace, mem)
|
2003-02-10 20:32:32 +00:00
|
|
|
#define gst_alloc_trace_free(trace, mem)
|
|
|
|
|
2003-05-10 12:42:02 +00:00
|
|
|
#define gst_alloc_trace_available() (FALSE)
|
|
|
|
#define gst_alloc_trace_list() (NULL)
|
|
|
|
#define _gst_alloc_trace_register(name) (NULL)
|
2005-10-15 15:30:24 +00:00
|
|
|
|
2006-07-18 09:42:31 +00:00
|
|
|
#define gst_alloc_trace_live_all() (0)
|
2005-10-15 15:30:24 +00:00
|
|
|
#define gst_alloc_trace_print_all()
|
2006-07-18 09:42:31 +00:00
|
|
|
#define gst_alloc_trace_print_live()
|
2003-02-10 20:32:32 +00:00
|
|
|
#define gst_alloc_trace_set_flags_all(flags)
|
2005-10-15 15:30:24 +00:00
|
|
|
|
2003-05-10 12:42:02 +00:00
|
|
|
#define gst_alloc_trace_get(name) (NULL)
|
2003-02-10 20:32:32 +00:00
|
|
|
#define gst_alloc_trace_print(trace)
|
|
|
|
#define gst_alloc_trace_set_flags(trace,flags)
|
|
|
|
|
2004-04-05 19:02:39 +00:00
|
|
|
#define gst_trace_add_entry(trace,seq,data,msg)
|
2003-02-10 20:32:32 +00:00
|
|
|
|
2001-12-15 18:15:13 +00:00
|
|
|
#endif /* GST_DISABLE_TRACE */
|
2001-06-25 20:36:02 +00:00
|
|
|
|
2002-07-08 19:07:30 +00:00
|
|
|
G_END_DECLS
|
2004-03-15 14:43:35 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
#endif /* __GST_TRACE_H__ */
|