From 02bd7a1a98bc8a3a124e1e4554a78439e26b4caf Mon Sep 17 00:00:00 2001 From: Benny Wong Date: Tue, 18 Aug 2009 13:32:47 -0500 Subject: Wait for first frame to finish queuing to avoid delays --- libopencorehw/android_surface_output_omap34xx.cpp | 19 ++++++++++++++++--- libopencorehw/android_surface_output_omap34xx.h | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'libopencorehw') diff --git a/libopencorehw/android_surface_output_omap34xx.cpp b/libopencorehw/android_surface_output_omap34xx.cpp index 6a92773..0300a12 100644 --- a/libopencorehw/android_surface_output_omap34xx.cpp +++ b/libopencorehw/android_surface_output_omap34xx.cpp @@ -63,6 +63,7 @@ OSCL_EXPORT_REF AndroidSurfaceOutputOmap34xx::AndroidSurfaceOutputOmap34xx() : { mUseOverlay = true; mOverlay = NULL; + mIsFirstFrame = true; } OSCL_EXPORT_REF AndroidSurfaceOutputOmap34xx::~AndroidSurfaceOutputOmap34xx() @@ -170,9 +171,21 @@ PVMFStatus AndroidSurfaceOutputOmap34xx::writeFrameBuf(uint8* aData, uint32 aDat bufEnc = i; mOverlay->queueBuffer((void*)bufEnc); overlay_buffer_t overlay_buffer; - if (mOverlay->dequeueBuffer(&overlay_buffer) != NO_ERROR) { - LOGE("Video (34xx)MIO dequeue buffer failed"); - return false; + + /* This is to prevent dequeueBuffer to be called before the first + * queueBuffer call is done. If that happens, there will be a delay + * as the dequeueBuffer call will be blocked. + */ + if (!mIsFirstFrame) + { + if (mOverlay->dequeueBuffer(&overlay_buffer) != NO_ERROR) { + LOGE("Video (34xx)MIO dequeue buffer failed"); + return false; + } + } + else + { + mIsFirstFrame = false; } } return PVMFSuccess; diff --git a/libopencorehw/android_surface_output_omap34xx.h b/libopencorehw/android_surface_output_omap34xx.h index c88e010..c40f66c 100644 --- a/libopencorehw/android_surface_output_omap34xx.h +++ b/libopencorehw/android_surface_output_omap34xx.h @@ -68,6 +68,7 @@ class AndroidSurfaceOutputOmap34xx : public AndroidSurfaceOutput int32 iNumberOfBuffers; int32 iBufferSize; + bool mIsFirstFrame; public: BufferAllocOmap34xx mbufferAlloc; }; -- cgit v1.2.3