From f0fe1148b721f47fbb763a6c9842c8492d09899b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 14 Sep 2011 10:15:38 +0200 Subject: [PATCH] omx: Wait until the Executing state is reached before calling OMX_FillThisBuffer() This correctly works around the QCOM race condition that happens when calling FTB after setting the new state and before reaching it. --- omx/gstomx.c | 8 -------- omx/gstomx.h | 6 ------ omx/gstomxaudioenc.c | 7 +++++-- omx/gstomxvideodec.c | 7 +++++-- omx/gstomxvideoenc.c | 7 +++++-- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/omx/gstomx.c b/omx/gstomx.c index 772f3c48fc..b2a55c6a05 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -1175,9 +1175,6 @@ gst_omx_port_set_flushing (GstOMXPort * port, gboolean flush) if (port->port_def.eDir == OMX_DirOutput && port->buffers) { GstOMXBuffer *buf; - if (comp->hacks & GST_OMX_HACK_QCOM_7x30_FILL_THIS_BUFFER_RACE) - g_usleep (G_USEC_PER_SEC / 10); - /* Enqueue all buffers for the component to fill */ while ((buf = g_queue_pop_head (port->pending_buffers))) { g_assert (!buf->used); @@ -1564,9 +1561,6 @@ gst_omx_port_set_enabled_unlocked (GstOMXPort * port, gboolean enabled) if (enabled && port->port_def.eDir == OMX_DirOutput) { GstOMXBuffer *buf; - if (comp->hacks & GST_OMX_HACK_QCOM_7x30_FILL_THIS_BUFFER_RACE) - g_usleep (G_USEC_PER_SEC / 10); - /* Enqueue all buffers for the component to fill */ while ((buf = g_queue_pop_head (port->pending_buffers))) { g_assert (!buf->used); @@ -1894,8 +1888,6 @@ gst_omx_parse_hacks (gchar ** hacks) hacks_flags |= GST_OMX_HACK_VIDEO_FRAMERATE_INTEGER; else if (g_str_equal (*hacks, "syncframe-flag-not-used")) hacks_flags |= GST_OMX_HACK_SYNCFRAME_FLAG_NOT_USED; - else if (g_str_equal (*hacks, "qcom-7x30-fill-this-buffer-race")) - hacks_flags |= GST_OMX_HACK_QCOM_7x30_FILL_THIS_BUFFER_RACE; else GST_WARNING ("Unknown hack: %s", *hacks); hacks++; diff --git a/omx/gstomx.h b/omx/gstomx.h index ebdd4e8b4f..1f2d207ce6 100644 --- a/omx/gstomx.h +++ b/omx/gstomx.h @@ -55,12 +55,6 @@ G_BEGIN_DECLS * Happens with the Bellagio ffmpegdist video encoder. */ #define GST_OMX_HACK_SYNCFRAME_FLAG_NOT_USED G_GUINT64_CONSTANT (0x0000000000000008) -/* Qualcomm 7x30 sometimes fails with an undefined error after - * allocating buffers, setting the state to Idle when calling - * OMX_FillThisBuffer() on all output buffers too early. - */ -#define GST_OMX_HACK_QCOM_7x30_FILL_THIS_BUFFER_RACE G_GUINT64_CONSTANT (0x0000000000000010) - typedef struct _GstOMXCore GstOMXCore; typedef struct _GstOMXPort GstOMXPort; diff --git a/omx/gstomxaudioenc.c b/omx/gstomxaudioenc.c index 4719d0f05b..eae62e37bc 100644 --- a/omx/gstomxaudioenc.c +++ b/omx/gstomxaudioenc.c @@ -713,6 +713,10 @@ gst_omx_audio_enc_set_format (GstBaseAudioEncoder * encoder, if (gst_omx_component_set_state (self->component, OMX_StateExecuting) != OMX_ErrorNone) return FALSE; + + if (gst_omx_component_get_state (self->component, + GST_CLOCK_TIME_NONE) != OMX_StateExecuting) + return FALSE; } /* Unset flushing to allow ports to accept data again */ @@ -730,8 +734,7 @@ gst_omx_audio_enc_set_format (GstBaseAudioEncoder * encoder, gst_pad_start_task (GST_BASE_AUDIO_ENCODER_SRC_PAD (self), (GstTaskFunction) gst_omx_audio_enc_loop, encoder); - return (gst_omx_component_get_state (self->component, - GST_CLOCK_TIME_NONE) == OMX_StateExecuting); + return TRUE; } static void diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 5105ea00bb..103bfe18ba 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -1019,6 +1019,10 @@ gst_omx_video_dec_set_format (GstBaseVideoDecoder * decoder, if (gst_omx_component_set_state (self->component, OMX_StateExecuting) != OMX_ErrorNone) return FALSE; + + if (gst_omx_component_get_state (self->component, + GST_CLOCK_TIME_NONE) != OMX_StateExecuting) + return FALSE; } /* Unset flushing to allow ports to accept data again */ @@ -1036,8 +1040,7 @@ gst_omx_video_dec_set_format (GstBaseVideoDecoder * decoder, gst_pad_start_task (GST_BASE_VIDEO_CODEC_SRC_PAD (self), (GstTaskFunction) gst_omx_video_dec_loop, decoder); - return (gst_omx_component_get_state (self->component, - GST_CLOCK_TIME_NONE) == OMX_StateExecuting); + return TRUE; } static gboolean diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index d245c16c92..43ea51c2c0 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -954,6 +954,10 @@ gst_omx_video_enc_set_format (GstBaseVideoEncoder * encoder, if (gst_omx_component_set_state (self->component, OMX_StateExecuting) != OMX_ErrorNone) return FALSE; + + if (gst_omx_component_get_state (self->component, + GST_CLOCK_TIME_NONE) != OMX_StateExecuting) + return FALSE; } /* Unset flushing to allow ports to accept data again */ @@ -971,8 +975,7 @@ gst_omx_video_enc_set_format (GstBaseVideoEncoder * encoder, gst_pad_start_task (GST_BASE_VIDEO_CODEC_SRC_PAD (self), (GstTaskFunction) gst_omx_video_enc_loop, encoder); - return (gst_omx_component_get_state (self->component, - GST_CLOCK_TIME_NONE) == OMX_StateExecuting); + return TRUE; } static gboolean