monitor-preload: schedule a report printout at exit

Conflicts:
	tools/gst-validate.c
This commit is contained in:
Vincent Penquerc'h 2013-09-05 04:34:42 -04:00 committed by Thiago Santos
parent 7223b183f3
commit fefc5ffb41
4 changed files with 37 additions and 18 deletions

View file

@ -27,6 +27,7 @@
#include <gst/gst.h>
#include <string.h>
#include <stdlib.h>
#include <gst/validate/validate.h>
#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 */

View file

@ -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;
}

View file

@ -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__ */

View file

@ -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);