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.
This commit is contained in:
Tim-Philipp Müller 2013-12-05 00:26:13 +00:00
parent d935be2d78
commit f2e68a23d7

View file

@ -458,6 +458,10 @@ print_toc_entry (gpointer data, gpointer user_data)
g_list_foreach (subentries, print_toc_entry, GUINT_TO_POINTER (indent)); 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 #ifdef G_OS_UNIX
/* As the interrupt handler is dispatched from GMainContext as a GSourceFunc /* As the interrupt handler is dispatched from GMainContext as a GSourceFunc
* handler, we can react to this by posting a message. */ * handler, we can react to this by posting a message. */
@ -475,6 +479,7 @@ intr_handler (gpointer user_data)
"message", G_TYPE_STRING, "Pipeline interrupted", NULL))); "message", G_TYPE_STRING, "Pipeline interrupted", NULL)));
/* remove signal handler */ /* remove signal handler */
signal_watch_id = 0;
return FALSE; return FALSE;
} }
@ -487,9 +492,6 @@ static EventLoopResult
event_loop (GstElement * pipeline, gboolean blocking, gboolean do_progress, event_loop (GstElement * pipeline, gboolean blocking, gboolean do_progress,
GstState target_state) GstState target_state)
{ {
#ifdef G_OS_UNIX
guint signal_watch_id;
#endif
GstBus *bus; GstBus *bus;
GstMessage *message = NULL; GstMessage *message = NULL;
EventLoopResult res = ELR_NO_ERROR; EventLoopResult res = ELR_NO_ERROR;
@ -824,7 +826,8 @@ exit:
gst_message_unref (message); gst_message_unref (message);
gst_object_unref (bus); gst_object_unref (bus);
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
g_source_remove (signal_watch_id); if (signal_watch_id > 0)
g_source_remove (signal_watch_id);
#endif #endif
return res; return res;
} }