From 80dddfd13aaf2fe7272765f8cf291215fe375e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Oca=C3=B1a=20Gonz=C3=A1lez?= Date: Tue, 17 Nov 2015 16:51:27 +0000 Subject: [PATCH] Properly handle drain requests while flushing Without this commit the decoder streaming thread stops without ever attending the drain request, leaving the decoder input thread waiting forever. --- omx/gstomx.c | 7 +++++++ omx/gstomxvideodec.c | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/omx/gstomx.c b/omx/gstomx.c index 69696c4..f0cd890 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -830,6 +830,13 @@ gst_omx_component_set_state (GstOMXComponent * comp, OMX_STATETYPE state) done: gst_omx_component_handle_messages (comp); + + if (err != OMX_ErrorNone && comp->last_error == OMX_ErrorNone) { + GST_ERROR_OBJECT (comp->parent, + "Last operation returned an error. Setting last_error manually."); + comp->last_error = err; + } + g_mutex_unlock (&comp->lock); if (err != OMX_ErrorNone) { diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index d531f75..a26c4a6 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -1539,9 +1539,16 @@ component_error: flushing: { GST_DEBUG_OBJECT (self, "Flushing -- stopping task"); + + g_mutex_lock (&self->drain_lock); + if (self->draining) { + self->draining = FALSE; + g_cond_broadcast (&self->drain_cond); + } gst_pad_pause_task (GST_VIDEO_DECODER_SRC_PAD (self)); self->downstream_flow_ret = GST_FLOW_FLUSHING; self->started = FALSE; + g_mutex_unlock (&self->drain_lock); return; } @@ -1599,8 +1606,14 @@ flow_error: self->started = FALSE; } else if (flow_ret == GST_FLOW_FLUSHING) { GST_DEBUG_OBJECT (self, "Flushing -- stopping task"); + g_mutex_lock (&self->drain_lock); + if (self->draining) { + self->draining = FALSE; + g_cond_broadcast (&self->drain_cond); + } gst_pad_pause_task (GST_VIDEO_DECODER_SRC_PAD (self)); self->started = FALSE; + g_mutex_unlock (&self->drain_lock); } GST_VIDEO_DECODER_STREAM_UNLOCK (self); return; -- 1.8.3.2