gst-validate: add interrupt handler
Handle interrupt properly to still print issues when exiting
This commit is contained in:
parent
ec6abff9dd
commit
db44d3aa27
@ -12,9 +12,26 @@
|
|||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/validate/validate.h>
|
#include <gst/validate/validate.h>
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
#include <glib-unix.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static GMainLoop *mainloop;
|
static GMainLoop *mainloop;
|
||||||
static GstElement *pipeline;
|
static GstElement *pipeline;
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
static gboolean
|
||||||
|
intr_handler (gpointer user_data)
|
||||||
|
{
|
||||||
|
g_print ("interrupt received.\n");
|
||||||
|
|
||||||
|
g_main_loop_quit (mainloop);
|
||||||
|
|
||||||
|
/* remove signal handler */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif /* G_OS_UNIX */
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
{
|
{
|
||||||
@ -47,6 +64,9 @@ main (int argc, gchar ** argv)
|
|||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
const gchar *scenario = NULL;
|
const gchar *scenario = NULL;
|
||||||
guint count = -1;
|
guint count = -1;
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
guint signal_watch_id;
|
||||||
|
#endif
|
||||||
|
|
||||||
GOptionEntry options[] = {
|
GOptionEntry options[] = {
|
||||||
{"set-scenario", '\0', 0, G_OPTION_ARG_STRING, &scenario,
|
{"set-scenario", '\0', 0, G_OPTION_ARG_STRING, &scenario,
|
||||||
@ -95,6 +115,11 @@ main (int argc, gchar ** argv)
|
|||||||
pipeline = (GstElement *) gst_parse_launchv ((const gchar **) argvn, &err);
|
pipeline = (GstElement *) gst_parse_launchv ((const gchar **) argvn, &err);
|
||||||
g_free (argvn);
|
g_free (argvn);
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
signal_watch_id =
|
||||||
|
g_unix_signal_add (SIGINT, (GSourceFunc) intr_handler, pipeline);
|
||||||
|
#endif
|
||||||
|
|
||||||
runner = gst_validate_runner_new ();
|
runner = gst_validate_runner_new ();
|
||||||
monitor =
|
monitor =
|
||||||
gst_validate_monitor_factory_create (GST_OBJECT_CAST (pipeline), runner,
|
gst_validate_monitor_factory_create (GST_OBJECT_CAST (pipeline), runner,
|
||||||
@ -136,6 +161,9 @@ exit:
|
|||||||
g_object_unref (monitor);
|
g_object_unref (monitor);
|
||||||
g_object_unref (runner);
|
g_object_unref (runner);
|
||||||
g_object_unref (pipeline);
|
g_object_unref (pipeline);
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
g_source_remove (signal_watch_id);
|
||||||
|
#endif
|
||||||
if (count)
|
if (count)
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user