]> git.sesse.net Git - vlc/blobdiff - modules/codec/omxil/omxil.c
nativewindowpriv: split setup into setUsage and setBuffersGeometry
[vlc] / modules / codec / omxil / omxil.c
index 936049daaf672b885030b3ac01f7b1919611d71d..9bdedc5b0e79b24eeae4fe5196e6e3673eb06a31 100644 (file)
@@ -96,7 +96,7 @@ static OMX_ERRORTYPE OmxFillBufferDone( OMX_HANDLETYPE, OMX_PTR,
 
 #if defined(USE_IOMX)
 static void *DequeueThread( void *data );
-static void UnlockPicture( picture_t* p_pic );
+static void UnlockPicture( picture_t* p_pic, bool b_render );
 static void HwBuffer_Init( decoder_t *p_dec, OmxPort *p_port );
 static void HwBuffer_Destroy( decoder_t *p_dec, OmxPort *p_port );
 static int  HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port );
@@ -2215,14 +2215,18 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port )
                                                  i_angle );
     }
 
-    if( p_port->p_hwbuf->anwpriv.setup( p_port->p_hwbuf->window_priv,
-                                        def->format.video.nFrameWidth,
-                                        def->format.video.nFrameHeight,
-                                        colorFormat,
-                                        true,
-                                        (int) i_hw_usage ) != 0 )
+    if( p_port->p_hwbuf->anwpriv.setUsage( p_port->p_hwbuf->window_priv,
+                                           true, (int) i_hw_usage ) != 0 )
     {
-        msg_Err( p_dec, "can't setup OMXHWBuffer" );
+        msg_Err( p_dec, "can't set usage" );
+        goto error;
+    }
+    if( p_port->p_hwbuf->anwpriv.setBuffersGeometry( p_port->p_hwbuf->window_priv,
+                                                     def->format.video.nFrameWidth,
+                                                     def->format.video.nFrameHeight,
+                                                     colorFormat ) != 0 )
+    {
+        msg_Err( p_dec, "can't set buffers geometry" );
         goto error;
     }
 
@@ -2277,7 +2281,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port )
         void *p_handle = NULL;
 
         if( p_port->p_hwbuf->anwpriv.dequeue( p_port->p_hwbuf->window_priv,
-                                              &p_handle, NULL ) != 0 )
+                                              &p_handle ) != 0 )
         {
             msg_Err( p_dec, "OMXHWBuffer_dequeue Fail" );
             goto error;
@@ -2290,7 +2294,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port )
     {
         OMX_DBG( "canceling buffer(%d)", i );
         p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv,
-                                         p_port->p_hwbuf->pp_handles[i], -1 );
+                                         p_port->p_hwbuf->pp_handles[i] );
     }
 
     return 0;
@@ -2320,7 +2324,7 @@ static int HwBuffer_FreeBuffers( decoder_t *p_dec, OmxPort *p_port )
 
             if( p_handle && p_port->p_hwbuf->i_states[i] == BUF_STATE_OWNED )
             {
-                p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, p_handle, -1 );
+                p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, p_handle );
                 HwBuffer_ChangeState( p_dec, p_port, i, BUF_STATE_NOT_OWNED );
             }
         }
@@ -2361,7 +2365,7 @@ 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( p_port->p_hwbuf->anwpriv.lock( p_port->p_hwbuf->window_priv,
-                                               p_header->pBuffer, -1 ) != 0 )
+                                               p_header->pBuffer ) != 0 )
             {
                 msg_Err( p_dec, "lock failed" );
                 HWBUFFER_UNLOCK();
@@ -2410,7 +2414,7 @@ static int HwBuffer_Stop( decoder_t *p_dec, OmxPort *p_port )
                     void *p_handle = p_port->pp_buffers[p_picsys->priv.hw.i_index]->pBuffer;
                     if( p_handle )
                     {
-                        p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, p_handle, -1 );
+                        p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, p_handle );
                         HwBuffer_ChangeState( p_dec, p_port, p_picsys->priv.hw.i_index,
                                               BUF_STATE_NOT_OWNED );
                     }
@@ -2540,9 +2544,9 @@ static void *DequeueThread( void *data )
         /* The thread can be stuck here. It shouldn't happen since we make sure
          * we call the dequeue function if there is at least one buffer
          * available. */
-        err = p_port->p_hwbuf->anwpriv.dequeue( p_port->p_hwbuf->window_priv, &p_handle, NULL );
+        err = p_port->p_hwbuf->anwpriv.dequeue( p_port->p_hwbuf->window_priv, &p_handle );
         if( err == 0 )
-            err = p_port->p_hwbuf->anwpriv.lock( p_port->p_hwbuf->window_priv, p_handle, -1 );
+            err = p_port->p_hwbuf->anwpriv.lock( p_port->p_hwbuf->window_priv, p_handle );
 
         HWBUFFER_LOCK();
 
@@ -2554,7 +2558,7 @@ static void *DequeueThread( void *data )
 
         if( !p_port->p_hwbuf->b_run )
         {
-            p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, p_handle, -1 );
+            p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, p_handle );
             continue;
         }
 
@@ -2589,7 +2593,7 @@ static void *DequeueThread( void *data )
 /*****************************************************************************
  * vout callbacks
  *****************************************************************************/
-static void UnlockPicture( picture_t* p_pic )
+static void UnlockPicture( picture_t* p_pic, bool b_render )
 {
     picture_sys_t *p_picsys = p_pic->p_sys;
     decoder_t *p_dec = p_picsys->priv.hw.p_dec;
@@ -2610,7 +2614,7 @@ static void UnlockPicture( picture_t* p_pic )
     p_handle = p_port->pp_buffers[p_picsys->priv.hw.i_index]->pBuffer;
 
     OMX_DBG( "DisplayBuffer: %s %p",
-             p_picsys->b_render ? "render" : "cancel", p_handle );
+             b_render ? "render" : "cancel", p_handle );
 
     if( !p_handle )
     {
@@ -2618,10 +2622,10 @@ static void UnlockPicture( picture_t* p_pic )
         goto end;
     }
 
-    if( p_picsys->b_render )
-        p_port->p_hwbuf->anwpriv.queue( p_port->p_hwbuf->window_priv, p_handle, -1 );
+    if( b_render )
+        p_port->p_hwbuf->anwpriv.queue( p_port->p_hwbuf->window_priv, p_handle );
     else
-        p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, p_handle, -1 );
+        p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, p_handle );
 
     HwBuffer_ChangeState( p_dec, p_port, p_picsys->priv.hw.i_index, BUF_STATE_NOT_OWNED );
     HWBUFFER_BROADCAST( p_port );