diff options
author | Arun Raghavan <arun@arunraghavan.net> | 2017-03-20 17:20:36 +0530 |
---|---|---|
committer | Arun Raghavan <arun@arunraghavan.net> | 2017-03-20 21:03:42 +0530 |
commit | 97265be3aebcc00996819ada91b8b5e0b07f511d (patch) | |
tree | 7e5441d667132a6cca29b8ce7b3ee28cbe4ab572 | |
parent | d19a03ca7790c9b7f228fa57b6ac91c3e33b3d37 (diff) | |
download | gstreamer-plugins-base-97265be3aebcc00996819ada91b8b5e0b07f511d.tar.gz |
convertframe: Fix async video sample conversion with non-default context
The GSource for dealing with timeouts in
gst_video_convert_sample_async() might be attached to a non-default
context, so we should not be using g_source_remove() on the returned ID.
The correct thing to do is to keep a reference to the actual GSource and
then call g_source_destroy() on it.
https://bugzilla.gnome.org/show_bug.cgi?id=780297
-rw-r--r-- | gst-libs/gst/video/convertframe.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/gst-libs/gst/video/convertframe.c b/gst-libs/gst/video/convertframe.c index 942a51e49..bde87e91d 100644 --- a/gst-libs/gst/video/convertframe.c +++ b/gst-libs/gst/video/convertframe.c @@ -422,7 +422,7 @@ typedef struct GMainContext *context; GstSample *sample; //GstBuffer *buffer; - gulong timeout_id; + GSource *timeout_source; gboolean finished; } GstVideoConvertSampleContext; @@ -445,8 +445,8 @@ gst_video_convert_frame_context_free (GstVideoConvertSampleContext * ctx) g_mutex_lock (&ctx->mutex); g_mutex_unlock (&ctx->mutex); g_mutex_clear (&ctx->mutex); - if (ctx->timeout_id) - g_source_remove (ctx->timeout_id); + if (ctx->timeout_source) + g_source_destroy (ctx->timeout_source); //if (ctx->buffer) // gst_buffer_unref (ctx->buffer); if (ctx->sample) @@ -486,9 +486,9 @@ convert_frame_finish (GstVideoConvertSampleContext * context, GSource *source; GstVideoConvertSampleCallbackContext *ctx; - if (context->timeout_id) - g_source_remove (context->timeout_id); - context->timeout_id = 0; + if (context->timeout_source) + g_source_destroy (context->timeout_source); + context->timeout_source = NULL; ctx = g_slice_new (GstVideoConvertSampleCallbackContext); ctx->callback = context->callback; @@ -712,11 +712,10 @@ gst_video_convert_sample_async (GstSample * sample, ctx->pipeline = pipeline; if (timeout != GST_CLOCK_TIME_NONE) { - source = g_timeout_source_new (timeout / GST_MSECOND); - g_source_set_callback (source, + ctx->timeout_source = g_timeout_source_new (timeout / GST_MSECOND); + g_source_set_callback (ctx->timeout_source, (GSourceFunc) convert_frame_timeout_callback, ctx, NULL); - ctx->timeout_id = g_source_attach (source, context); - g_source_unref (source); + g_source_attach (ctx->timeout_source, context); } g_signal_connect (src, "need-data", |