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.c: 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.
|
|
|
|
*/
|
2005-10-15 16:01:57 +00:00
|
|
|
|
2005-09-07 13:22:16 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gsttrace
|
|
|
|
* @short_description: Tracing functionality
|
|
|
|
*
|
2005-11-18 16:04:28 +00:00
|
|
|
* Traces allows to track object allocation. They provide a instance counter per
|
|
|
|
* #GType. The counter is incremented for each object allocated and decremented
|
|
|
|
* it when it's freed.
|
|
|
|
*
|
2005-11-21 14:50:22 +00:00
|
|
|
* <example>
|
|
|
|
* <title>Tracing object instances</title>
|
|
|
|
* <programlisting>
|
|
|
|
* // trace un-freed object instances
|
|
|
|
* gst_alloc_trace_set_flags_all (GST_ALLOC_TRACE_LIVE);
|
|
|
|
* if (!gst_alloc_trace_available ()) {
|
|
|
|
* g_warning ("Trace not available (recompile with trace enabled).");
|
|
|
|
* }
|
|
|
|
* gst_alloc_trace_print_live ();
|
|
|
|
* // do something here
|
|
|
|
* gst_alloc_trace_print_live ();
|
|
|
|
* </programlisting>
|
|
|
|
* </example>
|
2005-11-18 16:04:28 +00:00
|
|
|
*
|
2005-11-21 14:50:22 +00:00
|
|
|
* Last reviewed on 2005-11-21 (0.9.5)
|
2005-09-07 13:22:16 +00:00
|
|
|
*/
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2004-04-28 23:26:06 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2000-01-30 09:03:00 +00:00
|
|
|
#include <stdio.h>
|
2004-04-28 23:26:06 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2000-01-30 09:03:00 +00:00
|
|
|
#include <unistd.h>
|
2004-04-28 23:26:06 +00:00
|
|
|
#endif
|
2000-01-30 09:03:00 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
2000-12-15 01:57:34 +00:00
|
|
|
|
2000-12-28 22:12:02 +00:00
|
|
|
#include "gst_private.h"
|
2004-05-10 18:07:24 +00:00
|
|
|
#include "gstinfo.h"
|
2000-12-28 22:12:02 +00:00
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#include "gsttrace.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static
|
2002-12-18 21:44:57 +00:00
|
|
|
#ifdef __inline__
|
2004-03-13 15:27:01 +00:00
|
|
|
__inline__
|
2002-12-18 21:44:57 +00:00
|
|
|
#endif
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
2002-12-18 21:44:57 +00:00
|
|
|
read_tsc (gint64 * dst)
|
2001-12-04 22:12:50 +00:00
|
|
|
{
|
2001-05-16 05:04:44 +00:00
|
|
|
#ifdef HAVE_RDTSC
|
|
|
|
guint64 tsc;
|
2001-12-04 22:12:50 +00:00
|
|
|
__asm__ __volatile__ ("rdtsc":"=A" (tsc));
|
|
|
|
|
2001-05-16 05:04:44 +00:00
|
|
|
*dst = tsc;
|
2000-08-18 22:15:58 +00:00
|
|
|
#else
|
2001-05-16 05:04:44 +00:00
|
|
|
*dst = 0;
|
2000-08-18 22:15:58 +00:00
|
|
|
#endif
|
2001-05-16 05:04:44 +00:00
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
|
|
|
* gst_trace_read_tsc:
|
|
|
|
* @dst: pointer to hold the result.
|
|
|
|
*
|
|
|
|
* Read a platform independent timer value that can be used in
|
|
|
|
* benchmarks.
|
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
void
|
2002-12-18 21:44:57 +00:00
|
|
|
gst_trace_read_tsc (gint64 * dst)
|
2001-12-04 22:12:50 +00:00
|
|
|
{
|
|
|
|
read_tsc (dst);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GstTrace *_gst_trace_default = NULL;
|
|
|
|
gint _gst_trace_on = 1;
|
|
|
|
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
|
|
|
* gst_trace_new:
|
|
|
|
* @filename: a filename
|
|
|
|
* @size: the max size of the file
|
|
|
|
*
|
|
|
|
* Create a ringbuffer of @size in the file with @filename to
|
|
|
|
* store trace results in.
|
|
|
|
*
|
|
|
|
* Returns: a new #GstTrace.
|
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
GstTrace *
|
2002-08-12 16:59:39 +00:00
|
|
|
gst_trace_new (gchar * filename, gint size)
|
2001-12-04 22:12:50 +00:00
|
|
|
{
|
|
|
|
GstTrace *trace = g_malloc (sizeof (GstTrace));
|
|
|
|
|
|
|
|
g_return_val_if_fail (trace != NULL, NULL);
|
|
|
|
trace->filename = g_strdup (filename);
|
2007-03-07 17:26:49 +00:00
|
|
|
GST_DEBUG ("opening '%s'", trace->filename);
|
2004-04-28 23:26:06 +00:00
|
|
|
#ifndef S_IWUSR
|
|
|
|
#define S_IWUSR S_IWRITE
|
|
|
|
#endif
|
|
|
|
#ifndef S_IRUSR
|
2004-05-07 02:36:28 +00:00
|
|
|
#define S_IRUSR S_IREAD
|
2004-04-28 23:26:06 +00:00
|
|
|
#endif
|
2004-03-13 15:27:01 +00:00
|
|
|
trace->fd =
|
|
|
|
open (trace->filename, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
2001-12-04 22:12:50 +00:00
|
|
|
perror ("opening trace file");
|
|
|
|
g_return_val_if_fail (trace->fd > 0, NULL);
|
|
|
|
trace->buf = g_malloc (size * sizeof (GstTraceEntry));
|
|
|
|
g_return_val_if_fail (trace->buf != NULL, NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
trace->bufsize = size;
|
|
|
|
trace->bufoffset = 0;
|
|
|
|
|
|
|
|
return trace;
|
|
|
|
}
|
|
|
|
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
|
|
|
* gst_trace_destroy:
|
|
|
|
* @trace: the #GstTrace to destroy
|
|
|
|
*
|
|
|
|
* Flush an close the previously allocated @trace.
|
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
void
|
|
|
|
gst_trace_destroy (GstTrace * trace)
|
|
|
|
{
|
|
|
|
g_return_if_fail (trace != NULL);
|
|
|
|
g_return_if_fail (trace->buf != NULL);
|
|
|
|
|
|
|
|
if (gst_trace_get_remaining (trace) > 0)
|
|
|
|
gst_trace_flush (trace);
|
|
|
|
close (trace->fd);
|
|
|
|
g_free (trace->buf);
|
|
|
|
g_free (trace);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
|
|
|
* gst_trace_flush:
|
|
|
|
* @trace: the #GstTrace to flush.
|
|
|
|
*
|
|
|
|
* Flush any pending trace entries in @trace to the trace file.
|
|
|
|
* @trace can be NULL in which case the default #GstTrace will be
|
|
|
|
* flushed.
|
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
void
|
|
|
|
gst_trace_flush (GstTrace * trace)
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
if (!trace) {
|
|
|
|
trace = _gst_trace_default;
|
2001-12-04 22:12:50 +00:00
|
|
|
if (!trace)
|
|
|
|
return;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2005-09-02 12:08:45 +00:00
|
|
|
g_return_if_fail (write (trace->fd, trace->buf,
|
|
|
|
trace->bufoffset * sizeof (GstTraceEntry)) != -1);
|
2000-01-30 09:03:00 +00:00
|
|
|
trace->bufoffset = 0;
|
|
|
|
}
|
|
|
|
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
|
|
|
* gst_trace_text_flush:
|
|
|
|
* @trace: the #GstTrace to flush.
|
|
|
|
*
|
|
|
|
* Flush any pending trace entries in @trace to the trace file,
|
|
|
|
* formatted as a text line with timestamp and sequence numbers.
|
|
|
|
* @trace can be NULL in which case the default #GstTrace will be
|
|
|
|
* flushed.
|
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
void
|
|
|
|
gst_trace_text_flush (GstTrace * trace)
|
|
|
|
{
|
2001-05-16 05:04:44 +00:00
|
|
|
int i;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-01-30 20:48:13 +00:00
|
|
|
#define STRSIZE (20 + 1 + 10 + 1 + 10 + 1 + 112 + 1 + 1)
|
|
|
|
char str[STRSIZE];
|
2001-05-16 05:04:44 +00:00
|
|
|
|
|
|
|
if (!trace) {
|
|
|
|
trace = _gst_trace_default;
|
2001-12-04 22:12:50 +00:00
|
|
|
if (!trace)
|
|
|
|
return;
|
2001-05-16 05:04:44 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
for (i = 0; i < trace->bufoffset; i++) {
|
2004-04-28 23:26:06 +00:00
|
|
|
g_snprintf (str, STRSIZE, "%20" G_GINT64_FORMAT " %10d %10d %s\n",
|
2004-03-15 19:27:17 +00:00
|
|
|
trace->buf[i].timestamp,
|
|
|
|
trace->buf[i].sequence, trace->buf[i].data, trace->buf[i].message);
|
2005-09-02 12:08:45 +00:00
|
|
|
g_return_if_fail (write (trace->fd, str, strlen (str)) != -1);
|
2001-05-16 05:04:44 +00:00
|
|
|
}
|
|
|
|
trace->bufoffset = 0;
|
2004-01-30 20:48:13 +00:00
|
|
|
#undef STRSIZE
|
2001-05-16 05:04:44 +00:00
|
|
|
}
|
|
|
|
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
|
|
|
* gst_trace_set_default:
|
|
|
|
* @trace: the #GstTrace to set as the default.
|
|
|
|
*
|
|
|
|
* Set the default #GstTrace to @trace.
|
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
void
|
|
|
|
gst_trace_set_default (GstTrace * trace)
|
|
|
|
{
|
|
|
|
g_return_if_fail (trace != NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
_gst_trace_default = trace;
|
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
void
|
|
|
|
_gst_trace_add_entry (GstTrace * trace, guint32 seq, guint32 data, gchar * msg)
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstTraceEntry *entry;
|
2001-12-04 22:12:50 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
if (!trace) {
|
|
|
|
trace = _gst_trace_default;
|
2001-12-04 22:12:50 +00:00
|
|
|
if (!trace)
|
|
|
|
return;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
entry = trace->buf + trace->bufoffset;
|
2001-12-04 22:12:50 +00:00
|
|
|
read_tsc (&(entry->timestamp));
|
2000-01-30 09:03:00 +00:00
|
|
|
entry->sequence = seq;
|
|
|
|
entry->data = data;
|
2001-12-04 22:12:50 +00:00
|
|
|
strncpy (entry->message, msg, 112);
|
2000-01-30 09:03:00 +00:00
|
|
|
trace->bufoffset++;
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
gst_trace_flush (trace);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2003-02-02 19:10:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* global flags */
|
|
|
|
static GstAllocTraceFlags _gst_trace_flags = 0;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-02-02 19:10:44 +00:00
|
|
|
/* list of registered tracers */
|
|
|
|
static GList *_gst_alloc_tracers = NULL;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_alloc_trace_available:
|
|
|
|
*
|
2007-01-09 15:38:58 +00:00
|
|
|
* Check if alloc tracing was compiled into the core
|
2003-02-02 19:10:44 +00:00
|
|
|
*
|
|
|
|
* Returns: TRUE if the core was compiled with alloc
|
|
|
|
* tracing enabled.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_alloc_trace_available (void)
|
|
|
|
{
|
2003-05-10 12:42:02 +00:00
|
|
|
#ifdef GST_DISABLE_ALLOC_TRACE
|
2003-02-02 19:10:44 +00:00
|
|
|
return FALSE;
|
2003-05-10 12:42:02 +00:00
|
|
|
#else
|
|
|
|
return TRUE;
|
2003-02-02 19:10:44 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _gst_alloc_trace_register:
|
|
|
|
* @name: the name of the new alloc trace object.
|
|
|
|
*
|
|
|
|
* Register an get a handle to a GstAllocTrace object that
|
|
|
|
* can be used to trace memory allocations.
|
|
|
|
*
|
|
|
|
* Returns: A handle to a GstAllocTrace.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstAllocTrace *
|
|
|
|
_gst_alloc_trace_register (const gchar * name)
|
2003-02-02 19:10:44 +00:00
|
|
|
{
|
|
|
|
GstAllocTrace *trace;
|
|
|
|
|
|
|
|
g_return_val_if_fail (name, NULL);
|
|
|
|
|
|
|
|
trace = g_new0 (GstAllocTrace, 1);
|
|
|
|
trace->name = g_strdup (name);
|
|
|
|
trace->live = 0;
|
|
|
|
trace->mem_live = NULL;
|
|
|
|
trace->flags = _gst_trace_flags;
|
|
|
|
|
|
|
|
_gst_alloc_tracers = g_list_prepend (_gst_alloc_tracers, trace);
|
|
|
|
|
|
|
|
return trace;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_alloc_trace_list:
|
|
|
|
*
|
|
|
|
* Get a list of all registered alloc trace objects.
|
|
|
|
*
|
|
|
|
* Returns: a GList of GstAllocTrace objects.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
const GList *
|
2003-02-02 19:10:44 +00:00
|
|
|
gst_alloc_trace_list (void)
|
|
|
|
{
|
|
|
|
return _gst_alloc_tracers;
|
|
|
|
}
|
|
|
|
|
2003-10-15 21:31:23 +00:00
|
|
|
/**
|
|
|
|
* gst_alloc_trace_live_all:
|
|
|
|
*
|
2005-10-20 21:08:47 +00:00
|
|
|
* Get the total number of live registered alloc trace objects.
|
|
|
|
*
|
|
|
|
* Returns: the total number of live registered alloc trace objects.
|
2003-10-15 21:31:23 +00:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
gst_alloc_trace_live_all (void)
|
|
|
|
{
|
|
|
|
GList *walk = _gst_alloc_tracers;
|
|
|
|
int num = 0;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-15 21:31:23 +00:00
|
|
|
while (walk) {
|
|
|
|
GstAllocTrace *trace = (GstAllocTrace *) walk->data;
|
|
|
|
|
|
|
|
num += trace->live;
|
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static gint
|
|
|
|
compare_func (GstAllocTrace * a, GstAllocTrace * b)
|
|
|
|
{
|
|
|
|
return strcmp (a->name, b->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
gst_alloc_trace_list_sorted (void)
|
|
|
|
{
|
|
|
|
GList *ret;
|
|
|
|
|
|
|
|
ret = g_list_sort (g_list_copy (_gst_alloc_tracers),
|
|
|
|
(GCompareFunc) compare_func);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-02-02 19:10:44 +00:00
|
|
|
/**
|
|
|
|
* gst_alloc_trace_print_all:
|
|
|
|
*
|
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
|
|
|
* Print the status of all registered alloc trace objects.
|
2003-02-02 19:10:44 +00:00
|
|
|
*/
|
|
|
|
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
|
|
|
GList *orig, *walk;
|
|
|
|
|
|
|
|
orig = walk = gst_alloc_trace_list_sorted ();
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-02-02 19:10:44 +00:00
|
|
|
while (walk) {
|
|
|
|
GstAllocTrace *trace = (GstAllocTrace *) walk->data;
|
|
|
|
|
|
|
|
gst_alloc_trace_print (trace);
|
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
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
|
|
|
|
|
|
|
g_list_free (orig);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_alloc_trace_print_live:
|
|
|
|
*
|
|
|
|
* Print the status of all registered alloc trace objects, ignoring those
|
|
|
|
* without live objects.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_alloc_trace_print_live (void)
|
|
|
|
{
|
|
|
|
GList *orig, *walk;
|
|
|
|
|
|
|
|
orig = walk = gst_alloc_trace_list_sorted ();
|
|
|
|
|
|
|
|
while (walk) {
|
|
|
|
GstAllocTrace *trace = (GstAllocTrace *) walk->data;
|
|
|
|
|
|
|
|
if (trace->live)
|
|
|
|
gst_alloc_trace_print (trace);
|
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (orig);
|
2003-02-02 19:10:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_alloc_trace_set_flags_all:
|
|
|
|
* @flags: the options to enable
|
|
|
|
*
|
|
|
|
* Enable the specified options on all registered alloc trace
|
|
|
|
* objects.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_alloc_trace_set_flags_all (GstAllocTraceFlags flags)
|
|
|
|
{
|
|
|
|
GList *walk = _gst_alloc_tracers;
|
|
|
|
|
|
|
|
while (walk) {
|
|
|
|
GstAllocTrace *trace = (GstAllocTrace *) walk->data;
|
|
|
|
|
2007-03-07 17:26:49 +00:00
|
|
|
GST_DEBUG ("setting flags %d on %p", (gint) flags, trace);
|
2003-02-02 19:10:44 +00:00
|
|
|
gst_alloc_trace_set_flags (trace, flags);
|
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
_gst_trace_flags = flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_alloc_trace_get:
|
|
|
|
* @name: the name of the alloc trace object
|
|
|
|
*
|
|
|
|
* Get the named alloc trace object.
|
|
|
|
*
|
|
|
|
* Returns: a GstAllocTrace with the given name or NULL when
|
|
|
|
* no alloc tracer was registered with that name.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstAllocTrace *
|
|
|
|
gst_alloc_trace_get (const gchar * name)
|
2003-02-02 19:10:44 +00:00
|
|
|
{
|
|
|
|
GList *walk = _gst_alloc_tracers;
|
|
|
|
|
|
|
|
g_return_val_if_fail (name, NULL);
|
|
|
|
|
|
|
|
while (walk) {
|
|
|
|
GstAllocTrace *trace = (GstAllocTrace *) walk->data;
|
|
|
|
|
|
|
|
if (!strcmp (trace->name, name))
|
|
|
|
return trace;
|
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_alloc_trace_print:
|
|
|
|
* @trace: the GstAllocTrace to print
|
|
|
|
*
|
|
|
|
* Print the status of the given GstAllocTrace.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_alloc_trace_print (const GstAllocTrace * trace)
|
2003-02-02 19:10:44 +00:00
|
|
|
{
|
|
|
|
GSList *mem_live;
|
|
|
|
|
|
|
|
g_return_if_fail (trace != NULL);
|
|
|
|
|
|
|
|
if (trace->flags & GST_ALLOC_TRACE_LIVE) {
|
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
|
|
|
g_print ("%-22.22s : %d\n", trace->name, trace->live);
|
|
|
|
} else {
|
|
|
|
g_print ("%-22.22s : (no live count)\n", trace->name);
|
2003-02-02 19:10:44 +00:00
|
|
|
}
|
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
|
|
|
|
2003-02-02 19:10:44 +00:00
|
|
|
if (trace->flags & GST_ALLOC_TRACE_MEM_LIVE) {
|
|
|
|
mem_live = trace->mem_live;
|
|
|
|
|
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
|
|
|
while (mem_live) {
|
|
|
|
g_print ("%-22.22s : %p\n", "", mem_live->data);
|
|
|
|
mem_live = mem_live->next;
|
2003-02-02 19:10:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_alloc_trace_set_flags:
|
2005-10-15 15:30:24 +00:00
|
|
|
* @trace: the GstAllocTrace
|
|
|
|
* @flags: flags to set
|
2003-02-02 19:10:44 +00:00
|
|
|
*
|
|
|
|
* Enable the given features on the given GstAllocTrace object.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_alloc_trace_set_flags (GstAllocTrace * trace, GstAllocTraceFlags flags)
|
2003-02-02 19:10:44 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (trace != NULL);
|
|
|
|
|
|
|
|
trace->flags = flags;
|
|
|
|
}
|