diff options
author | He Junyan <junyan.he@intel.com> | 2020-12-08 13:34:35 +0800 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2020-12-11 18:02:34 +0000 |
commit | 5bee089331cfe6e579f75f482b2501737cfbecdc (patch) | |
tree | da329c8fdd69b59e0996911dfa8d36a28dd328e6 | |
parent | 5997093ba1415452f94e8c3c97444a5be299a37c (diff) |
plugins: encode: unlock the stream lock before _flush()
The current encoder will hang when EOS comes. When we call the
gst_vaapi_encoder_encode_and_queue(), we should release the stream
lock, just like what we do in gst_vaapiencode_handle_frame().
The deadlock happens when: The input thread holding the stream lock
is using gst_vaapi_encoder_create_coded_buffer() to acquire a coded
buffer, while the output thread which holding the coded buffer resource
is acquiring the stream lock in _push_frame() to push the data to
down stream element.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/404>
-rw-r--r-- | gst/vaapi/gstvaapiencode.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gst/vaapi/gstvaapiencode.c b/gst/vaapi/gstvaapiencode.c index a970f827..b17a81e5 100644 --- a/gst/vaapi/gstvaapiencode.c +++ b/gst/vaapi/gstvaapiencode.c @@ -565,7 +565,10 @@ gst_vaapiencode_drain (GstVaapiEncode * encode) if (!encode->encoder) return TRUE; + GST_VIDEO_ENCODER_STREAM_UNLOCK (encode); status = gst_vaapi_encoder_flush (encode->encoder); + GST_VIDEO_ENCODER_STREAM_LOCK (encode); + if (status != GST_VAAPI_ENCODER_STATUS_SUCCESS) return FALSE; gst_vaapiencode_purge (encode); @@ -722,10 +725,12 @@ gst_vaapiencode_finish (GstVideoEncoder * venc) if (!encode->encoder) return GST_FLOW_NOT_NEGOTIATED; + GST_VIDEO_ENCODER_STREAM_UNLOCK (encode); + status = gst_vaapi_encoder_flush (encode->encoder); - GST_VIDEO_ENCODER_STREAM_UNLOCK (encode); gst_pad_stop_task (GST_VAAPI_PLUGIN_BASE_SRC_PAD (encode)); + GST_VIDEO_ENCODER_STREAM_LOCK (encode); while (status == GST_VAAPI_ENCODER_STATUS_SUCCESS && ret == GST_FLOW_OK) |