From 9813b0ca3744036895a5d0195a816899fb743b2b Mon Sep 17 00:00:00 2001 From: Erik Walthinsen Date: Sat, 30 Dec 2000 02:41:15 +0000 Subject: [PATCH] Updated more files to use INFO. Original commit message from CVS: Updated more files to use INFO. --- gst/cothreads.c | 10 +++++---- gst/gst.c | 2 ++ gst/gst_private.h | 3 +++ gst/gstbin.c | 32 +++++++++++++++++++++------- gst/gstbuffer.c | 14 +++++-------- gst/gstelement.c | 2 +- gst/gstinfo.c | 49 ++++++++++++++++++++++++++++++++----------- gst/gstinfo.h | 53 ++++++++++++++++++++++++++++++++++++----------- gst/gstpad.c | 3 +-- gst/gstplugin.c | 7 +++---- gst/gsttype.c | 2 -- 11 files changed, 124 insertions(+), 53 deletions(-) diff --git a/gst/cothreads.c b/gst/cothreads.c index 485505f9e6..a91ebacabc 100644 --- a/gst/cothreads.c +++ b/gst/cothreads.c @@ -81,9 +81,9 @@ cothread_create (cothread_context *ctx) s->sp = ((int *)s + COTHREAD_STACKSIZE); s->top_sp = s->sp; - ctx->threads[ctx->nthreads++] = s; + INFO(GST_INFO_COTHREADS,"created cothread #%d: %p at sp:%p\n", ctx->nthreads, s, s->sp); - DEBUG("created cothread at %p %p\n",s, s->sp); + ctx->threads[ctx->nthreads++] = s; return s; } @@ -121,6 +121,8 @@ cothread_init (void) { cothread_context *ctx = (cothread_context *)malloc(sizeof(cothread_context)); + INFO(GST_INFO_COTHREADS,"initializing cothreads\n"); + if (_cothread_key == -1) { if (pthread_key_create (&_cothread_key,NULL) != 0) { perror ("pthread_key_create"); @@ -141,7 +143,7 @@ cothread_init (void) ctx->threads[0]->sp = (int *)CURRENT_STACK_FRAME; ctx->threads[0]->pc = 0; - DEBUG("0th thread is at %p, sp %p\n",ctx->threads[0], ctx->threads[0]->sp); + INFO(GST_INFO_COTHREADS,"0th thread is %p at sp:%p\n",ctx->threads[0], ctx->threads[0]->sp); // we consider the initiating process to be cothread 0 ctx->nthreads = 1; @@ -257,7 +259,7 @@ cothread_switch (cothread_state *thread) // find the number of the thread to switch to ctx->current = thread->threadnum; - DEBUG("about to switch to thread #%d\n",ctx->current); + INFO(GST_INFO_COTHREAD_SWITCH,"switching to thread #%d\n",ctx->current); /* save the current stack pointer, frame pointer, and pc */ GET_SP(current->sp); diff --git a/gst/gst.c b/gst/gst.c index 1bafa0a2d3..450c6e9d9d 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -52,6 +52,8 @@ gst_init (int *argc, char **argv[]) { GstTrace *gst_trace; + INFO (GST_INFO_GST_INIT, "Initializing GStreamer Core Library\n"); + if (!g_thread_supported ()) g_thread_init (NULL); _gst_progname = g_strdup(*argv[0]); diff --git a/gst/gst_private.h b/gst/gst_private.h index e83a59112b..63b3315d63 100644 --- a/gst/gst_private.h +++ b/gst/gst_private.h @@ -28,6 +28,9 @@ #include "config.h" #endif +#include +#include + #include #endif /* __GST_PRIVATE_H__ */ diff --git a/gst/gstbin.c b/gst/gstbin.c index 6e766a066f..493cc0c96a 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -175,6 +175,8 @@ gst_bin_add (GstBin *bin, bin->numchildren++; gst_object_set_parent (GST_OBJECT (element), GST_OBJECT (bin)); + INFO_ELEMENT (GST_INFO_PARENTAGE, bin, "added child %s", gst_element_get_name(element)); + /* we know we have at least one child, we just added one... */ // if (GST_STATE(element) < GST_STATE_READY) // gst_bin_change_state_norecurse(bin,GST_STATE_READY); @@ -203,10 +205,18 @@ gst_bin_remove (GstBin *bin, g_return_if_fail ((GST_STATE (bin) == GST_STATE_NULL) || (GST_STATE (bin) == GST_STATE_PAUSED)); + if (g_list_find(bin->children, element) == NULL) { + // FIXME this should be a warning!!! + ERROR_OBJECT(bin,element,"no such element in bin"); + return; + } + gst_object_unparent (GST_OBJECT (element)); bin->children = g_list_remove (bin->children, element); bin->numchildren--; + INFO_ELEMENT (GST_INFO_PARENTAGE, bin, "removed child %s", gst_element_get_name(element)); + /* if we're down to zero children, force state to NULL */ if (bin->numchildren == 0) gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL); @@ -226,9 +236,13 @@ gst_bin_change_state (GstElement *element) bin = GST_BIN (element); - DEBUG("currently %d(%s), %d(%s) pending\n", GST_STATE (element), - _gst_print_statename (GST_STATE (element)), GST_STATE_PENDING (element), - _gst_print_statename (GST_STATE_PENDING (element))); +// DEBUG("currently %d(%s), %d(%s) pending\n",GST_STATE (element), +// _gst_print_statename (GST_STATE (element)), GST_STATE_PENDING (element), +// _gst_print_statename (GST_STATE_PENDING (element))); + + INFO_ELEMENT (GST_INFO_STATES, element, "changing bin's state from %s to %s", + _gst_print_statename (GST_STATE (element)), + _gst_print_statename (GST_STATE_PENDING (element))); // g_return_val_if_fail(bin->numchildren != 0, GST_STATE_FAILURE); @@ -386,9 +400,8 @@ gst_bin_get_by_name (GstBin *bin, g_return_val_if_fail (GST_IS_BIN (bin), NULL); g_return_val_if_fail (name != NULL, NULL); - g_print("gstbin: lookup element \"%s\" in \"%s\"\n", name, - gst_element_get_name (GST_ELEMENT (bin))); - + INFO_ELEMENT (GST_INFO_PARENTAGE, bin, "looking up child element %s", name); + children = bin->children; while (children) { child = GST_ELEMENT (children->data); @@ -436,6 +449,8 @@ gst_bin_save_thyself (GstElement *element, childlist = xmlNewChild (parent,NULL,"children",NULL); + INFO_ELEMENT (GST_INFO_XML, bin, "saving %d children", bin->numchildren); + children = bin->children; while (children) { child = GST_ELEMENT (children->data); @@ -454,10 +469,11 @@ gst_bin_restore_thyself (GstElement *element, xmlNodePtr field = parent->childs; xmlNodePtr childlist; - g_print("gstbin: restore \"%s\"\n", gst_element_get_name (element)); +// g_print("gstbin: restore \"%s\"\n", gst_element_get_name (element)); while (field) { if (!strcmp (field->name, "children")) { + INFO_ELEMENT (GST_INFO_XML, element, "loading children"); childlist = field->childs; while (childlist) { if (!strcmp (childlist->name, "element")) { @@ -557,6 +573,8 @@ gst_bin_create_plan_func (GstBin *bin) DEBUG_SET_STRING("(\"%s\")",gst_element_get_name (GST_ELEMENT (bin))); DEBUG_ENTER_STRING; + INFO_ELEMENT (GST_INFO_PLANNING, bin, "creating plan"); + // first figure out which element is the manager of this and all child elements // if we're a managing bin ourselves, that'd be us if (GST_FLAG_IS_SET (bin, GST_BIN_FLAG_MANAGER)) { diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index 0f34201639..cb8e88982e 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -20,7 +20,6 @@ * Boston, MA 02111-1307, USA. */ - /* this file makes too much noise for most debugging sessions */ #define GST_DEBUG_FORCE_DISABLE #include "gst_private.h" @@ -50,7 +49,7 @@ gst_buffer_new(void) GstBuffer *buffer; buffer = g_mem_chunk_alloc (_gst_buffer_chunk); - DEBUG("allocating new buffer %p\n",buffer); + INFO(GST_INFO_BUFFER,"creating new buffer %p",buffer); // g_print("allocating new mutex\n"); buffer->lock = g_mutex_new (); @@ -109,7 +108,7 @@ gst_buffer_create_sub (GstBuffer *parent, g_return_val_if_fail ((offset+size) <= parent->size, NULL); buffer = g_mem_chunk_alloc (_gst_buffer_chunk); - DEBUG("allocating new subbuffer %p, parent %p\n", buffer, parent); + INFO(GST_INFO_BUFFER,"creating new subbuffer %p from parent %p", buffer, parent); buffer->lock = g_mutex_new (); #ifdef HAVE_ATOMIC_H @@ -164,6 +163,8 @@ gst_buffer_append (GstBuffer *buffer, g_return_val_if_fail (append != NULL, NULL); g_return_val_if_fail (buffer->pool == NULL, NULL); + INFO(GST_INFO_BUFFER,"appending buffers %p and %p",buffer,append); + GST_BUFFER_LOCK (buffer); // the buffer is not used by anyone else if (GST_BUFFER_REFCOUNT (buffer) == 1 && buffer->parent == NULL @@ -201,12 +202,7 @@ void gst_buffer_destroy (GstBuffer *buffer) g_return_if_fail (buffer != NULL); - if (buffer->parent != NULL) { - DEBUG("freeing subbuffer %p\n", buffer); - } - else { - DEBUG("freeing buffer %p\n", buffer); - } + INFO(GST_INFO_BUFFER,"freeing %sbuffer %p", (buffer->parent?"sub":""),buffer); // free the data only if there is some, DONTFREE isn't set, and not sub if (GST_BUFFER_DATA (buffer) && diff --git a/gst/gstelement.c b/gst/gstelement.c index cfda7348b0..c3c33e45e6 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -670,7 +670,7 @@ gst_element_load_thyself (xmlNodePtr parent, g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (type != NULL, NULL); - INFO(0,NULL,"loading \"%s\" of type \"%s\"\n", name, type); + INFO(GST_INFO_XML,"loading \"%s\" of type \"%s\"\n", name, type); element = gst_elementfactory_make (type, name); diff --git a/gst/gstinfo.c b/gst/gstinfo.c index ba029c3569..5c2125ee11 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -20,9 +20,9 @@ * Boston, MA 02111-1307, USA. */ +#include "gst_private.h" #include "gst.h" - extern gchar *_gst_progname; @@ -33,26 +33,53 @@ GHashTable *__gst_function_pointers = NULL; /***** INFO system *****/ GstInfoHandler _gst_info_handler = gst_default_info_handler; +guint32 _gst_info_categories = 0xffffffff; + +static gchar *_gst_info_category_strings[] = { + "GST_INIT", + "COTHREADS", + "COTHREAD_SWITCH", + "AUTOPLUG", + "AUTOPLUG_ATTEMPT", + "PARENTAGE", + "STATES", + "PLANING", + "SCHEDULING", + "OPERATION", + "BUFFER", + "CAPS", + "CLOCK", + "ELEMENT_PADS", + "ELEMENTFACTORY", + "PADS", + "PIPELINE", + "PLUGIN_LOADING", + "PLUGIN_ERRORS", + "PROPERTIES", + "THREAD", + "TYPES", + "XML", +}; void -gst_default_info_handler (gint level, gchar *file, gchar *function, +gst_default_info_handler (gint category, gchar *file, gchar *function, gint line, gchar *debug_string, void *element, gchar *string) { if (element) { if (debug_string) - fprintf(stderr,"INFO:%d:%s:%d%s: [%s] %s\n", - level,function,line,debug_string,gst_element_get_name(element),string); + fprintf(stderr,"INFO:%s:%d%s: [%s] %s\n", + function,line,debug_string,gst_element_get_name(element),string); else - fprintf(stderr,"INFO:%d:%s:%d: [%s] %s\n", - level,function,line,gst_element_get_name(element),string); + fprintf(stderr,"INFO:%s:%d: [%s] %s\n", + function,line,gst_element_get_name(element),string); } else { if (debug_string) - fprintf(stderr,"INFO:%d:%s:%d%s: %s\n", - level,function,line,debug_string,string); + fprintf(stderr,"INFO:%s:%d%s: %s\n", + function,line,debug_string,string); else - fprintf(stderr,"INFO:%d:%s:%d: %s\n", - level,function,line,string); + fprintf(stderr,"INFO:%s:%d: %s\n", + function,line,string); } g_free(string); @@ -141,8 +168,6 @@ gst_default_error_handler (gchar *file, gchar *function, void *element, void *object, gchar *string) { int chars = 0; - GSList *parentage; - GstObject *parent; gchar *path; int i; diff --git a/gst/gstinfo.h b/gst/gstinfo.h index 1b474fe7fb..9a04c8156f 100644 --- a/gst/gstinfo.h +++ b/gst/gstinfo.h @@ -31,6 +31,8 @@ #include #endif +#include "cothreads.h" + /********************************************************************** * DEBUG system @@ -166,28 +168,57 @@ G_GNUC_UNUSED static GModule *_debug_self_module = NULL; * INFO system **********************************************************************/ -typedef void (*GstInfoHandler) (gint level,gchar *file,gchar *function, +typedef void (*GstInfoHandler) (gint category,gchar *file,gchar *function, gint line,gchar *debug_string, void *element,gchar *string); -void gst_default_info_handler (gint level,gchar *file,gchar *function, +void gst_default_info_handler (gint category,gchar *file,gchar *function, gint line,gchar *debug_string, void *element,gchar *string); extern GstInfoHandler _gst_info_handler; +extern guint32 _gst_info_categories; -#define INFO(lvl,format,args...) \ - _gst_info_handler(lvl,__FILE__,__PRETTY_FUNCTION__,__LINE__,_debug_string, \ - NULL,g_strdup_printf( format , ## args )) +#define INFO(cat,format,args...) G_STMT_START{ \ + if ((1<getregionfunc = NULL; pad->qosfunc = NULL; - pad->pushfunc = NULL; //GST_DEBUG_FUNCPTR(gst_pad_push_func); + pad->pushfunc = GST_DEBUG_FUNCPTR(gst_pad_push_func); pad->pullfunc = NULL; pad->pullregionfunc = NULL; diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 3fade713ba..660d9ac4e9 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -24,7 +24,6 @@ #include #include #include -#include //#define GST_DEBUG_ENABLED #include "gst_private.h" @@ -411,7 +410,7 @@ gst_plugin_load_elementfactory (gchar *name) gchar *filename = g_strdup (plugin->filename); gchar *pluginname = g_strdup (plugin->name); - INFO("loaded elementfactory %s from plugin %s",name,plugin->name); + INFO(GST_INFO_PLUGIN_LOADING,"loaded elementfactory %s from plugin %s",name,plugin->name); gst_plugin_remove(plugin); if (!gst_plugin_load_absolute(filename)) { DEBUG("gstplugin: error loading element factory %s from plugin %s\n", name, pluginname); @@ -458,7 +457,7 @@ gst_plugin_load_typefactory (gchar *mime) gchar *filename = g_strdup (plugin->filename); gchar *pluginname = g_strdup (plugin->name); - INFO(GST_INFO_PLUGIN_LOAD,"loading type factory for \"%s\" from plugin %s",mime,plugin->name); + INFO(GST_INFO_PLUGIN_LOADING,"loading type factory for \"%s\" from plugin %s",mime,plugin->name); gst_plugin_remove(plugin); if (!gst_plugin_load_absolute(filename)) { DEBUG("gstplugin: error loading type factory \"%s\" from plugin %s\n", mime, pluginname); @@ -630,6 +629,6 @@ gst_plugin_load_thyself (xmlNodePtr parent) kinderen = kinderen->next; } // DEBUG("gstplugin: added %d registered factories and %d types\n", elementcount, typecount); - INFO(GST_INFO_PLUGIN_LOAD,"added %d registered factories and %d types",elementcount,typecount); + INFO(GST_INFO_PLUGIN_LOADING,"added %d registered factories and %d types",elementcount,typecount); } diff --git a/gst/gsttype.c b/gst/gsttype.c index caf66008fe..ac31518331 100644 --- a/gst/gsttype.c +++ b/gst/gsttype.c @@ -27,8 +27,6 @@ * I'm not overly worried yet... */ -#include - #include "gst_private.h" #include "gsttype.h"