[gst-cvs] gstreamer: benchmark: handle errors from the pipeline
Stefan Kost
ensonic at kemper.freedesktop.org
Thu Aug 5 00:37:13 PDT 2010
Module: gstreamer
Branch: master
Commit: dbe8e5d1ad9be08c8304128a63025a1520badc44
URL: http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=dbe8e5d1ad9be08c8304128a63025a1520badc44
Author: Stefan Kost <ensonic at users.sf.net>
Date: Thu Jul 8 14:08:27 2010 +0300
benchmark: handle errors from the pipeline
Catch errors and warnings on the bus. This fixes hanging pipelines in the case
of bugs elsewhere. Also print state-change messages to give more detail on the progress.
---
tests/benchmarks/capsnego.c | 55 +++++++++++++++++++++++++++++++++++++-----
1 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/tests/benchmarks/capsnego.c b/tests/benchmarks/capsnego.c
index d3df889..7ea534c 100644
--- a/tests/benchmarks/capsnego.c
+++ b/tests/benchmarks/capsnego.c
@@ -132,7 +132,7 @@ create_nodes (GstBin * bin, GstElement * sink, gint depth, gint children,
}
static void
-event_loop (GstElement * bin)
+event_loop (GstElement * bin, GstClockTime start)
{
GstBus *bus;
GstMessage *msg = NULL;
@@ -141,18 +141,58 @@ event_loop (GstElement * bin)
bus = gst_element_get_bus (bin);
while (running) {
- msg = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, -1);
+ msg = gst_bus_poll (bus,
+ GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR | GST_MESSAGE_WARNING,
+ -1);
- if (GST_MESSAGE_SRC (msg) == (GstObject *) bin) {
- GstState old_state, new_state;
+ switch (GST_MESSAGE_TYPE (msg)) {
+ case GST_MESSAGE_STATE_CHANGED:
+ if (GST_MESSAGE_SRC (msg) == (GstObject *) bin) {
+ GstState old_state, new_state;
+ GstClockTime end;
- gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
- if (old_state == GST_STATE_READY && new_state == GST_STATE_PAUSED) {
+ gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
+
+ end = gst_util_get_timestamp ();
+ g_print ("%" GST_TIME_FORMAT " state change on the bin: %s -> %s\n",
+ GST_TIME_ARGS (end - start),
+ gst_element_state_get_name (old_state),
+ gst_element_state_get_name (new_state));
+
+ if (old_state == GST_STATE_READY && new_state == GST_STATE_PAUSED) {
+ running = FALSE;
+ }
+ }
+ break;
+ case GST_MESSAGE_WARNING:{
+ GError *err = NULL;
+ gchar *dbg = NULL;
+
+ gst_message_parse_warning (msg, &err, &dbg);
+ GST_WARNING_OBJECT (GST_MESSAGE_SRC (msg), "%s (%s)", err->message,
+ (dbg ? dbg : "no details"));
+ g_error_free (err);
+ g_free (dbg);
+ break;
+ }
+ case GST_MESSAGE_ERROR:{
+ GError *err = NULL;
+ gchar *dbg = NULL;
+
+ gst_message_parse_error (msg, &err, &dbg);
+ GST_ERROR_OBJECT (GST_MESSAGE_SRC (msg), "%s (%s)", err->message,
+ (dbg ? dbg : "no details"));
+ g_error_free (err);
+ g_free (dbg);
running = FALSE;
+ break;
}
+ default:
+ break;
}
gst_message_unref (msg);
}
+ gst_object_unref (bus);
}
@@ -216,6 +256,7 @@ main (gint argc, gchar * argv[])
goto Error;
}
end = gst_util_get_timestamp ();
+ /* num-threads = num-sources = pow (children, depth) */
g_print ("%" GST_TIME_FORMAT " built pipeline with %d elements\n",
GST_TIME_ARGS (end - start), GST_BIN_NUMCHILDREN (bin));
@@ -225,7 +266,7 @@ main (gint argc, gchar * argv[])
GST_DEBUG_BIN_TO_DOT_FILE (bin, GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE, "capsnego");
start = gst_util_get_timestamp ();
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
- event_loop (GST_ELEMENT (bin));
+ event_loop (GST_ELEMENT (bin), start);
end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " reached paused\n",
GST_TIME_ARGS (end - start));
More information about the Gstreamer-commits
mailing list