From 4b2bb87b25f612f73f7c9a14eec142675afced3f Mon Sep 17 00:00:00 2001 From: Erik Walthinsen Date: Wed, 2 May 2001 19:20:24 +0000 Subject: [PATCH] Converted the DEBUG system to look like the INFO system, with a function pointer that can be replaced. Not done with... Original commit message from CVS: Converted the DEBUG system to look like the INFO system, with a function pointer that can be replaced. Not done with everything, since it seems that we need an ERROR system plus a FATAL error, or maybe just an ERROR system with a severity, and depending on this the DEBUG system might again be changed to have a single or at least fewer handlers. Also did a bit of work fixing up the actual DEBUG and INFO commands scattered throughout the code. We still have over 500 of these in gst/*.c alone... --- gst/gst.c | 18 +-- gst/gstcaps.c | 14 +-- gst/gstelement.c | 7 +- gst/gstelementfactory.c | 11 +- gst/gstinfo.c | 234 +++++++++++++++++++++-------------- gst/gstinfo.h | 236 ++++++++++++++++-------------------- gst/gstpad.c | 46 +++---- gst/gstprops.c | 2 +- gst/gstqueue.c | 44 +++---- plugins/elements/gstqueue.c | 44 +++---- 10 files changed, 341 insertions(+), 315 deletions(-) diff --git a/gst/gst.c b/gst/gst.c index d7b3824e3e..e859b04392 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -232,17 +232,19 @@ gst_init_check (int *argc, g_print ("--------------------------------------------------------\n"); for (i = 0; iid != tocaps->id) { - GST_DEBUG (0,"gstcaps: mime types differ (%s to %s)\n", + GST_DEBUG (GST_CAT_CAPS,"mime types differ (%s to %s)\n", gst_type_find_by_id (fromcaps->id)->mime, gst_type_find_by_id (tocaps->id)->mime); return FALSE; @@ -487,13 +487,13 @@ gst_caps_check_compatibility_func (GstCaps *fromcaps, GstCaps *tocaps) return gst_props_check_compatibility (fromcaps->properties, tocaps->properties); } else { - GST_DEBUG (0,"gstcaps: no source caps\n"); + GST_DEBUG (GST_CAT_CAPS,"no source caps\n"); return FALSE; } } else { // assume it accepts everything - GST_DEBUG (0,"gstcaps: no caps\n"); + GST_DEBUG (GST_CAT_CAPS,"no caps\n"); return TRUE; } } @@ -512,17 +512,17 @@ gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps) { if (fromcaps == NULL) { if (tocaps == NULL) { - GST_DEBUG (0,"gstcaps: no caps\n"); + GST_DEBUG (GST_CAT_CAPS,"no caps\n"); return TRUE; } else { - GST_DEBUG (0,"gstcaps: no src but destination caps\n"); + GST_DEBUG (GST_CAT_CAPS,"gstcaps: no src but destination caps\n"); return FALSE; } } else { if (tocaps == NULL) { - GST_DEBUG (0,"gstcaps: src caps and no dest caps\n"); + GST_DEBUG (GST_CAT_CAPS,"src caps and no dest caps\n"); return TRUE; } } diff --git a/gst/gstelement.c b/gst/gstelement.c index edb8504cbf..4fe9f920e9 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -378,21 +378,18 @@ gst_element_get_pad (GstElement *element, const gchar *name) if (!element->numpads) return NULL; - GST_DEBUG(GST_CAT_ELEMENT_PADS,"searching for pad '%s' in element %s\n", - name, GST_ELEMENT_NAME (element)); - // look through the list, matching by name walk = element->pads; while (walk) { GstPad *pad = GST_PAD(walk->data); if (!strcmp (GST_PAD_NAME(pad), name)) { - GST_DEBUG(GST_CAT_ELEMENT_PADS,"found pad '%s'\n",name); + GST_INFO(GST_CAT_ELEMENT_PADS,"found pad %s:%s\n",GST_DEBUG_PAD_NAME(pad)); return pad; } walk = g_list_next (walk); } - GST_DEBUG(GST_CAT_ELEMENT_PADS,"no such pad '%s'\n",name); + GST_INFO(GST_CAT_ELEMENT_PADS,"no such pad '%s' in element \"%s\"\n",name,GST_ELEMENT_NAME(element)); return NULL; } diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 0e2f275ca1..05d408e1ed 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -68,8 +68,6 @@ gst_elementfactory_find (const gchar *name) g_return_val_if_fail(name != NULL, NULL); - GST_DEBUG (GST_CAT_ELEMENTFACTORY,"gstelementfactory: find \"%s\"\n", name); - walk = _gst_elementfactories; while (walk) { factory = (GstElementFactory *)(walk->data); @@ -78,6 +76,8 @@ gst_elementfactory_find (const gchar *name) walk = g_list_next(walk); } + // this should be an ERROR + GST_DEBUG (GST_CAT_ELEMENTFACTORY,"no such elementfactoryfactory \"%s\"\n", name); return NULL; } @@ -148,7 +148,8 @@ gst_elementfactory_create (GstElementFactory *factory, g_return_val_if_fail(factory != NULL, NULL); g_return_val_if_fail(name != NULL, NULL); - GST_DEBUG (GST_CAT_ELEMENTFACTORY,"gstelementfactory: create \"%s\" \"%s\"\n", factory->name, name); + GST_DEBUG (GST_CAT_ELEMENTFACTORY,"creating element from factory \"%s\" with name \"%s\"\n", + factory->name, name); // it's not loaded, try to load the plugin if (factory->type == 0) { @@ -165,7 +166,7 @@ gst_elementfactory_create (GstElementFactory *factory, // attempt to set the elemenfactory class pointer if necessary oclass = GST_ELEMENT_CLASS(GTK_OBJECT(element)->klass); if (oclass->elementfactory == NULL) { - GST_DEBUG (GST_CAT_ELEMENTFACTORY,"gstelementfactory: class %s\n", factory->name); + GST_DEBUG (GST_CAT_ELEMENTFACTORY,"class %s\n", factory->name); oclass->elementfactory = factory; } @@ -194,7 +195,7 @@ gst_elementfactory_make (const gchar *factoryname, const gchar *name) g_return_val_if_fail(factoryname != NULL, NULL); g_return_val_if_fail(name != NULL, NULL); - GST_DEBUG (GST_CAT_ELEMENTFACTORY,"gstelementfactory: make \"%s\" \"%s\"\n", factoryname, name); +// GST_DEBUG (GST_CAT_ELEMENTFACTORY,"gstelementfactory: make \"%s\" \"%s\"\n", factoryname, name); //gst_plugin_load_elementfactory(factoryname); factory = gst_elementfactory_find(factoryname); diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 5d779a2dd5..61fd26ba68 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -28,19 +28,7 @@ extern gchar *_gst_progname; -/***** DEBUG system *****/ -GHashTable *__gst_function_pointers = NULL; - - - -/***** INFO system *****/ -GstInfoHandler _gst_info_handler = gst_default_info_handler; -#ifdef GST_INFO_ENABLED_VERBOSE -guint32 _gst_info_categories = 0xffffffff; -#else -guint32 _gst_info_categories = 0x00000001; -#endif - +/***** Categories and colorization *****/ static gchar *_gst_info_category_strings[] = { "GST_INIT", "COTHREADS", @@ -69,6 +57,21 @@ static gchar *_gst_info_category_strings[] = { "NEGOTIATION", }; +/** + * gst_get_category_name: + * @category: the category to return the name of + * + * Returns: string containing the name of the category + */ +const gchar * +gst_get_category_name (gint category) { + if ((category >= 0) && (category < GST_CAT_MAX_CATEGORY)) + return _gst_info_category_strings[category]; + else + return NULL; +} + + /* * Attribute codes: * 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed @@ -77,11 +80,10 @@ static gchar *_gst_info_category_strings[] = { * Background color codes: * 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white */ - const gchar *_gst_category_colors[32] = { [GST_CAT_GST_INIT] = "07;37", - [GST_CAT_COTHREADS] = "00;32", - [GST_CAT_COTHREAD_SWITCH] = "00;32", + [GST_CAT_COTHREADS] = "07;32", + [GST_CAT_COTHREAD_SWITCH] = "01;37;42", [GST_CAT_AUTOPLUG] = "00;34", [GST_CAT_AUTOPLUG_ATTEMPT] = "00;36;44", [GST_CAT_PARENTAGE] = "01;37;41", // !! @@ -108,8 +110,7 @@ const gchar *_gst_category_colors[32] = { [31] = "", }; - -/* colorization hash */ +/* colorization hash - DEPRACATED in favor of above */ inline gint _gst_debug_stringhash_color(gchar *file) { int filecolor = 0; while (file[0]) filecolor += *(char *)(file++); @@ -118,6 +119,125 @@ inline gint _gst_debug_stringhash_color(gchar *file) { } + +/***** DEBUG system *****/ +GstDebugHandler _gst_debug_handler = gst_default_debug_handler; +guint32 _gst_debug_categories = 0x00000000; + +/** + * gst_default_debug_handler: + * @category: category of the DEBUG message + * @file: the file the DEBUG occurs in + * @function: the function the DEBUG occurs in + * @line: the line number in the file + * @debug_string: the current debug_string in the function, if any + * @element: pointer to the #GstElement in question + * @string: the actual DEBUG string + * + * Prints out the DEBUG mesage in a variant of the following form: + * + * DEBUG(pid:cid):gst_function:542(args): [elementname] something neat happened + */ +void +gst_default_debug_handler (gint category, gboolean incore, gchar *file, gchar *function, + gint line, gchar *debug_string, + void *element, gchar *string) +{ + gchar *empty = ""; + gchar *elementname = empty,*location = empty; + int pthread_id = getpid(); + int cothread_id = cothread_getcurrent(); +#ifdef GST_DEBUG_COLOR + int pthread_color = pthread_id%6 + 31; + int cothread_color = (cothread_id < 0) ? 37 : (cothread_id%6 + 31); +#endif + + if (debug_string == NULL) debug_string = ""; +// if (category != GST_CAT_GST_INIT) + location = g_strdup_printf("%s:%d%s:",function,line,debug_string); + if (element && GST_IS_ELEMENT (element)) + elementname = g_strdup_printf (" \033[04m[%s]\033[00m", GST_OBJECT_NAME (element)); + +#ifdef GST_DEBUG_COLOR + fprintf(stderr,"DEBUG(\033[00;%dm%5d\033[00m:\033[00;%dm%2d\033[00m)\033[" + "%s;%sm%s%s\033[00m %s", + pthread_color,pthread_id,cothread_color,cothread_id,incore?"00":"01", + _gst_category_colors[category],location,elementname,string); +#else + fprintf(stderr,"DEBUG(%5d:%2d)%s%s %s", + pthread_id,cothread_id,location,elementname,string); +#endif /* GST_DEBUG_COLOR */ + + if (location != empty) g_free(location); + if (elementname != empty) g_free(elementname); + + g_free(string); +} + + +/** + * gst_debug_set_categories: + * @categories: bitmask of DEBUG categories to enable + * + * Enable the output of DEBUG categories based on the given bitmask. + * The bit for any given category is (1 << GST_CAT_...). + */ +void +gst_debug_set_categories (guint32 categories) { + _gst_debug_categories = categories; + if (categories) + GST_INFO (0, "setting DEBUG categories to 0x%08X",categories); +} + +/** + * gst_debug_get_categories: + * + * Returns: the current bitmask of enabled DEBUG categories + * The bit for any given category is (1 << GST_CAT_...). + */ +guint32 +gst_debug_get_categories () { + return _gst_debug_categories; +} + +/** + * gst_debug_enable_category: + * @category: the category to enable + * + * Enables the given GST_CAT_... DEBUG category. + */ +void +gst_debug_enable_category (gint category) { + _gst_debug_categories |= (1 << category); + if (_gst_debug_categories) + GST_INFO (0, "setting DEBUG categories to 0x%08X",_gst_debug_categories); +} + +/** + * gst_debug_disable_category: + * @category: the category to disable + * + * Disables the given GST_CAT_... DEBUG category. + */ +void +gst_debug_disable_category (gint category) { + _gst_debug_categories &= ~ (1 << category); + if (_gst_debug_categories) + GST_INFO (0, "setting DEBUG categories to 0x%08X",_gst_debug_categories); +} + + + + +/***** INFO system *****/ +GstInfoHandler _gst_info_handler = gst_default_info_handler; +#ifdef GST_INFO_ENABLED_VERBOSE +guint32 _gst_info_categories = 0xffffffff; +#else +guint32 _gst_info_categories = 0x00000001; +#endif + + /** * gst_default_info_handler: * @category: category of the INFO message @@ -133,7 +253,7 @@ inline gint _gst_debug_stringhash_color(gchar *file) { * INFO:gst_function:542(args): [elementname] something neat happened */ void -gst_default_info_handler (gint category, gchar *file, gchar *function, +gst_default_info_handler (gint category, gboolean incore,gchar *file, gchar *function, gint line, gchar *debug_string, void *element, gchar *string) { @@ -160,7 +280,7 @@ gst_default_info_handler (gint category, gchar *file, gchar *function, _gst_category_colors[category],location,elementname,string); #else fprintf(stderr,"INFO (%5d:%2d)%s%s %s\n", - getpid(),cothread_id,location,elementname,string); + pthread_id,cothread_id,location,elementname,string); #endif /* GST_DEBUG_COLOR */ #else #ifdef GST_DEBUG_COLOR @@ -231,77 +351,6 @@ gst_info_disable_category (gint category) { -/***** DEBUG system *****/ -guint32 _gst_debug_categories = 0x00000000; - - -/** - * gst_debug_set_categories: - * @categories: bitmask of DEBUG categories to enable - * - * Enable the output of DEBUG categories based on the given bitmask. - * The bit for any given category is (1 << GST_CAT_...). - */ -void -gst_debug_set_categories (guint32 categories) { - _gst_debug_categories = categories; - if (categories) - GST_INFO (0, "setting DEBUG categories to 0x%08X",categories); -} - -/** - * gst_debug_get_categories: - * - * Returns: the current bitmask of enabled DEBUG categories - * The bit for any given category is (1 << GST_CAT_...). - */ -guint32 -gst_debug_get_categories () { - return _gst_debug_categories; -} - -/** - * gst_debug_enable_category: - * @category: the category to enable - * - * Enables the given GST_CAT_... DEBUG category. - */ -void -gst_debug_enable_category (gint category) { - _gst_debug_categories |= (1 << category); - if (_gst_debug_categories) - GST_INFO (0, "setting DEBUG categories to 0x%08X",_gst_debug_categories); -} - -/** - * gst_debug_disable_category: - * @category: the category to disable - * - * Disables the given GST_CAT_... DEBUG category. - */ -void -gst_debug_disable_category (gint category) { - _gst_debug_categories &= ~ (1 << category); - if (_gst_debug_categories) - GST_INFO (0, "setting DEBUG categories to 0x%08X",_gst_debug_categories); -} - -/** - * gst_get_category_name: - * @category: the category to return the name of - * - * Returns: string containing the name of the category - */ -const gchar * -gst_get_category_name (gint category) { - if ((category >= 0) && (category < GST_CAT_MAX_CATEGORY)) - return _gst_info_category_strings[category]; - else - return NULL; -} - - - /***** ERROR system *****/ GstErrorHandler _gst_error_handler = gst_default_error_handler; @@ -389,6 +438,9 @@ gst_default_error_handler (gchar *file, gchar *function, #warning __USE_GNU is defined #endif +/***** DEBUG system *****/ +GHashTable *__gst_function_pointers = NULL; + gchar * _gst_debug_nameof_funcptr (void *ptr) { diff --git a/gst/gstinfo.h b/gst/gstinfo.h index 5646d05ff0..a0653cd19a 100644 --- a/gst/gstinfo.h +++ b/gst/gstinfo.h @@ -34,6 +34,14 @@ #include "cothreads.h" +/***** are we in the core or not? *****/ +#ifdef __GST_PRIVATE_H__ + #define _GST_DEBUG_INCORE TRUE +#else + #define _GST_DEBUG_INCORE FALSE +#endif + + /* colorization stuff */ #ifdef GST_DEBUG_COLOR #ifdef __GST_PRIVATE_H__ /* FIXME this should be some libgst.la -specific thing */ @@ -47,13 +55,50 @@ gint _gst_debug_stringhash_color(gchar *file); +/********************************************************************** + * Categories + **********************************************************************/ + +const gchar * gst_get_category_name (gint category); + +enum { + GST_CAT_GST_INIT = 0, // Library initialization + GST_CAT_COTHREADS, // Cothread creation, etc. + GST_CAT_COTHREAD_SWITCH, // Cothread switching + GST_CAT_AUTOPLUG, // Successful autoplug results + GST_CAT_AUTOPLUG_ATTEMPT, // Attempted autoplug operations + GST_CAT_PARENTAGE, // GstBin parentage issues + GST_CAT_STATES, // State changes and such + GST_CAT_PLANNING, // Plan generation + GST_CAT_SCHEDULING, // Schedule construction + GST_CAT_DATAFLOW, // Events during actual data movement + GST_CAT_BUFFER, // Buffer creation/destruction + GST_CAT_CAPS, // Capabilities matching + GST_CAT_CLOCK, // Clocking + GST_CAT_ELEMENT_PADS, // Element pad management + GST_CAT_ELEMENTFACTORY, // Elementfactory stuff + GST_CAT_PADS, // Pad creation/connection + GST_CAT_PIPELINE, // Pipeline stuff + GST_CAT_PLUGIN_LOADING, // Plugin loading + GST_CAT_PLUGIN_ERRORS, // Errors during plugin loading + GST_CAT_PLUGIN_INFO, // Plugin state information + GST_CAT_PROPERTIES, // Properties + GST_CAT_THREAD, // Thread creation/management + GST_CAT_TYPES, // Typing + GST_CAT_XML, // XML load/save of everything + GST_CAT_NEGOTIATION, // Caps Negotiation stuff + + GST_CAT_MAX_CATEGORY = 31 +}; + +extern const gchar *_gst_category_colors[32]; + + /********************************************************************** * DEBUG system **********************************************************************/ -extern guint32 _gst_debug_categories; - /* for include files that make too much noise normally */ #ifdef GST_DEBUG_FORCE_DISABLE #undef GST_DEBUG_ENABLED @@ -69,119 +114,59 @@ extern guint32 _gst_debug_categories; //#define GST_DEBUG_ENABLE_CATEGORIES 0x00000000 //#endif + +typedef void (*GstDebugHandler) (gint category,gboolean core,gchar *file,gchar *function, + gint line,gchar *debug_string, + void *element,gchar *string); + +void gst_default_debug_handler (gint category,gboolean incore,gchar *file,gchar *function, + gint line,gchar *debug_string, + void *element,gchar *string); + +extern guint32 _gst_debug_categories; +extern GstDebugHandler _gst_debug_handler; + /* fallback, this should probably be a 'weak' symbol or something */ G_GNUC_UNUSED static gchar *_debug_string = NULL; -#ifdef GST_DEBUG_COLOR - #ifdef _GST_COLOR_CODE -#warning have a coded debug - #define GST_DEBUG_PREFIX(cat,format,args...) \ -"DEBUG(%5d:%2d)\033[" _GST_COLOR_CODE "m" __PRETTY_FUNCTION__ ":%d\033[00m" format , \ -getpid() , cothread_getcurrent() , __LINE__ , ## args - #else - #define GST_DEBUG_PREFIX(cat,format,args...) \ -"DEBUG(%5d:%2d)\033[" GST_DEBUG_CHAR_MODE ";%sm" __PRETTY_FUNCTION__ ":%d\033[00m" format , \ -getpid() , cothread_getcurrent() , _gst_category_colors[cat] , __LINE__ , ## args - #endif /* _GST_COLOR_CODE */ -#else - #define GST_DEBUG_PREFIX(cat,format,args...) \ -"DEBUG(%5d:%2d)" __PRETTY_FUNCTION__ ":%d" format , getpid() ,cothread_getcurrent() , __LINE__ , ## args -#endif + #ifdef GST_DEBUG_ENABLED #define GST_DEBUG(cat,format,args...) G_STMT_START{ \ - if (((1<sched) GST_SCHEDULE_PAD_CONNECT (realsink->sched, realsrc, realsink); - GST_INFO (GST_CAT_ELEMENT_PADS, "connected %s:%s and %s:%s", - GST_DEBUG_PAD_NAME(srcpad), GST_DEBUG_PAD_NAME(sinkpad)); - if (GST_PAD_CAPS (srcpad)) { negotiated = gst_pad_renegotiate (srcpad); } @@ -645,9 +640,14 @@ gst_pad_connect (GstPad *srcpad, negotiated = TRUE; if (!negotiated) { + GST_INFO(GST_CAT_ELEMENT_PADS, "pads %s:%s and %s:%s failed to negotiate, disconnecting", + GST_DEBUG_PAD_NAME(srcpad), GST_DEBUG_PAD_NAME(sinkpad)); gst_pad_disconnect (GST_PAD (realsrc), GST_PAD (realsink)); return FALSE; } + + GST_INFO (GST_CAT_ELEMENT_PADS, "connected %s:%s and %s:%s", + GST_DEBUG_PAD_NAME(srcpad), GST_DEBUG_PAD_NAME(sinkpad)); return TRUE; } diff --git a/gst/gstprops.c b/gst/gstprops.c index 05e23539d9..eee92322f1 100644 --- a/gst/gstprops.c +++ b/gst/gstprops.c @@ -745,7 +745,7 @@ gst_props_check_compatibility (GstProps *fromprops, GstProps *toprops) if (!gst_props_entry_check_compatibility (entry1, entry2)) { compatible = FALSE; - GST_DEBUG (GST_CAT_PROPERTIES, "%s are not compatible\n:", + GST_DEBUG (GST_CAT_PROPERTIES, "%s are not compatible: ", g_quark_to_string (entry1->propid)); gst_props_debug_entry (entry1); gst_props_debug_entry (entry2); diff --git a/gst/gstqueue.c b/gst/gstqueue.c index b9316c7550..5b26a701b4 100644 --- a/gst/gstqueue.c +++ b/gst/gstqueue.c @@ -23,7 +23,7 @@ //#define DEBUG_ENABLED //#define STATUS_ENABLED #ifdef STATUS_ENABLED -#define STATUS(A) GST_DEBUG(0,A, GST_ELEMENT_NAME(queue)) +#define STATUS(A) GST_DEBUG(GST_CAT_DATAFLOW, A, GST_ELEMENT_NAME(queue)) #else #define STATUS(A) #endif @@ -208,10 +208,10 @@ gst_queue_handle_eos (GstPad *pad) queue = GST_QUEUE (GST_OBJECT_PARENT (pad)); - GST_DEBUG (0,"queue: %s received eos\n", GST_ELEMENT_NAME (queue)); + GST_DEBUG (GST_CAT_DATAFLOW,"%s received eos\n", GST_ELEMENT_NAME (queue)); GST_LOCK (queue); - GST_DEBUG (0,"queue: %s has %d buffers left\n", GST_ELEMENT_NAME (queue), + GST_DEBUG (GST_CAT_DATAFLOW,"%s has %d buffers left\n", GST_ELEMENT_NAME (queue), queue->level_buffers); GST_FLAG_SET (pad, GST_PAD_EOS); @@ -226,7 +226,7 @@ gst_queue_handle_eos (GstPad *pad) static void gst_queue_cleanup_buffers (gpointer data, const gpointer user_data) { - GST_DEBUG (0,"queue: %s cleaning buffer %p\n", (gchar *)user_data, data); + GST_DEBUG (GST_CAT_DATAFLOW,"%s cleaning buffer %p\n", (gchar *)user_data, data); gst_buffer_unref (GST_BUFFER (data)); } @@ -259,16 +259,16 @@ gst_queue_chain (GstPad *pad, GstBuffer *buf) /* we have to lock the queue since we span threads */ - GST_DEBUG (0,"queue: try have queue lock\n"); + GST_DEBUG (GST_CAT_DATAFLOW,"try have queue lock\n"); GST_LOCK (queue); - GST_DEBUG (0,"queue: %s adding buffer %p %ld\n", name, buf, pthread_self ()); - GST_DEBUG (0,"queue: have queue lock\n"); + GST_DEBUG (GST_CAT_DATAFLOW,"%s adding buffer %p %ld\n", name, buf, pthread_self ()); + GST_DEBUG (GST_CAT_DATAFLOW,"have queue lock\n"); if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLUSH)) { gst_queue_flush (queue); } - GST_DEBUG (0,"queue: %s: chain %d %p\n", name, queue->level_buffers, buf); + GST_DEBUG (GST_CAT_DATAFLOW,"%s: chain %d %p\n", name, queue->level_buffers, buf); while (queue->level_buffers >= queue->max_buffers) { // if there's a pending state change for this queue or its manager, switch @@ -280,28 +280,28 @@ gst_queue_chain (GstPad *pad, GstBuffer *buf) cothread_switch(cothread_current_main()); } - GST_DEBUG (0,"queue: %s waiting %d\n", name, queue->level_buffers); - STATUS("%s: O\n"); + GST_DEBUG (GST_CAT_DATAFLOW, "%s waiting %d\n", name, queue->level_buffers); + GST_DEBUG (GST_CAT_DATAFLOW, "%s: O\n", name); g_cond_signal (queue->emptycond); g_cond_wait (queue->fullcond, GST_OBJECT(queue)->lock); STATUS("%s: O+\n"); - GST_DEBUG (0,"queue: %s waiting done %d\n", name, queue->level_buffers); + GST_DEBUG (GST_CAT_DATAFLOW, "%s waiting done %d\n", name, queue->level_buffers); } /* put the buffer on the tail of the list */ queue->queue = g_slist_append (queue->queue, buf); - GST_DEBUG (0,"(%s:%s)+ ",GST_DEBUG_PAD_NAME(pad)); + GST_DEBUG (GST_CAT_DATAFLOW,"(%s:%s)+ ",GST_DEBUG_PAD_NAME(pad)); /* if we were empty, but aren't any more, signal a condition */ queue->level_buffers++; // if (queue->level_buffers >= 0) if (queue->level_buffers == 1) { - GST_DEBUG (0,"queue: %s signalling emptycond\n", name); + GST_DEBUG (GST_CAT_DATAFLOW,"%s signalling emptycond\n", name); g_cond_signal (queue->emptycond); } - GST_DEBUG (0,"queue: %s chain %d end signal(%d,%p)\n", name, queue->level_buffers, tosignal, queue->emptycond); + GST_DEBUG (GST_CAT_DATAFLOW,"%s chain %d end signal(%d,%p)\n", name, queue->level_buffers, tosignal, queue->emptycond); GST_UNLOCK (queue); } @@ -323,10 +323,10 @@ gst_queue_get (GstPad *pad) name = GST_ELEMENT_NAME (queue); /* have to lock for thread-safety */ - GST_DEBUG (0,"queue: %s try have queue lock\n", name); + GST_DEBUG (GST_CAT_DATAFLOW,"%s try have queue lock\n", name); GST_LOCK (queue); - GST_DEBUG (0,"queue: %s push %d %ld %p\n", name, queue->level_buffers, pthread_self (), queue->emptycond); - GST_DEBUG (0,"queue: %s have queue lock\n", name); + GST_DEBUG (GST_CAT_DATAFLOW,"%s push %d %ld %p\n", name, queue->level_buffers, pthread_self (), queue->emptycond); + GST_DEBUG (GST_CAT_DATAFLOW,"%s have queue lock\n", name); // we bail if there's nothing there // g_assert(queue->block); @@ -337,7 +337,7 @@ gst_queue_get (GstPad *pad) while (!queue->level_buffers) { if (GST_FLAG_IS_SET (queue->sinkpad, GST_PAD_EOS)) { - STATUS("queue: %s U released lock\n"); + GST_DEBUG (GST_CAT_DATAFLOW, "%s U released lock\n", name); GST_UNLOCK(queue); gst_pad_set_eos (queue->srcpad); // this return NULL shouldn't hurt anything... @@ -359,19 +359,19 @@ gst_queue_get (GstPad *pad) front = queue->queue; buf = (GstBuffer *)(front->data); - GST_DEBUG (0,"retrieved buffer %p from queue\n",buf); + GST_DEBUG (GST_CAT_DATAFLOW,"retrieved buffer %p from queue\n",buf); queue->queue = g_slist_remove_link (queue->queue, front); g_slist_free (front); // if (queue->level_buffers < queue->max_buffers) if (queue->level_buffers == queue->max_buffers) { - GST_DEBUG (0,"queue: %s signalling fullcond\n", name); + GST_DEBUG (GST_CAT_DATAFLOW,"%s signalling fullcond\n", name); g_cond_signal (queue->fullcond); } queue->level_buffers--; - GST_DEBUG (0,"(%s:%s)- ",GST_DEBUG_PAD_NAME(pad)); + GST_DEBUG (GST_CAT_DATAFLOW,"(%s:%s)- ",GST_DEBUG_PAD_NAME(pad)); GST_UNLOCK(queue); @@ -391,7 +391,7 @@ gst_queue_change_state (GstElement *element) // can't call this queue's _get (or whatever) GST_LOCK (queue); - GST_DEBUG (GST_CAT_STATES,"gstqueue: state pending %d\n", GST_STATE_PENDING (element)); + GST_DEBUG (GST_CAT_STATES,"state pending %d\n", GST_STATE_PENDING (element)); /* if going down into NULL state, clear out buffers*/ if (GST_STATE_PENDING (element) == GST_STATE_READY) { diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index b9316c7550..5b26a701b4 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -23,7 +23,7 @@ //#define DEBUG_ENABLED //#define STATUS_ENABLED #ifdef STATUS_ENABLED -#define STATUS(A) GST_DEBUG(0,A, GST_ELEMENT_NAME(queue)) +#define STATUS(A) GST_DEBUG(GST_CAT_DATAFLOW, A, GST_ELEMENT_NAME(queue)) #else #define STATUS(A) #endif @@ -208,10 +208,10 @@ gst_queue_handle_eos (GstPad *pad) queue = GST_QUEUE (GST_OBJECT_PARENT (pad)); - GST_DEBUG (0,"queue: %s received eos\n", GST_ELEMENT_NAME (queue)); + GST_DEBUG (GST_CAT_DATAFLOW,"%s received eos\n", GST_ELEMENT_NAME (queue)); GST_LOCK (queue); - GST_DEBUG (0,"queue: %s has %d buffers left\n", GST_ELEMENT_NAME (queue), + GST_DEBUG (GST_CAT_DATAFLOW,"%s has %d buffers left\n", GST_ELEMENT_NAME (queue), queue->level_buffers); GST_FLAG_SET (pad, GST_PAD_EOS); @@ -226,7 +226,7 @@ gst_queue_handle_eos (GstPad *pad) static void gst_queue_cleanup_buffers (gpointer data, const gpointer user_data) { - GST_DEBUG (0,"queue: %s cleaning buffer %p\n", (gchar *)user_data, data); + GST_DEBUG (GST_CAT_DATAFLOW,"%s cleaning buffer %p\n", (gchar *)user_data, data); gst_buffer_unref (GST_BUFFER (data)); } @@ -259,16 +259,16 @@ gst_queue_chain (GstPad *pad, GstBuffer *buf) /* we have to lock the queue since we span threads */ - GST_DEBUG (0,"queue: try have queue lock\n"); + GST_DEBUG (GST_CAT_DATAFLOW,"try have queue lock\n"); GST_LOCK (queue); - GST_DEBUG (0,"queue: %s adding buffer %p %ld\n", name, buf, pthread_self ()); - GST_DEBUG (0,"queue: have queue lock\n"); + GST_DEBUG (GST_CAT_DATAFLOW,"%s adding buffer %p %ld\n", name, buf, pthread_self ()); + GST_DEBUG (GST_CAT_DATAFLOW,"have queue lock\n"); if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLUSH)) { gst_queue_flush (queue); } - GST_DEBUG (0,"queue: %s: chain %d %p\n", name, queue->level_buffers, buf); + GST_DEBUG (GST_CAT_DATAFLOW,"%s: chain %d %p\n", name, queue->level_buffers, buf); while (queue->level_buffers >= queue->max_buffers) { // if there's a pending state change for this queue or its manager, switch @@ -280,28 +280,28 @@ gst_queue_chain (GstPad *pad, GstBuffer *buf) cothread_switch(cothread_current_main()); } - GST_DEBUG (0,"queue: %s waiting %d\n", name, queue->level_buffers); - STATUS("%s: O\n"); + GST_DEBUG (GST_CAT_DATAFLOW, "%s waiting %d\n", name, queue->level_buffers); + GST_DEBUG (GST_CAT_DATAFLOW, "%s: O\n", name); g_cond_signal (queue->emptycond); g_cond_wait (queue->fullcond, GST_OBJECT(queue)->lock); STATUS("%s: O+\n"); - GST_DEBUG (0,"queue: %s waiting done %d\n", name, queue->level_buffers); + GST_DEBUG (GST_CAT_DATAFLOW, "%s waiting done %d\n", name, queue->level_buffers); } /* put the buffer on the tail of the list */ queue->queue = g_slist_append (queue->queue, buf); - GST_DEBUG (0,"(%s:%s)+ ",GST_DEBUG_PAD_NAME(pad)); + GST_DEBUG (GST_CAT_DATAFLOW,"(%s:%s)+ ",GST_DEBUG_PAD_NAME(pad)); /* if we were empty, but aren't any more, signal a condition */ queue->level_buffers++; // if (queue->level_buffers >= 0) if (queue->level_buffers == 1) { - GST_DEBUG (0,"queue: %s signalling emptycond\n", name); + GST_DEBUG (GST_CAT_DATAFLOW,"%s signalling emptycond\n", name); g_cond_signal (queue->emptycond); } - GST_DEBUG (0,"queue: %s chain %d end signal(%d,%p)\n", name, queue->level_buffers, tosignal, queue->emptycond); + GST_DEBUG (GST_CAT_DATAFLOW,"%s chain %d end signal(%d,%p)\n", name, queue->level_buffers, tosignal, queue->emptycond); GST_UNLOCK (queue); } @@ -323,10 +323,10 @@ gst_queue_get (GstPad *pad) name = GST_ELEMENT_NAME (queue); /* have to lock for thread-safety */ - GST_DEBUG (0,"queue: %s try have queue lock\n", name); + GST_DEBUG (GST_CAT_DATAFLOW,"%s try have queue lock\n", name); GST_LOCK (queue); - GST_DEBUG (0,"queue: %s push %d %ld %p\n", name, queue->level_buffers, pthread_self (), queue->emptycond); - GST_DEBUG (0,"queue: %s have queue lock\n", name); + GST_DEBUG (GST_CAT_DATAFLOW,"%s push %d %ld %p\n", name, queue->level_buffers, pthread_self (), queue->emptycond); + GST_DEBUG (GST_CAT_DATAFLOW,"%s have queue lock\n", name); // we bail if there's nothing there // g_assert(queue->block); @@ -337,7 +337,7 @@ gst_queue_get (GstPad *pad) while (!queue->level_buffers) { if (GST_FLAG_IS_SET (queue->sinkpad, GST_PAD_EOS)) { - STATUS("queue: %s U released lock\n"); + GST_DEBUG (GST_CAT_DATAFLOW, "%s U released lock\n", name); GST_UNLOCK(queue); gst_pad_set_eos (queue->srcpad); // this return NULL shouldn't hurt anything... @@ -359,19 +359,19 @@ gst_queue_get (GstPad *pad) front = queue->queue; buf = (GstBuffer *)(front->data); - GST_DEBUG (0,"retrieved buffer %p from queue\n",buf); + GST_DEBUG (GST_CAT_DATAFLOW,"retrieved buffer %p from queue\n",buf); queue->queue = g_slist_remove_link (queue->queue, front); g_slist_free (front); // if (queue->level_buffers < queue->max_buffers) if (queue->level_buffers == queue->max_buffers) { - GST_DEBUG (0,"queue: %s signalling fullcond\n", name); + GST_DEBUG (GST_CAT_DATAFLOW,"%s signalling fullcond\n", name); g_cond_signal (queue->fullcond); } queue->level_buffers--; - GST_DEBUG (0,"(%s:%s)- ",GST_DEBUG_PAD_NAME(pad)); + GST_DEBUG (GST_CAT_DATAFLOW,"(%s:%s)- ",GST_DEBUG_PAD_NAME(pad)); GST_UNLOCK(queue); @@ -391,7 +391,7 @@ gst_queue_change_state (GstElement *element) // can't call this queue's _get (or whatever) GST_LOCK (queue); - GST_DEBUG (GST_CAT_STATES,"gstqueue: state pending %d\n", GST_STATE_PENDING (element)); + GST_DEBUG (GST_CAT_STATES,"state pending %d\n", GST_STATE_PENDING (element)); /* if going down into NULL state, clear out buffers*/ if (GST_STATE_PENDING (element) == GST_STATE_READY) {