From 830566c17e3e2be79a2bbc6caf5b8e53643b3be8 Mon Sep 17 00:00:00 2001 From: Wind Yuan Date: Tue, 17 Dec 2013 04:23:42 -0500 Subject: [PATCH] vaapiencode: fix possible hang on SIGINT. vaapiencode might hang when the pipeline is stopped without any EOS, e.g. when +C is pressed, thus causing the srcpad task to keep running and locked. This fixes a possible deadlock on state change from PAUSED to READY. https://bugzilla.gnome.org/show_bug.cgi?id=720584 Signed-off-by: Gwenole Beauchesne --- gst/vaapi/gstvaapiencode.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gst/vaapi/gstvaapiencode.c b/gst/vaapi/gstvaapiencode.c index 2ac023d610..9344f97af5 100644 --- a/gst/vaapi/gstvaapiencode.c +++ b/gst/vaapi/gstvaapiencode.c @@ -595,6 +595,22 @@ gst_vaapiencode_finish (GstVideoEncoder * venc) return ret; } +static GstStateChangeReturn +gst_vaapiencode_change_state (GstElement * element, GstStateChange transition) +{ + GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (element); + + switch (transition) { + case GST_STATE_CHANGE_PAUSED_TO_READY: + gst_pad_stop_task (GST_VAAPI_PLUGIN_BASE_SRC_PAD (encode)); + break; + default: + break; + } + return GST_ELEMENT_CLASS (gst_vaapiencode_parent_class)-> + change_state (element, transition); +} + #if GST_CHECK_VERSION(1,0,0) static gboolean gst_vaapiencode_propose_allocation (GstVideoEncoder * venc, GstQuery * query) @@ -639,6 +655,7 @@ static void gst_vaapiencode_class_init (GstVaapiEncodeClass * klass) { GObjectClass *const object_class = G_OBJECT_CLASS (klass); + GstElementClass *const element_class = GST_ELEMENT_CLASS (klass); GstVideoEncoderClass *const venc_class = GST_VIDEO_ENCODER_CLASS (klass); GST_DEBUG_CATEGORY_INIT (gst_vaapiencode_debug, @@ -648,6 +665,9 @@ gst_vaapiencode_class_init (GstVaapiEncodeClass * klass) object_class->finalize = gst_vaapiencode_finalize; + element_class->change_state = + GST_DEBUG_FUNCPTR (gst_vaapiencode_change_state); + venc_class->open = GST_DEBUG_FUNCPTR (gst_vaapiencode_open); venc_class->close = GST_DEBUG_FUNCPTR (gst_vaapiencode_close); venc_class->set_format = GST_DEBUG_FUNCPTR (gst_vaapiencode_set_format);