summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2018-11-30 12:40:19 +0200
committerTim-Philipp Müller <tim@centricular.com>2019-05-01 17:01:58 +0100
commitc5e239094c82aa64f45913ede469167adb57b081 (patch)
tree5a66c65a0826407aebe747248254c26066c676ad
parent2d87fd688aeb5c42c01292e76cb6d9dc6ca27c0f (diff)
downloadgstreamer-plugins-base-c5e239094c82aa64f45913ede469167adb57b081.tar.gz
video: convertframe: Shut down pipeline asynchronously via the thread pool
If we use the main loop it might happen that the caller (e.g. our unit test) already shut down the loop once the result was received and in that case the pipeline would never ever be shut down (and our unit test would hang).
-rw-r--r--gst-libs/gst/video/convertframe.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/gst-libs/gst/video/convertframe.c b/gst-libs/gst/video/convertframe.c
index b3e780a9c..d6d6610d0 100644
--- a/gst-libs/gst/video/convertframe.c
+++ b/gst-libs/gst/video/convertframe.c
@@ -486,11 +486,10 @@ convert_frame_dispatch_callback (GstVideoConvertSampleContext * ctx)
return FALSE;
}
-static gboolean
-convert_frame_stop_pipeline (GstElement * element)
+static void
+convert_frame_stop_pipeline (GstElement * element, gpointer user_data)
{
gst_element_set_state (element, GST_STATE_NULL);
- return FALSE;
}
static void
@@ -522,14 +521,14 @@ convert_frame_finish (GstVideoConvertSampleContext * context,
* state to NULL and get rid of its last reference, which in turn
* will get rid of all remaining references to our context and free
* it too. We can't do this directly here as we might be called from
- * a streaming thread. */
+ * a streaming thread.
+ *
+ * We don't use the main loop here because the user might shut down it
+ * immediately after getting the result of the conversion above.
+ */
if (context->pipeline) {
- source = g_timeout_source_new (0);
- g_source_set_callback (source,
- (GSourceFunc) convert_frame_stop_pipeline,
- context->pipeline, (GDestroyNotify) gst_object_unref);
- g_source_attach (source, context->context);
- g_source_unref (source);
+ gst_element_call_async (context->pipeline, convert_frame_stop_pipeline,
+ NULL, NULL);
context->pipeline = NULL;
}
}