]> git.sesse.net Git - vlc/commitdiff
iomx-dr: don't always lock buffers from dequeue
authorThomas Guillem <guillem@archos.com>
Fri, 25 Jul 2014 14:50:54 +0000 (16:50 +0200)
committerMartin Storsjö <martin@martin.st>
Sat, 26 Jul 2014 10:59:47 +0000 (13:59 +0300)
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@martin.st>
modules/codec/omxil/iomx_hwbuffer.c
modules/codec/omxil/omxil.c
modules/codec/omxil/omxil_core.c
modules/codec/omxil/omxil_core.h

index c22d8c750125bb5098b5e250e7c6bf87c5685457..c8619d4914dfa47059e7ca2b6a2828ad97ad45f0 100644 (file)
@@ -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;
 }
 
index 875f5a211926e2d796a85cb7d0436e7f7b53a9d3..ce8361392383eef9a78f3883cffbdca952aa3bce 100644 (file)
@@ -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();
 
index 8b866a7cb0b890552ebd4a7ab74dc958ad3e5d24..23166b39a19644d438328f6d3548d5b7c7f224cf 100644 (file)
@@ -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
index 0326179767cb8863e63a64a83cdac607971aa2e8..dbf6629c19a28841455e3007a3d7af421c59febd 100644 (file)
@@ -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 *);