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
This commit is contained in:
Hyunjun Ko 2016-11-29 14:59:02 +09:00 committed by Víctor Manuel Jáquez Leal
parent 4609f7fd5e
commit 6e6fbd1cbf

View file

@ -438,6 +438,12 @@ gst_vaapiencode_open (GstVideoEncoder * venc)
return success;
}
static gboolean
gst_vaapiencode_start (GstVideoEncoder * venc)
{
return ensure_encoder (GST_VAAPIENCODE_CAST (venc));
}
static gboolean
gst_vaapiencode_close (GstVideoEncoder * 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);