From d1a79d7c591fbe68f2048bcfb02a14ba49c312e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Oca=C3=B1a=20Gonz=C3=A1lez?= Date: Wed, 18 Nov 2015 12:59:59 +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. https://bugzilla.gnome.org/show_bug.cgi?id=758274 --- omx/gstomxaudiodec.c | 12 ++++++++++++ omx/gstomxaudioenc.c | 12 ++++++++++++ omx/gstomxvideodec.c | 12 ++++++++++++ omx/gstomxvideoenc.c | 12 ++++++++++++ 4 files changed, 48 insertions(+) diff --git a/omx/gstomxaudiodec.c b/omx/gstomxaudiodec.c index 9b84555e5f..b6fdf3495f 100644 --- a/omx/gstomxaudiodec.c +++ b/omx/gstomxaudiodec.c @@ -599,9 +599,15 @@ 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_AUDIO_DECODER_SRC_PAD (self)); self->downstream_flow_ret = GST_FLOW_FLUSHING; self->started = FALSE; + g_mutex_unlock (&self->drain_lock); return; } @@ -673,8 +679,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_AUDIO_DECODER_SRC_PAD (self)); self->started = FALSE; + g_mutex_unlock (&self->drain_lock); } GST_AUDIO_DECODER_STREAM_UNLOCK (self); return; diff --git a/omx/gstomxaudioenc.c b/omx/gstomxaudioenc.c index 8724f5e7b7..a6ba861176 100644 --- a/omx/gstomxaudioenc.c +++ b/omx/gstomxaudioenc.c @@ -491,9 +491,15 @@ 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_AUDIO_ENCODER_SRC_PAD (self)); self->downstream_flow_ret = GST_FLOW_FLUSHING; self->started = FALSE; + g_mutex_unlock (&self->drain_lock); return; } eos: @@ -541,8 +547,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_AUDIO_ENCODER_SRC_PAD (self)); self->started = FALSE; + g_mutex_unlock (&self->drain_lock); } GST_AUDIO_ENCODER_STREAM_UNLOCK (self); return; diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index d52a576463..2368f34e41 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -1534,9 +1534,15 @@ 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; } @@ -1594,8 +1600,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; diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index 0901b3373f..8e6cde3d48 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -788,9 +788,15 @@ 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_ENCODER_SRC_PAD (self)); self->downstream_flow_ret = GST_FLOW_FLUSHING; self->started = FALSE; + g_mutex_unlock (&self->drain_lock); return; } @@ -839,8 +845,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_ENCODER_SRC_PAD (self)); self->started = FALSE; + g_mutex_unlock (&self->drain_lock); } GST_VIDEO_ENCODER_STREAM_UNLOCK (self); return;