From fefc5ffb41641ab1bd99a4bc71d8d20af1542acc Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Thu, 5 Sep 2013 04:34:42 -0400 Subject: [PATCH] monitor-preload: schedule a report printout at exit Conflicts: tools/gst-validate.c --- .../gst/validate/gst-validate-monitor-preload.c | 9 +++++++++ validate/gst/validate/gst-validate-runner.c | 22 ++++++++++++++++++++++ validate/gst/validate/gst-validate-runner.h | 2 ++ validate/tools/gst-validate.c | 22 ++++------------------ 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/validate/gst/validate/gst-validate-monitor-preload.c b/validate/gst/validate/gst-validate-monitor-preload.c index a583a9e..939dc73 100644 --- a/validate/gst/validate/gst-validate-monitor-preload.c +++ b/validate/gst/validate/gst-validate-monitor-preload.c @@ -27,6 +27,7 @@ #include #include +#include #include #define __USE_GNU @@ -34,6 +35,13 @@ static GstValidateRunner *runner = NULL; +static void +exit_report_printer (void) +{ + if (runner) + gst_validate_runner_printf (runner); +} + /* * Functions that wrap object creation so gst-validate can be used * to monitor 'standard' applications @@ -45,6 +53,7 @@ gst_validate_preload_wrap (GstElement * element) if (runner == NULL) { gst_validate_init (); runner = gst_validate_runner_new (); + atexit (exit_report_printer); } /* the reference to the monitor is lost */ diff --git a/validate/gst/validate/gst-validate-runner.c b/validate/gst/validate/gst-validate-runner.c index d423b0a..e2c1ff1 100644 --- a/validate/gst/validate/gst-validate-runner.c +++ b/validate/gst/validate/gst-validate-runner.c @@ -115,3 +115,25 @@ gst_validate_runner_get_reports (GstValidateRunner * runner) * after pipeline ends? */ return runner->reports; } + +int +gst_validate_runner_printf (GstValidateRunner * runner) +{ + GSList *tmp; + guint count = 0; + int ret = 0; + + for (tmp = gst_validate_runner_get_reports (runner); tmp; tmp = tmp->next) { + GstValidateReport *report = tmp->data; + + gst_validate_report_printf (report); + if (ret == 0 && report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) { + g_printerr ("Got critical error %s, setting return value to -1\n", + ((GstValidateReport *) (tmp->data))->message); + ret = -1; + } + count++; + } + g_print ("Pipeline finished, issues found: %u\n", count); + return ret; +} diff --git a/validate/gst/validate/gst-validate-runner.h b/validate/gst/validate/gst-validate-runner.h index d35561a..73803a9 100644 --- a/validate/gst/validate/gst-validate-runner.h +++ b/validate/gst/validate/gst-validate-runner.h @@ -78,6 +78,8 @@ void gst_validate_runner_add_report (GstValidateRunner * runner, Gst guint gst_validate_runner_get_reports_count (GstValidateRunner * runner); GSList * gst_validate_runner_get_reports (GstValidateRunner * runner); +int gst_validate_runner_printf (GstValidateRunner * runner); + G_END_DECLS #endif /* __GST_VALIDATE_RUNNER_H__ */ diff --git a/validate/tools/gst-validate.c b/validate/tools/gst-validate.c index 7e341d3..e4f270c 100644 --- a/validate/tools/gst-validate.c +++ b/validate/tools/gst-validate.c @@ -98,14 +98,13 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data) int main (int argc, gchar ** argv) { - GSList *tmp; GError *err = NULL; const gchar *scenario = NULL; gboolean list_scenarios = FALSE; #ifdef G_OS_UNIX guint signal_watch_id; #endif - guint count = 0; + int rep_err; GOptionEntry options[] = { {"set-scenario", '\0', 0, G_OPTION_ARG_STRING, &scenario, @@ -204,22 +203,9 @@ main (int argc, gchar ** argv) g_print ("Pipeline started\n"); g_main_loop_run (mainloop); - tmp = gst_validate_runner_get_reports (runner); - tmp = g_slist_reverse (tmp); - - g_print ("Pipeline finished\n"); - count = g_slist_length (tmp); - if (count) { - g_print ("\nFound %u issues\n", count); - - for (; tmp; tmp = tmp->next) { - GstValidateReport *report = tmp->data; - - gst_validate_report_printf (report); - if (ret == 0 && report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) - ret = -1; - } - } + rep_err = gst_validate_runner_printf (runner); + if (ret == 0) + ret = rep_err; exit: gst_element_set_state (pipeline, GST_STATE_NULL); -- 2.7.4