mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
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.
This commit is contained in:
parent
ced3d517eb
commit
dbe8e5d1ad
1 changed files with 49 additions and 8 deletions
|
@ -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) {
|
||||
running = FALSE;
|
||||
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));
|
||||
|
|
Loading…
Reference in a new issue