From 208e303568a11ad0419b2632d6a3c90517487abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 5 Dec 2013 00:26:13 +0000 Subject: [PATCH] tools: gst-launch: don't try to remove already-removed GSource from main loop It's considered a programming error in recent GLib versions now. We may already have removed the source by returning FALSE from the callback if it was fired. Fixes warning with newer GLibs when interrupting a pipeline with Control-C. --- tools/gst-launch.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/gst-launch.c b/tools/gst-launch.c index 280b428590..d24ffd1d81 100644 --- a/tools/gst-launch.c +++ b/tools/gst-launch.c @@ -460,6 +460,10 @@ print_toc_entry (gpointer data, gpointer user_data) g_list_foreach (subentries, print_toc_entry, GUINT_TO_POINTER (indent)); } +#ifdef G_OS_UNIX +static guint signal_watch_id; +#endif + #ifdef G_OS_UNIX /* As the interrupt handler is dispatched from GMainContext as a GSourceFunc * handler, we can react to this by posting a message. */ @@ -477,6 +481,7 @@ intr_handler (gpointer user_data) "message", G_TYPE_STRING, "Pipeline interrupted", NULL))); /* remove signal handler */ + signal_watch_id = 0; return FALSE; } @@ -489,9 +494,6 @@ static EventLoopResult event_loop (GstElement * pipeline, gboolean blocking, gboolean do_progress, GstState target_state) { -#ifdef G_OS_UNIX - guint signal_watch_id; -#endif GstBus *bus; GstMessage *message = NULL; EventLoopResult res = ELR_NO_ERROR; @@ -826,7 +828,8 @@ exit: gst_message_unref (message); gst_object_unref (bus); #ifdef G_OS_UNIX - g_source_remove (signal_watch_id); + if (signal_watch_id > 0) + g_source_remove (signal_watch_id); #endif return res; }