Commit f9182874 authored by Thomas Guillem's avatar Thomas Guillem Committed by 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ö's avatarMartin Storsjö <martin@martin.st>
parent e69072b9
......@@ -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;
}
......
......@@ -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();
......
......@@ -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
......
......@@ -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 *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment