diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index e58215798e..b354c29365 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -1474,6 +1474,11 @@ gst_omx_video_enc_finish (GstBaseVideoEncoder * encoder) return TRUE; self->eos = TRUE; + /* Make sure to release the base class stream lock, otherwise + * _loop() can't call _finish_frame() and we might block forever + * because no input buffers are released */ + GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (self); + /* Send an EOS buffer to the component and let the base * class drop the EOS event. We will send it later when * the EOS buffer arrives on the output port. */ @@ -1483,6 +1488,8 @@ gst_omx_video_enc_finish (GstBaseVideoEncoder * encoder) gst_omx_port_release_buffer (self->in_port, buf); } + GST_BASE_VIDEO_CODEC_STREAM_LOCK (self); + return TRUE; } @@ -1502,14 +1509,20 @@ gst_omx_video_enc_drain (GstOMXVideoEnc * self) if (self->eos) return GST_FLOW_OK; + /* Make sure to release the base class stream lock, otherwise + * _loop() can't call _finish_frame() and we might block forever + * because no input buffers are released */ + GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (self); + /* Send an EOS buffer to the component and let the base * class drop the EOS event. We will send it later when * the EOS buffer arrives on the output port. */ acq_ret = gst_omx_port_acquire_buffer (self->in_port, &buf); - if (acq_ret != GST_OMX_ACQUIRE_BUFFER_OK) + if (acq_ret != GST_OMX_ACQUIRE_BUFFER_OK) { + GST_BASE_VIDEO_CODEC_STREAM_LOCK (self); return GST_FLOW_ERROR; + } - GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (self); g_mutex_lock (self->drain_lock); self->draining = TRUE; buf->omx_buf->nFlags |= OMX_BUFFERFLAG_EOS;