Updates to DEBUG system: moved statename into gstelement.c, colorized the states:

Original commit message from CVS:
Updates to DEBUG system: moved statename into gstelement.c, colorized the
states:

NULL: white
READY: read
PAUSED: yellow
PLAYING: green
This commit is contained in:
Erik Walthinsen 2001-05-21 23:23:39 +00:00
parent 6ae2bbb62d
commit aa743e581b
6 changed files with 43 additions and 25 deletions

View file

@ -360,12 +360,12 @@ gst_bin_change_state (GstElement *element)
bin = GST_BIN (element); bin = GST_BIN (element);
// GST_DEBUG (GST_CAT_STATES,"currently %d(%s), %d(%s) pending\n",GST_STATE (element), // GST_DEBUG (GST_CAT_STATES,"currently %d(%s), %d(%s) pending\n",GST_STATE (element),
// _gst_print_statename (GST_STATE (element)), GST_STATE_PENDING (element), // gst_element_statename (GST_STATE (element)), GST_STATE_PENDING (element),
// _gst_print_statename (GST_STATE_PENDING (element))); // gst_element_statename (GST_STATE_PENDING (element)));
GST_INFO_ELEMENT (GST_CAT_STATES, element, "changing bin's state from %s to %s", GST_INFO_ELEMENT (GST_CAT_STATES, element, "changing bin's state from %s to %s",
_gst_print_statename (GST_STATE (element)), gst_element_statename (GST_STATE (element)),
_gst_print_statename (GST_STATE_PENDING (element))); gst_element_statename (GST_STATE_PENDING (element)));
// g_return_val_if_fail(bin->numchildren != 0, GST_STATE_FAILURE); // g_return_val_if_fail(bin->numchildren != 0, GST_STATE_FAILURE);
@ -400,7 +400,7 @@ gst_bin_change_state (GstElement *element)
case GST_STATE_FAILURE: case GST_STATE_FAILURE:
GST_STATE_PENDING (element) = GST_STATE_NONE_PENDING; GST_STATE_PENDING (element) = GST_STATE_NONE_PENDING;
GST_DEBUG (GST_CAT_STATES,"child '%s' failed to go to state %d(%s)\n", GST_ELEMENT_NAME (child), GST_DEBUG (GST_CAT_STATES,"child '%s' failed to go to state %d(%s)\n", GST_ELEMENT_NAME (child),
GST_STATE_PENDING (element), _gst_print_statename (GST_STATE_PENDING (element))); GST_STATE_PENDING (element), gst_element_statename (GST_STATE_PENDING (element)));
return GST_STATE_FAILURE; return GST_STATE_FAILURE;
break; break;
case GST_STATE_ASYNC: case GST_STATE_ASYNC:
@ -413,8 +413,8 @@ gst_bin_change_state (GstElement *element)
// g_print("<-- \"%s\"\n",GST_OBJECT_NAME(bin)); // g_print("<-- \"%s\"\n",GST_OBJECT_NAME(bin));
GST_INFO_ELEMENT (GST_CAT_STATES, element, "done changing bin's state from %s to %s", GST_INFO_ELEMENT (GST_CAT_STATES, element, "done changing bin's state from %s to %s",
_gst_print_statename (GST_STATE (element)), gst_element_statename (GST_STATE (element)),
_gst_print_statename (GST_STATE_PENDING (element))); gst_element_statename (GST_STATE_PENDING (element)));
return gst_bin_change_state_norecurse (bin); return gst_bin_change_state_norecurse (bin);
} }

View file

@ -780,7 +780,7 @@ gst_element_set_state (GstElement *element, GstElementState state)
g_return_val_if_fail (element->sched != NULL, GST_STATE_FAILURE); g_return_val_if_fail (element->sched != NULL, GST_STATE_FAILURE);
GST_DEBUG (GST_CAT_STATES,"setting element '%s' to state %s\n",GST_ELEMENT_NAME (element), GST_DEBUG (GST_CAT_STATES,"setting element '%s' to state %s\n",GST_ELEMENT_NAME (element),
_gst_print_statename(state)); gst_element_statename(state));
/* start with the current state */ /* start with the current state */
curpending = GST_STATE(element); curpending = GST_STATE(element);
@ -795,7 +795,7 @@ gst_element_set_state (GstElement *element, GstElementState state)
// FIXME: should probably check to see that we don't already have one // FIXME: should probably check to see that we don't already have one
GST_STATE_PENDING (element) = curpending; GST_STATE_PENDING (element) = curpending;
GST_DEBUG (GST_CAT_STATES,"intermediate: setting element '%s' to state %s\n", GST_DEBUG (GST_CAT_STATES,"intermediate: setting element '%s' to state %s\n",
GST_ELEMENT_NAME (element),_gst_print_statename(curpending)); GST_ELEMENT_NAME (element),gst_element_statename(curpending));
/* call the state change function so it can set the state */ /* call the state change function so it can set the state */
oclass = GST_ELEMENT_CLASS (GTK_OBJECT (element)->klass); oclass = GST_ELEMENT_CLASS (GTK_OBJECT (element)->klass);
@ -853,7 +853,7 @@ gst_element_change_state (GstElement *element)
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE); g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
GST_DEBUG (GST_CAT_STATES, "default handler sets '%s' state to %s\n", GST_DEBUG (GST_CAT_STATES, "default handler sets '%s' state to %s\n",
GST_ELEMENT_NAME (element), _gst_print_statename(GST_STATE_PENDING(element))); GST_ELEMENT_NAME (element), gst_element_statename(GST_STATE_PENDING(element)));
if ((GST_STATE_TRANSITION(element) == GST_STATE_READY_TO_PLAYING) || if ((GST_STATE_TRANSITION(element) == GST_STATE_READY_TO_PLAYING) ||
(GST_STATE_TRANSITION(element) == GST_STATE_PAUSED_TO_PLAYING)) { (GST_STATE_TRANSITION(element) == GST_STATE_PAUSED_TO_PLAYING)) {
@ -1213,3 +1213,25 @@ gst_element_signal_eos (GstElement *element)
gtk_signal_emit (GTK_OBJECT (element), gst_element_signals[EOS]); gtk_signal_emit (GTK_OBJECT (element), gst_element_signals[EOS]);
GST_FLAG_SET(element,GST_ELEMENT_COTHREAD_STOPPING); GST_FLAG_SET(element,GST_ELEMENT_COTHREAD_STOPPING);
} }
const gchar *gst_element_statename(int state) {
switch (state) {
#ifdef GST_DEBUG_COLOR
case GST_STATE_NONE_PENDING: return "NONE_PENDING";break;
case GST_STATE_NULL: return "\033[01;37mNULL\033[00m";break;
case GST_STATE_READY: return "\033[01;31mREADY\033[00m";break;
case GST_STATE_PLAYING: return "\033[01;32mPLAYING\033[00m";break;
case GST_STATE_PAUSED: return "\033[01;33mPAUSED\033[00m";break;
default: return "\033[01;37;41mUNKNOWN!\033[00m";
#else
case GST_STATE_NONE_PENDING: return "NONE_PENDING";break;
case GST_STATE_NULL: return "NULL";break;
case GST_STATE_READY: return "READY";break;
case GST_STATE_PLAYING: return "PLAYING";break;
case GST_STATE_PAUSED: return "PAUSED";break;
default: return "UNKNOWN!";
#endif
}
return "";
}

View file

@ -56,17 +56,6 @@ typedef enum {
GST_STATE_ASYNC = 2, GST_STATE_ASYNC = 2,
} GstElementStateReturn; } GstElementStateReturn;
static inline char *_gst_print_statename(int state) {
switch (state) {
case GST_STATE_NONE_PENDING: return "NONE_PENDING";break;
case GST_STATE_NULL: return "NULL";break;
case GST_STATE_READY: return "READY";break;
case GST_STATE_PLAYING: return "PLAYING";break;
case GST_STATE_PAUSED: return "PAUSED";break;
default: return "";
}
return "";
}
// NOTE: this probably should be done with an #ifdef to decide whether to safe-cast // NOTE: this probably should be done with an #ifdef to decide whether to safe-cast
// or to just do the non-checking cast. // or to just do the non-checking cast.
@ -287,6 +276,9 @@ GstElement* gst_elementfactory_make (const gchar *factoryname, const gchar *n
xmlNodePtr gst_elementfactory_save_thyself (GstElementFactory *factory, xmlNodePtr parent); xmlNodePtr gst_elementfactory_save_thyself (GstElementFactory *factory, xmlNodePtr parent);
GstElementFactory* gst_elementfactory_load_thyself (xmlNodePtr parent); GstElementFactory* gst_elementfactory_load_thyself (xmlNodePtr parent);
const gchar * gst_element_statename (int state);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View file

@ -276,7 +276,7 @@ gst_default_info_handler (gint category, gboolean incore,gchar *file, gchar *fun
#ifdef GST_DEBUG_ENABLED #ifdef GST_DEBUG_ENABLED
#ifdef GST_DEBUG_COLOR #ifdef GST_DEBUG_COLOR
fprintf(stderr,"INFO (\033[00;%dm%5d\033[00m:\033[00;%dm%2d\033[00m)\033[" fprintf(stderr,"\033[01mINFO\033[00m (\033[00;%dm%5d\033[00m:\033[00;%dm%2d\033[00m)\033["
GST_DEBUG_CHAR_MODE ";%sm%s%s\033[00m %s\n", GST_DEBUG_CHAR_MODE ";%sm%s%s\033[00m %s\n",
pthread_color,pthread_id,cothread_color,cothread_id, pthread_color,pthread_id,cothread_color,cothread_id,
_gst_category_colors[category],location,elementname,string); _gst_category_colors[category],location,elementname,string);
@ -286,7 +286,7 @@ gst_default_info_handler (gint category, gboolean incore,gchar *file, gchar *fun
#endif /* GST_DEBUG_COLOR */ #endif /* GST_DEBUG_COLOR */
#else #else
#ifdef GST_DEBUG_COLOR #ifdef GST_DEBUG_COLOR
fprintf(stderr,"INFO:\033[" GST_DEBUG_CHAR_MODE ";%sm%s%s\033[00m %s\n", fprintf(stderr,"\033[01mINFO\033[00m:\033[" GST_DEBUG_CHAR_MODE ";%sm%s%s\033[00m %s\n",
location,elementname,_gst_category_colors[category],string); location,elementname,_gst_category_colors[category],string);
#else #else
fprintf(stderr,"INFO:%s%s %s\n", fprintf(stderr,"INFO:%s%s %s\n",

View file

@ -622,6 +622,10 @@ gst_pad_connect (GstPad *srcpad,
realsrc = GST_PAD_REALIZE(srcpad); realsrc = GST_PAD_REALIZE(srcpad);
realsink = GST_PAD_REALIZE(sinkpad); realsink = GST_PAD_REALIZE(sinkpad);
if ((realsrc != srcpad) || (realsink != sinkpad))
GST_INFO (GST_CAT_PADS, "*actually* connecting %s:%s and %s:%s",
GST_DEBUG_PAD_NAME(realsrc), GST_DEBUG_PAD_NAME(realsink));
g_return_val_if_fail(GST_RPAD_PEER(realsrc) == NULL, FALSE); g_return_val_if_fail(GST_RPAD_PEER(realsrc) == NULL, FALSE);
g_return_val_if_fail(GST_RPAD_PEER(realsink) == NULL, FALSE); g_return_val_if_fail(GST_RPAD_PEER(realsink) == NULL, FALSE);

View file

@ -245,8 +245,8 @@ gst_thread_change_state (GstElement *element)
GST_INFO (GST_CAT_THREAD,"thread \"%s\" changing state to %s from %s", GST_INFO (GST_CAT_THREAD,"thread \"%s\" changing state to %s from %s",
GST_ELEMENT_NAME (GST_ELEMENT (element)), GST_ELEMENT_NAME (GST_ELEMENT (element)),
_gst_print_statename(GST_STATE_PENDING (element)), gst_element_statename(GST_STATE_PENDING (element)),
_gst_print_statename(GST_STATE (element))); gst_element_statename(GST_STATE (element)));
//GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING); //GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);