validate🏃 Add a method to force exiting the runner

This method is similar to runner_printf() but can be used
only once. The user needs to make sure all the pipeline
are in NULL state when this is called.

The method emits a "STOPPING" signal and at that point
overrides or monitors should do extra processing/checks if
needed.

+ Make use of it everywhere where it makes sense.

API:
  gst_validate_runner_exit
  GstValidateRunner::stopping signal
This commit is contained in:
Thibault Saunier 2015-05-27 13:18:33 +02:00
parent 5ce8ab213e
commit dfe29c56e5
7 changed files with 36 additions and 5 deletions

View file

@ -39,7 +39,7 @@ static void
exit_report_printer (void)
{
if (runner)
gst_validate_runner_printf (runner);
gst_validate_runner_exit (runner, TRUE);
}
/*

View file

@ -316,6 +316,8 @@ gst_validate_reporter_set_runner (GstValidateReporter * reporter,
GstValidateReporterPrivate *priv = gst_validate_reporter_get_priv (reporter);
priv->runner = runner;
g_object_notify (G_OBJECT (reporter), "validate-runner");
}
/**

View file

@ -98,6 +98,7 @@ G_DEFINE_TYPE (GstValidateRunner, gst_validate_runner, G_TYPE_OBJECT);
enum
{
REPORT_ADDED_SIGNAL,
STOPPING_SIGNAL,
/* add more above */
LAST_SIGNAL
};
@ -262,6 +263,10 @@ gst_validate_runner_class_init (GstValidateRunnerClass * klass)
g_signal_new ("report-added", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1,
GST_TYPE_VALIDATE_REPORT);
_signals[STOPPING_SIGNAL] =
g_signal_new ("stopping", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0,
NULL, NULL, NULL, G_TYPE_NONE, 0);
}
static void
@ -501,3 +506,26 @@ gst_validate_runner_printf (GstValidateRunner * runner)
gst_validate_runner_get_reports_count (runner));
return ret;
}
int
gst_validate_runner_exit (GstValidateRunner * runner, gboolean print_result)
{
gint ret = 0;
g_signal_emit (runner, _signals[STOPPING_SIGNAL], 0);
if (print_result) {
ret = gst_validate_runner_printf (runner);
} else {
GList *tmp;
for (tmp = runner->priv->reports; tmp; tmp = tmp->next) {
GstValidateReport *report = tmp->data;
if (report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL)
ret = 18;
}
}
return ret;
}

View file

@ -76,9 +76,10 @@ GstValidateRunner * gst_validate_runner_new (void);
void gst_validate_runner_add_report (GstValidateRunner * runner, GstValidateReport * report);
guint gst_validate_runner_get_reports_count (GstValidateRunner * runner);
GList * gst_validate_runner_get_reports (GstValidateRunner * runner);
GList * gst_validate_runner_get_reports (GstValidateRunner * runner);
int gst_validate_runner_printf (GstValidateRunner * runner);
int gst_validate_runner_exit (GstValidateRunner * runner, gboolean print_result);
GstValidateReportingDetails gst_validate_runner_get_default_reporting_level (GstValidateRunner *runner);
GstValidateReportingDetails gst_validate_runner_get_reporting_level_for_name (GstValidateRunner *runner,

View file

@ -124,7 +124,7 @@ main (int argc, gchar ** argv)
g_free (output);
}
ret = gst_validate_runner_printf (runner);
ret = gst_validate_runner_exit (runner, TRUE);
if (ret && expected_file) {
output = gst_media_descriptor_writer_serialize (writer);
g_print ("Media info:\n%s\n", output);

View file

@ -940,7 +940,7 @@ main (int argc, gchar ** argv)
g_main_loop_run (mainloop);
rep_err = gst_validate_runner_printf (runner);
rep_err = gst_validate_runner_exit (runner, TRUE);
if (ret == 0)
ret = rep_err;

View file

@ -609,7 +609,7 @@ main (int argc, gchar ** argv)
gst_bus_remove_signal_watch (bus);
gst_object_unref (bus);
rep_err = gst_validate_runner_printf (runner);
rep_err = gst_validate_runner_exit (runner, TRUE);
if (ret == 0) {
ret = rep_err;
if (rep_err != 0)