From 6e6fbd1cbfdaffec6f58b3c9aca58a2216fc4c30 Mon Sep 17 00:00:00 2001 From: Hyunjun Ko Date: Tue, 29 Nov 2016 14:59:02 +0900 Subject: [PATCH] vaapiencode: call ensure_encoder() at start() Currently, specific encoder is created during set_format(). This might lead to race condition when creating profiles with multiple encoders. This patch moves ensure_encoder() call to start() vmethod to ensure avoiding the race condition. https://bugzilla.gnome.org/show_bug.cgi?id=773546 --- gst/vaapi/gstvaapiencode.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gst/vaapi/gstvaapiencode.c b/gst/vaapi/gstvaapiencode.c index acaac3c..a68384a 100644 --- a/gst/vaapi/gstvaapiencode.c +++ b/gst/vaapi/gstvaapiencode.c @@ -439,6 +439,12 @@ gst_vaapiencode_open (GstVideoEncoder * venc) } static gboolean +gst_vaapiencode_start (GstVideoEncoder * venc) +{ + return ensure_encoder (GST_VAAPIENCODE_CAST (venc)); +} + +static gboolean gst_vaapiencode_close (GstVideoEncoder * venc) { GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc); @@ -473,8 +479,6 @@ gst_vaapiencode_set_format (GstVideoEncoder * venc, GstVideoCodecState * state) g_return_val_if_fail (state->caps != NULL, FALSE); - if (!ensure_encoder (encode)) - return FALSE; if (!set_codec_state (encode, state)) return FALSE; @@ -713,6 +717,7 @@ gst_vaapiencode_class_init (GstVaapiEncodeClass * klass) venc_class->open = GST_DEBUG_FUNCPTR (gst_vaapiencode_open); venc_class->close = GST_DEBUG_FUNCPTR (gst_vaapiencode_close); + venc_class->start = GST_DEBUG_FUNCPTR (gst_vaapiencode_start); venc_class->set_format = GST_DEBUG_FUNCPTR (gst_vaapiencode_set_format); venc_class->handle_frame = GST_DEBUG_FUNCPTR (gst_vaapiencode_handle_frame); venc_class->finish = GST_DEBUG_FUNCPTR (gst_vaapiencode_finish); -- 2.7.4