From 9e4cddee7ec184c739d7efd5dee001c2b295ac9c Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Wed, 25 Apr 2012 19:01:32 +0530 Subject: [PATCH] omxvideodec: Add hack for Ducati components not returning from drain This happens on the Galaxy Nexus, and causes the pipeline to hang waiting endlessly for a drain. The hack replaces the wait with a wait + 500ms timeout. --- omx/gstomx.c | 2 ++ omx/gstomx.h | 5 +++++ omx/gstomxvideodec.c | 16 ++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/omx/gstomx.c b/omx/gstomx.c index d7cf5a0025..d51422069b 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -1973,6 +1973,8 @@ gst_omx_parse_hacks (gchar ** hacks) hacks_flags |= GST_OMX_HACK_NO_COMPONENT_RECONFIGURE; else if (g_str_equal (*hacks, "no-empty-eos-buffer")) hacks_flags |= GST_OMX_HACK_NO_EMPTY_EOS_BUFFER; + else if (g_str_equal (*hacks, "drain-may-not-return")) + hacks_flags |= GST_OMX_HACK_DRAIN_MAY_NOT_RETURN; else GST_WARNING ("Unknown hack: %s", *hacks); hacks++; diff --git a/omx/gstomx.h b/omx/gstomx.h index 84b3beab04..41f6f0e3dd 100644 --- a/omx/gstomx.h +++ b/omx/gstomx.h @@ -65,6 +65,11 @@ G_BEGIN_DECLS */ #define GST_OMX_HACK_NO_EMPTY_EOS_BUFFER G_GUINT64_CONSTANT (0x0000000000000020) +/* If the component might not acknowledge a drain. + * Happens with TI's Ducati OpenMAX implementation. + */ +#define GST_OMX_HACK_DRAIN_MAY_NOT_RETURN G_GUINT64_CONSTANT (0x0000000000000040) + typedef struct _GstOMXCore GstOMXCore; typedef struct _GstOMXPort GstOMXPort; diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 85a83c281a..c9bddf60cc 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -1398,8 +1398,20 @@ gst_omx_video_dec_drain (GstOMXVideoDec * self) buf->omx_buf->nFlags |= OMX_BUFFERFLAG_EOS; gst_omx_port_release_buffer (self->in_port, buf); GST_DEBUG_OBJECT (self, "Waiting until component is drained"); - g_cond_wait (self->drain_cond, self->drain_lock); - GST_DEBUG_OBJECT (self, "Drained component"); + + if (G_UNLIKELY(self->component->hacks & GST_OMX_HACK_DRAIN_MAY_NOT_RETURN)) { + GTimeVal tv = { .tv_sec = 0, .tv_usec = 500000 }; + + if (!g_cond_timed_wait (self->drain_cond, self->drain_lock, &tv)) + GST_WARNING_OBJECT (self, "Drain timed out"); + else + GST_DEBUG_OBJECT (self, "Drained component"); + + } else { + g_cond_wait (self->drain_cond, self->drain_lock); + GST_DEBUG_OBJECT (self, "Drained component"); + } + g_mutex_unlock (self->drain_lock); GST_BASE_VIDEO_CODEC_STREAM_LOCK (self);