[vlc-devel] [PATCH 1/8] Revert "nativewindowpriv: use fence_fd"
Julian Scheel
julian at jusst.de
Thu Nov 20 13:34:47 CET 2014
Am 20.11.2014 um 13:16 schrieb Thomas Guillem:
> This reverts commit 06cb362f3aaa45f53de3f6a755961bc7dded5495.
Would you mind adding a short explanation why you revert this?
> ---
> modules/codec/omxil/omxil.c | 20 +++----
> modules/video_output/android/android_window.c | 14 ++---
> modules/video_output/android/android_window.h | 1 -
> modules/video_output/android/nativewindowpriv.c | 72 ++++++-------------------
> modules/video_output/android/utils.h | 8 +--
> 5 files changed, 33 insertions(+), 82 deletions(-)
>
> diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
> index 936049d..95abfb2 100644
> --- a/modules/codec/omxil/omxil.c
> +++ b/modules/codec/omxil/omxil.c
> @@ -2277,7 +2277,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 +2290,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 +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 )
> {
> - 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 +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_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 +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;
> 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 +2540,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 +2554,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;
> }
>
> @@ -2619,9 +2619,9 @@ static void UnlockPicture( picture_t* p_pic )
> }
>
> 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
> - 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 );
> diff --git a/modules/video_output/android/android_window.c b/modules/video_output/android/android_window.c
> index 101271b..d2ac522 100644
> --- a/modules/video_output/android/android_window.c
> +++ b/modules/video_output/android/android_window.c
> @@ -472,7 +472,6 @@ static void AndroidWindow_UnlockPicture(vout_display_sys_t *sys,
> if (p_window->b_use_priv) {
> int err = 0;
> void *p_handle = p_picsys->priv.sw.p_handle;
> - int i_fence_fd = p_picsys->priv.sw.i_fence_fd;
>
> if (p_handle == NULL)
> return;
> @@ -481,11 +480,9 @@ static void AndroidWindow_UnlockPicture(vout_display_sys_t *sys,
>
> if (err == 0) {
> if (p_picsys->b_render)
> - err = sys->anwp.queue(p_window->p_handle_priv, p_handle,
> - i_fence_fd);
> + err = sys->anwp.queue(p_window->p_handle_priv, p_handle);
> else
> - err = sys->anwp.cancel(p_window->p_handle_priv, p_handle,
> - i_fence_fd);
> + err = sys->anwp.cancel(p_window->p_handle_priv, p_handle);
> }
> } else
> sys->anw.unlockAndPost(p_window->p_handle);
> @@ -499,19 +496,16 @@ static int AndroidWindow_LockPicture(vout_display_sys_t *sys,
>
> if (p_window->b_use_priv) {
> void *p_handle;
> - int i_fence_fd = -1;
> int err;
>
> - err = sys->anwp.dequeue(p_window->p_handle_priv, &p_handle, &i_fence_fd);
> - err = err == 0 ? sys->anwp.lock(p_window->p_handle_priv,
> - p_handle, i_fence_fd) : err;
> + err = sys->anwp.dequeue(p_window->p_handle_priv, &p_handle);
> + err = err == 0 ? sys->anwp.lock(p_window->p_handle_priv, p_handle) : err;
> err = err == 0 ? sys->anwp.lockData(p_window->p_handle_priv,
> p_handle,
> &p_picsys->priv.sw.buf) : err;
> if (err != 0)
> return -1;
> p_picsys->priv.sw.p_handle = p_handle;
> - p_picsys->priv.sw.i_fence_fd = i_fence_fd;
> } else {
> if (sys->anw.winLock(p_window->p_handle,
> &p_picsys->priv.sw.buf, NULL) != 0)
> diff --git a/modules/video_output/android/android_window.h b/modules/video_output/android/android_window.h
> index f4d1d90..68101c8 100644
> --- a/modules/video_output/android/android_window.h
> +++ b/modules/video_output/android/android_window.h
> @@ -50,7 +50,6 @@ struct picture_sys_t
> } hw;
> struct {
> void *p_handle;
> - int i_fence_fd;
> ANativeWindow_Buffer buf;
> } sw;
> } priv;
> diff --git a/modules/video_output/android/nativewindowpriv.c b/modules/video_output/android/nativewindowpriv.c
> index 712d198..bcf5c03 100644
> --- a/modules/video_output/android/nativewindowpriv.c
> +++ b/modules/video_output/android/nativewindowpriv.c
> @@ -24,23 +24,17 @@
> * 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 <stdio.h>
> #include <stdlib.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>
>
> +#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
> #include <system/window.h>
> #else
> @@ -71,7 +65,6 @@ struct native_window_priv
>
> #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 LOGW(...) __android_log_print( ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__ )
>
> #define CHECK_ERR() do {\
> if( err != NO_ERROR ) {\
> @@ -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 );
> }
>
> -int ANativeWindowPriv_dequeue( native_window_priv *priv, void **pp_handle,
> - int *p_fence_fd )
> +int ANativeWindowPriv_dequeue( native_window_priv *priv, void **pp_handle )
> {
> ANativeWindowBuffer_t *anb;
> status_t err = NO_ERROR;
>
> #if ANDROID_JBMR2_OR_LATER
> - int i_fence_fd = -1;
> - 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);
> - }
> + err = priv->anw->dequeueBuffer_DEPRECATED( priv->anw, &anb );
> #else
> err = priv->anw->dequeueBuffer( priv->anw, &anb );
> - if (p_fence_fd)
> - *p_fence_fd = -1;
> #endif
> CHECK_ERR();
>
> @@ -279,19 +238,20 @@ int ANativeWindowPriv_dequeue( native_window_priv *priv, void **pp_handle,
> return 0;
> }
>
> -int ANativeWindowPriv_lock( native_window_priv *priv, void *p_handle,
> - int i_fence_fd )
> +int ANativeWindowPriv_lock( native_window_priv *priv, void *p_handle )
> {
> -#if !ANDROID_JBMR2_OR_LATER
> ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
> status_t err = NO_ERROR;
>
> CHECK_ANB();
>
> +#if ANDROID_JBMR2_OR_LATER
> + err = priv->anw->lockBuffer_DEPRECATED( priv->anw, anb );
> +#else
> err = priv->anw->lockBuffer( priv->anw, anb );
> +#endif
> CHECK_ERR();
>
> -#endif
> return 0;
> }
>
> @@ -331,8 +291,7 @@ int ANativeWindowPriv_unlockData( native_window_priv *priv, void *p_handle )
> return 0;
> }
>
> -int ANativeWindowPriv_queue( native_window_priv *priv, void *p_handle,
> - int i_fence_fd )
> +int ANativeWindowPriv_queue( native_window_priv *priv, void *p_handle )
> {
> ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
> status_t err = NO_ERROR;
> @@ -340,7 +299,7 @@ int ANativeWindowPriv_queue( native_window_priv *priv, void *p_handle,
> CHECK_ANB();
>
> #if ANDROID_JBMR2_OR_LATER
> - err = priv->anw->queueBuffer( priv->anw, anb, i_fence_fd );
> + err = priv->anw->queueBuffer_DEPRECATED( priv->anw, anb );
> #else
> err = priv->anw->queueBuffer( priv->anw, anb );
> #endif
> @@ -349,8 +308,7 @@ int ANativeWindowPriv_queue( native_window_priv *priv, void *p_handle,
> return 0;
> }
>
> -int ANativeWindowPriv_cancel( native_window_priv *priv, void *p_handle,
> - int i_fence_fd )
> +int ANativeWindowPriv_cancel( native_window_priv *priv, void *p_handle )
> {
> ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
> status_t err = NO_ERROR;
> @@ -358,7 +316,7 @@ int ANativeWindowPriv_cancel( native_window_priv *priv, void *p_handle,
> CHECK_ANB();
>
> #if ANDROID_JBMR2_OR_LATER
> - err = priv->anw->cancelBuffer( priv->anw, anb, i_fence_fd );
> + err = priv->anw->cancelBuffer_DEPRECATED( priv->anw, anb );
> #else
> err = priv->anw->cancelBuffer( priv->anw, anb );
> #endif
> diff --git a/modules/video_output/android/utils.h b/modules/video_output/android/utils.h
> index 148cc48..97b74bf 100644
> --- a/modules/video_output/android/utils.h
> +++ b/modules/video_output/android/utils.h
> @@ -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_setBufferCount) (native_window_priv *, unsigned 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_lock) (native_window_priv *, void *, int);
> +typedef int (*ptr_ANativeWindowPriv_dequeue) (native_window_priv *, void **);
> +typedef int (*ptr_ANativeWindowPriv_lock) (native_window_priv *, void *);
> typedef int (*ptr_ANativeWindowPriv_lockData) (native_window_priv *, void *, ANativeWindow_Buffer *);
> typedef int (*ptr_ANativeWindowPriv_unlockData) (native_window_priv *, void *);
> -typedef int (*ptr_ANativeWindowPriv_queue) (native_window_priv *, void *, int);
> -typedef int (*ptr_ANativeWindowPriv_cancel) (native_window_priv *, void *, int);
> +typedef int (*ptr_ANativeWindowPriv_queue) (native_window_priv *, void *);
> +typedef int (*ptr_ANativeWindowPriv_cancel) (native_window_priv *, void *);
> typedef int (*ptr_ANativeWindowPriv_setOrientation) (native_window_priv *, int);
>
> typedef struct
>
More information about the vlc-devel
mailing list