Commit b4ceb7f3 authored by Thomas Guillem's avatar Thomas Guillem Committed by Jean-Baptiste Kempf

Revert "nativewindowpriv: use fence_fd"

fence_fd should stay in nativewindowpriv.c, no need to export it. It's not
needed by hw buffers (iomx-dr), and it's not used by gralloc until Android 5.0.

This reverts commit 06cb362f.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 826a226f
...@@ -2277,7 +2277,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2277,7 +2277,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port )
void *p_handle = NULL; void *p_handle = NULL;
if( p_port->p_hwbuf->anwpriv.dequeue( p_port->p_hwbuf->window_priv, 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" ); msg_Err( p_dec, "OMXHWBuffer_dequeue Fail" );
goto error; goto error;
...@@ -2290,7 +2290,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2290,7 +2290,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port )
{ {
OMX_DBG( "canceling buffer(%d)", i ); OMX_DBG( "canceling buffer(%d)", i );
p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, 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; return 0;
...@@ -2320,7 +2320,7 @@ static int HwBuffer_FreeBuffers( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2320,7 +2320,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 ) 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 ); HwBuffer_ChangeState( p_dec, p_port, i, BUF_STATE_NOT_OWNED );
} }
} }
...@@ -2361,7 +2361,7 @@ static int HwBuffer_Start( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2361,7 +2361,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_header && p_port->p_hwbuf->i_states[i] == BUF_STATE_OWNED )
{ {
if( p_port->p_hwbuf->anwpriv.lock( p_port->p_hwbuf->window_priv, 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" ); msg_Err( p_dec, "lock failed" );
HWBUFFER_UNLOCK(); HWBUFFER_UNLOCK();
...@@ -2410,7 +2410,7 @@ static int HwBuffer_Stop( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2410,7 +2410,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; void *p_handle = p_port->pp_buffers[p_picsys->priv.hw.i_index]->pBuffer;
if( p_handle ) 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, HwBuffer_ChangeState( p_dec, p_port, p_picsys->priv.hw.i_index,
BUF_STATE_NOT_OWNED ); BUF_STATE_NOT_OWNED );
} }
...@@ -2540,9 +2540,9 @@ static void *DequeueThread( void *data ) ...@@ -2540,9 +2540,9 @@ static void *DequeueThread( void *data )
/* The thread can be stuck here. It shouldn't happen since we make sure /* 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 * we call the dequeue function if there is at least one buffer
* available. */ * 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 ) 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(); HWBUFFER_LOCK();
...@@ -2554,7 +2554,7 @@ static void *DequeueThread( void *data ) ...@@ -2554,7 +2554,7 @@ static void *DequeueThread( void *data )
if( !p_port->p_hwbuf->b_run ) 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; continue;
} }
...@@ -2619,9 +2619,9 @@ static void UnlockPicture( picture_t* p_pic ) ...@@ -2619,9 +2619,9 @@ static void UnlockPicture( picture_t* p_pic )
} }
if( p_picsys->b_render ) if( p_picsys->b_render )
p_port->p_hwbuf->anwpriv.queue( p_port->p_hwbuf->window_priv, p_handle, -1 ); p_port->p_hwbuf->anwpriv.queue( p_port->p_hwbuf->window_priv, p_handle );
else 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_ChangeState( p_dec, p_port, p_picsys->priv.hw.i_index, BUF_STATE_NOT_OWNED );
HWBUFFER_BROADCAST( p_port ); HWBUFFER_BROADCAST( p_port );
......
...@@ -472,7 +472,6 @@ static void AndroidWindow_UnlockPicture(vout_display_sys_t *sys, ...@@ -472,7 +472,6 @@ static void AndroidWindow_UnlockPicture(vout_display_sys_t *sys,
if (p_window->b_use_priv) { if (p_window->b_use_priv) {
int err = 0; int err = 0;
void *p_handle = p_picsys->priv.sw.p_handle; void *p_handle = p_picsys->priv.sw.p_handle;
int i_fence_fd = p_picsys->priv.sw.i_fence_fd;
if (p_handle == NULL) if (p_handle == NULL)
return; return;
...@@ -481,11 +480,9 @@ static void AndroidWindow_UnlockPicture(vout_display_sys_t *sys, ...@@ -481,11 +480,9 @@ static void AndroidWindow_UnlockPicture(vout_display_sys_t *sys,
if (err == 0) { if (err == 0) {
if (p_picsys->b_render) if (p_picsys->b_render)
err = sys->anwp.queue(p_window->p_handle_priv, p_handle, err = sys->anwp.queue(p_window->p_handle_priv, p_handle);
i_fence_fd);
else else
err = sys->anwp.cancel(p_window->p_handle_priv, p_handle, err = sys->anwp.cancel(p_window->p_handle_priv, p_handle);
i_fence_fd);
} }
} else } else
sys->anw.unlockAndPost(p_window->p_handle); sys->anw.unlockAndPost(p_window->p_handle);
...@@ -499,19 +496,16 @@ static int AndroidWindow_LockPicture(vout_display_sys_t *sys, ...@@ -499,19 +496,16 @@ static int AndroidWindow_LockPicture(vout_display_sys_t *sys,
if (p_window->b_use_priv) { if (p_window->b_use_priv) {
void *p_handle; void *p_handle;
int i_fence_fd = -1;
int err; int err;
err = sys->anwp.dequeue(p_window->p_handle_priv, &p_handle, &i_fence_fd); err = sys->anwp.dequeue(p_window->p_handle_priv, &p_handle);
err = err == 0 ? sys->anwp.lock(p_window->p_handle_priv, err = err == 0 ? sys->anwp.lock(p_window->p_handle_priv, p_handle) : err;
p_handle, i_fence_fd) : err;
err = err == 0 ? sys->anwp.lockData(p_window->p_handle_priv, err = err == 0 ? sys->anwp.lockData(p_window->p_handle_priv,
p_handle, p_handle,
&p_picsys->priv.sw.buf) : err; &p_picsys->priv.sw.buf) : err;
if (err != 0) if (err != 0)
return -1; return -1;
p_picsys->priv.sw.p_handle = p_handle; p_picsys->priv.sw.p_handle = p_handle;
p_picsys->priv.sw.i_fence_fd = i_fence_fd;
} else { } else {
if (sys->anw.winLock(p_window->p_handle, if (sys->anw.winLock(p_window->p_handle,
&p_picsys->priv.sw.buf, NULL) != 0) &p_picsys->priv.sw.buf, NULL) != 0)
......
...@@ -50,7 +50,6 @@ struct picture_sys_t ...@@ -50,7 +50,6 @@ struct picture_sys_t
} hw; } hw;
struct { struct {
void *p_handle; void *p_handle;
int i_fence_fd;
ANativeWindow_Buffer buf; ANativeWindow_Buffer buf;
} sw; } sw;
} priv; } priv;
......
...@@ -24,23 +24,17 @@ ...@@ -24,23 +24,17 @@
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
#define ANDROID_HC_OR_LATER (ANDROID_API >= 11)
#define ANDROID_ICS_OR_LATER (ANDROID_API >= 14)
#define ANDROID_JBMR2_OR_LATER (ANDROID_API >= 18)
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#if ANDROID_JBMR2_OR_LATER
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#endif
#include <android/native_window.h> #include <android/native_window.h>
#define ANDROID_HC_OR_LATER (ANDROID_API >= 11)
#define ANDROID_ICS_OR_LATER (ANDROID_API >= 14)
#define ANDROID_JBMR2_OR_LATER (ANDROID_API >= 18)
#if ANDROID_ICS_OR_LATER #if ANDROID_ICS_OR_LATER
#include <system/window.h> #include <system/window.h>
#else #else
...@@ -71,7 +65,6 @@ struct native_window_priv ...@@ -71,7 +65,6 @@ struct native_window_priv
#define LOGD(...) __android_log_print( ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__ ) #define LOGD(...) __android_log_print( ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__ )
#define LOGE(...) __android_log_print( ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__ ) #define LOGE(...) __android_log_print( ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__ )
#define LOGW(...) __android_log_print( ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__ )
#define CHECK_ERR() do {\ #define CHECK_ERR() do {\
if( err != NO_ERROR ) {\ if( err != NO_ERROR ) {\
...@@ -228,49 +221,15 @@ int ANativeWindowPriv_setCrop( native_window_priv *priv, int ofs_x, int ofs_y, i ...@@ -228,49 +221,15 @@ int ANativeWindowPriv_setCrop( native_window_priv *priv, int ofs_x, int ofs_y, i
return native_window_set_crop( priv->anw, &crop ); return native_window_set_crop( priv->anw, &crop );
} }
int ANativeWindowPriv_dequeue( native_window_priv *priv, void **pp_handle, int ANativeWindowPriv_dequeue( native_window_priv *priv, void **pp_handle )
int *p_fence_fd )
{ {
ANativeWindowBuffer_t *anb; ANativeWindowBuffer_t *anb;
status_t err = NO_ERROR; status_t err = NO_ERROR;
#if ANDROID_JBMR2_OR_LATER #if ANDROID_JBMR2_OR_LATER
int i_fence_fd = -1; err = priv->anw->dequeueBuffer_DEPRECATED( priv->anw, &anb );
err = priv->anw->dequeueBuffer( priv->anw, &anb, &i_fence_fd );
if( p_fence_fd )
{
*p_fence_fd = i_fence_fd;
}
else if( i_fence_fd != -1 )
{
fd_set rfds;
struct timeval tv;
int ret;
LOGW("dequeue: fence_fd != -1 and not handled");
FD_ZERO(&rfds);
FD_SET(i_fence_fd, &rfds);
/* Wait up to 5 seconds. */
tv.tv_sec = 5;
tv.tv_usec = 0;
ret = select(i_fence_fd + 1, &rfds, NULL, NULL, &tv);
if (ret == -1) {
priv->anw->cancelBuffer( priv->anw, anb, i_fence_fd );
LOGE("dequeue: select error on fence_fd");
return -1;
} else if (ret == 0) {
LOGW("dequeue: fence_fd timed out");
}
close(i_fence_fd);
}
#else #else
err = priv->anw->dequeueBuffer( priv->anw, &anb ); err = priv->anw->dequeueBuffer( priv->anw, &anb );
if (p_fence_fd)
*p_fence_fd = -1;
#endif #endif
CHECK_ERR(); CHECK_ERR();
...@@ -279,19 +238,20 @@ int ANativeWindowPriv_dequeue( native_window_priv *priv, void **pp_handle, ...@@ -279,19 +238,20 @@ int ANativeWindowPriv_dequeue( native_window_priv *priv, void **pp_handle,
return 0; return 0;
} }
int ANativeWindowPriv_lock( native_window_priv *priv, void *p_handle, int ANativeWindowPriv_lock( native_window_priv *priv, void *p_handle )
int i_fence_fd )
{ {
#if !ANDROID_JBMR2_OR_LATER
ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle; ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
status_t err = NO_ERROR; status_t err = NO_ERROR;
CHECK_ANB(); CHECK_ANB();
#if ANDROID_JBMR2_OR_LATER
err = priv->anw->lockBuffer_DEPRECATED( priv->anw, anb );
#else
err = priv->anw->lockBuffer( priv->anw, anb ); err = priv->anw->lockBuffer( priv->anw, anb );
#endif
CHECK_ERR(); CHECK_ERR();
#endif
return 0; return 0;
} }
...@@ -331,8 +291,7 @@ int ANativeWindowPriv_unlockData( native_window_priv *priv, void *p_handle ) ...@@ -331,8 +291,7 @@ int ANativeWindowPriv_unlockData( native_window_priv *priv, void *p_handle )
return 0; return 0;
} }
int ANativeWindowPriv_queue( native_window_priv *priv, void *p_handle, int ANativeWindowPriv_queue( native_window_priv *priv, void *p_handle )
int i_fence_fd )
{ {
ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle; ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
status_t err = NO_ERROR; status_t err = NO_ERROR;
...@@ -340,7 +299,7 @@ int ANativeWindowPriv_queue( native_window_priv *priv, void *p_handle, ...@@ -340,7 +299,7 @@ int ANativeWindowPriv_queue( native_window_priv *priv, void *p_handle,
CHECK_ANB(); CHECK_ANB();
#if ANDROID_JBMR2_OR_LATER #if ANDROID_JBMR2_OR_LATER
err = priv->anw->queueBuffer( priv->anw, anb, i_fence_fd ); err = priv->anw->queueBuffer_DEPRECATED( priv->anw, anb );
#else #else
err = priv->anw->queueBuffer( priv->anw, anb ); err = priv->anw->queueBuffer( priv->anw, anb );
#endif #endif
...@@ -349,8 +308,7 @@ int ANativeWindowPriv_queue( native_window_priv *priv, void *p_handle, ...@@ -349,8 +308,7 @@ int ANativeWindowPriv_queue( native_window_priv *priv, void *p_handle,
return 0; return 0;
} }
int ANativeWindowPriv_cancel( native_window_priv *priv, void *p_handle, int ANativeWindowPriv_cancel( native_window_priv *priv, void *p_handle )
int i_fence_fd )
{ {
ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle; ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
status_t err = NO_ERROR; status_t err = NO_ERROR;
...@@ -358,7 +316,7 @@ int ANativeWindowPriv_cancel( native_window_priv *priv, void *p_handle, ...@@ -358,7 +316,7 @@ int ANativeWindowPriv_cancel( native_window_priv *priv, void *p_handle,
CHECK_ANB(); CHECK_ANB();
#if ANDROID_JBMR2_OR_LATER #if ANDROID_JBMR2_OR_LATER
err = priv->anw->cancelBuffer( priv->anw, anb, i_fence_fd ); err = priv->anw->cancelBuffer_DEPRECATED( priv->anw, anb );
#else #else
err = priv->anw->cancelBuffer( priv->anw, anb ); err = priv->anw->cancelBuffer( priv->anw, anb );
#endif #endif
......
...@@ -78,12 +78,12 @@ typedef int (*ptr_ANativeWindowPriv_getMinUndequeued) (native_window_priv *, uns ...@@ -78,12 +78,12 @@ typedef int (*ptr_ANativeWindowPriv_getMinUndequeued) (native_window_priv *, uns
typedef int (*ptr_ANativeWindowPriv_getMaxBufferCount) (native_window_priv *, unsigned int *); typedef int (*ptr_ANativeWindowPriv_getMaxBufferCount) (native_window_priv *, unsigned int *);
typedef int (*ptr_ANativeWindowPriv_setBufferCount) (native_window_priv *, unsigned int ); typedef int (*ptr_ANativeWindowPriv_setBufferCount) (native_window_priv *, unsigned int );
typedef int (*ptr_ANativeWindowPriv_setCrop) (native_window_priv *, int, int, int, int); typedef int (*ptr_ANativeWindowPriv_setCrop) (native_window_priv *, int, int, int, int);
typedef int (*ptr_ANativeWindowPriv_dequeue) (native_window_priv *, void **, int *); typedef int (*ptr_ANativeWindowPriv_dequeue) (native_window_priv *, void **);
typedef int (*ptr_ANativeWindowPriv_lock) (native_window_priv *, void *, int); typedef int (*ptr_ANativeWindowPriv_lock) (native_window_priv *, void *);
typedef int (*ptr_ANativeWindowPriv_lockData) (native_window_priv *, void *, ANativeWindow_Buffer *); typedef int (*ptr_ANativeWindowPriv_lockData) (native_window_priv *, void *, ANativeWindow_Buffer *);
typedef int (*ptr_ANativeWindowPriv_unlockData) (native_window_priv *, void *); typedef int (*ptr_ANativeWindowPriv_unlockData) (native_window_priv *, void *);
typedef int (*ptr_ANativeWindowPriv_queue) (native_window_priv *, void *, int); typedef int (*ptr_ANativeWindowPriv_queue) (native_window_priv *, void *);
typedef int (*ptr_ANativeWindowPriv_cancel) (native_window_priv *, void *, int); typedef int (*ptr_ANativeWindowPriv_cancel) (native_window_priv *, void *);
typedef int (*ptr_ANativeWindowPriv_setOrientation) (native_window_priv *, int); typedef int (*ptr_ANativeWindowPriv_setOrientation) (native_window_priv *, int);
typedef struct typedef struct
......
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