[vlc-commits] iomx-dr: don't always lock buffers from dequeue

Thomas Guillem git at videolan.org
Sat Jul 26 13:08:50 CEST 2014


vlc | branch: master | Thomas Guillem <guillem at archos.com> | Fri Jul 25 16:50:54 2014 +0200| [f9182874b2235acea94ef634552188edc80b2df8] | committer: Martin Storsjö

iomx-dr: don't always lock buffers from dequeue

According to OMXCodec.cpp, we shouldn't call lockBuffer when we first allocate
all buffers, since we may cancel some of them (the min_undequeued ones).

We should call lockBuffer only before giving a buffer to OMX.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f9182874b2235acea94ef634552188edc80b2df8
---

 modules/codec/omxil/iomx_hwbuffer.c |   16 ++++++++++++++--
 modules/codec/omxil/omxil.c         |   13 +++++++++++--
 modules/codec/omxil/omxil_core.c    |    2 ++
 modules/codec/omxil/omxil_core.h    |    1 +
 4 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/modules/codec/omxil/iomx_hwbuffer.c b/modules/codec/omxil/iomx_hwbuffer.c
index c22d8c7..c8619d4 100644
--- a/modules/codec/omxil/iomx_hwbuffer.c
+++ b/modules/codec/omxil/iomx_hwbuffer.c
@@ -181,6 +181,20 @@ int IOMXHWBuffer_Dequeue( void *window, void **pp_handle )
 #endif
     CHECK_ERR();
 
+    *pp_handle = anb;
+
+    return 0;
+}
+
+int IOMXHWBuffer_Lock( void *window, void *p_handle )
+{
+    ANativeWindow *anw = (ANativeWindow *)window;
+    ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
+    status_t err = NO_ERROR;
+
+    CHECK_ANW();
+    CHECK_ANB();
+
 #if ANDROID_API >= 18
     err = anw->lockBuffer_DEPRECATED( anw, anb );
 #else
@@ -188,8 +202,6 @@ int IOMXHWBuffer_Dequeue( void *window, void **pp_handle )
 #endif
     CHECK_ERR();
 
-    *pp_handle = anb;
-
     return 0;
 }
 
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 875f5a2..ce83613 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -2018,8 +2018,8 @@ static void HwBuffer_Init( decoder_t *p_dec, OmxPort *p_port )
     if( !(pf_enable_graphic_buffers && pf_get_graphic_buffer_usage &&
           pf_omx_hwbuffer_connect && pf_omx_hwbuffer_disconnect &&
           pf_omx_hwbuffer_setup && pf_omx_hwbuffer_setcrop &&
-          pf_omx_hwbuffer_dequeue && pf_omx_hwbuffer_queue &&
-          pf_omx_hwbuffer_cancel &&
+          pf_omx_hwbuffer_dequeue && pf_omx_hwbuffer_lock &&
+          pf_omx_hwbuffer_queue && pf_omx_hwbuffer_cancel &&
           ((OMX_COMPONENTTYPE*)p_port->omx_handle)->UseBuffer) )
     {
         msg_Warn( p_dec, "direct output port enabled but can't find "
@@ -2281,6 +2281,13 @@ static int HwBuffer_Start( decoder_t *p_dec, OmxPort *p_port )
 
         if( p_header && p_port->p_hwbuf->i_states[i] == BUF_STATE_OWNED )
         {
+            if( pf_omx_hwbuffer_lock( p_port->p_hwbuf->window,
+                                      p_header->pBuffer ) != 0 )
+            {
+                msg_Err( p_dec, "lock failed" );
+                HWBUFFER_UNLOCK();
+                return -1;
+            }
             OMX_DBG( "FillThisBuffer %p, %p", p_header, p_header->pBuffer );
             OMX_FillThisBuffer( p_port->omx_handle, p_header );
         }
@@ -2455,6 +2462,8 @@ static void *DequeueThread( void *data )
          * we call the dequeue function if there is at least one buffer
          * available. */
         err = pf_omx_hwbuffer_dequeue( p_port->p_hwbuf->window, &p_handle );
+        if( err == 0 )
+            err = pf_omx_hwbuffer_lock( p_port->p_hwbuf->window, p_handle );
 
         HWBUFFER_LOCK();
 
diff --git a/modules/codec/omxil/omxil_core.c b/modules/codec/omxil/omxil_core.c
index 8b866a7..23166b3 100644
--- a/modules/codec/omxil/omxil_core.c
+++ b/modules/codec/omxil/omxil_core.c
@@ -96,6 +96,7 @@ int (*pf_omx_hwbuffer_setup) (void *, int, int, int, int, unsigned int *,
                               unsigned int *);
 int (*pf_omx_hwbuffer_setcrop) (void *, int, int, int, int);
 int (*pf_omx_hwbuffer_dequeue) (void *, void **);
+int (*pf_omx_hwbuffer_lock) (void *, void *);
 int (*pf_omx_hwbuffer_queue) (void *, void *);
 int (*pf_omx_hwbuffer_cancel) (void *, void *);
 
@@ -180,6 +181,7 @@ int InitOmxCore(vlc_object_t *p_this)
     pf_omx_hwbuffer_setup = dlsym( dll_handle, "OMXHWBuffer_Setup" );
     pf_omx_hwbuffer_setcrop = dlsym( dll_handle, "OMXHWBuffer_Setcrop" );
     pf_omx_hwbuffer_dequeue = dlsym( dll_handle, "OMXHWBuffer_Dequeue" );
+    pf_omx_hwbuffer_lock = dlsym( dll_handle, "OMXHWBuffer_Lock" );
     pf_omx_hwbuffer_queue = dlsym( dll_handle, "OMXHWBuffer_Queue" );
     pf_omx_hwbuffer_cancel = dlsym( dll_handle, "OMXHWBuffer_Cancel" );
 #endif
diff --git a/modules/codec/omxil/omxil_core.h b/modules/codec/omxil/omxil_core.h
index 0326179..dbf6629 100644
--- a/modules/codec/omxil/omxil_core.h
+++ b/modules/codec/omxil/omxil_core.h
@@ -44,6 +44,7 @@ int (*pf_omx_hwbuffer_setup) (void *, int, int, int, int, unsigned int *,
                               unsigned int *);
 int (*pf_omx_hwbuffer_setcrop) (void *, int, int, int, int);
 int (*pf_omx_hwbuffer_dequeue) (void *, void **);
+int (*pf_omx_hwbuffer_lock) (void *, void *);
 int (*pf_omx_hwbuffer_queue) (void *, void *);
 int (*pf_omx_hwbuffer_cancel) (void *, void *);
 



More information about the vlc-commits mailing list