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

android_window: render picture on Display, and not via pool.pic_unlock

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 00c28704
...@@ -619,7 +619,7 @@ static void CloseDecoder(vlc_object_t *p_this) ...@@ -619,7 +619,7 @@ static void CloseDecoder(vlc_object_t *p_this)
/***************************************************************************** /*****************************************************************************
* vout callbacks * 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; picture_sys_t *p_picsys = p_pic->p_sys;
decoder_t *p_dec = p_picsys->priv.hw.p_dec; decoder_t *p_dec = p_picsys->priv.hw.p_dec;
...@@ -637,7 +637,6 @@ static void UnlockPicture(picture_t* p_pic) ...@@ -637,7 +637,6 @@ static void UnlockPicture(picture_t* p_pic)
} }
uint32_t i_index = p_picsys->priv.hw.i_index; uint32_t i_index = p_picsys->priv.hw.i_index;
bool b_render = p_picsys->b_render;
p_sys->inflight_picture[i_index] = NULL; p_sys->inflight_picture[i_index] = NULL;
/* Release the MediaCodec buffer. */ /* Release the MediaCodec buffer. */
......
...@@ -96,7 +96,7 @@ static OMX_ERRORTYPE OmxFillBufferDone( OMX_HANDLETYPE, OMX_PTR, ...@@ -96,7 +96,7 @@ static OMX_ERRORTYPE OmxFillBufferDone( OMX_HANDLETYPE, OMX_PTR,
#if defined(USE_IOMX) #if defined(USE_IOMX)
static void *DequeueThread( void *data ); 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_Init( decoder_t *p_dec, OmxPort *p_port );
static void HwBuffer_Destroy( 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 ); static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port );
...@@ -2589,7 +2589,7 @@ static void *DequeueThread( void *data ) ...@@ -2589,7 +2589,7 @@ static void *DequeueThread( void *data )
/***************************************************************************** /*****************************************************************************
* vout callbacks * 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; picture_sys_t *p_picsys = p_pic->p_sys;
decoder_t *p_dec = p_picsys->priv.hw.p_dec; decoder_t *p_dec = p_picsys->priv.hw.p_dec;
...@@ -2610,7 +2610,7 @@ static void UnlockPicture( picture_t* p_pic ) ...@@ -2610,7 +2610,7 @@ static void UnlockPicture( picture_t* p_pic )
p_handle = p_port->pp_buffers[p_picsys->priv.hw.i_index]->pBuffer; p_handle = p_port->pp_buffers[p_picsys->priv.hw.i_index]->pBuffer;
OMX_DBG( "DisplayBuffer: %s %p", OMX_DBG( "DisplayBuffer: %s %p",
p_picsys->b_render ? "render" : "cancel", p_handle ); b_render ? "render" : "cancel", p_handle );
if( !p_handle ) if( !p_handle )
{ {
...@@ -2618,7 +2618,7 @@ static void UnlockPicture( picture_t* p_pic ) ...@@ -2618,7 +2618,7 @@ static void UnlockPicture( picture_t* p_pic )
goto end; goto end;
} }
if( p_picsys->b_render ) if( b_render )
p_port->p_hwbuf->anwpriv.queue( p_port->p_hwbuf->window_priv, p_handle ); 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 ); p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, p_handle );
......
...@@ -465,7 +465,8 @@ static int AndroidWindow_Setup(vout_display_sys_t *sys, ...@@ -465,7 +465,8 @@ static int AndroidWindow_Setup(vout_display_sys_t *sys,
static void AndroidWindow_UnlockPicture(vout_display_sys_t *sys, static void AndroidWindow_UnlockPicture(vout_display_sys_t *sys,
android_window *p_window, android_window *p_window,
picture_t *p_pic) picture_t *p_pic,
bool b_render)
{ {
picture_sys_t *p_picsys = p_pic->p_sys; picture_sys_t *p_picsys = p_pic->p_sys;
...@@ -475,8 +476,7 @@ static void AndroidWindow_UnlockPicture(vout_display_sys_t *sys, ...@@ -475,8 +476,7 @@ static void AndroidWindow_UnlockPicture(vout_display_sys_t *sys,
if (p_handle == NULL) if (p_handle == NULL)
return; return;
sys->anwp.unlockData(p_window->p_handle_priv, p_handle, sys->anwp.unlockData(p_window->p_handle_priv, p_handle, b_render);
p_picsys->b_render);
} else } else
sys->anw.unlockAndPost(p_window->p_handle); sys->anw.unlockAndPost(p_window->p_handle);
} }
...@@ -506,7 +506,7 @@ static int AndroidWindow_LockPicture(vout_display_sys_t *sys, ...@@ -506,7 +506,7 @@ static int AndroidWindow_LockPicture(vout_display_sys_t *sys,
p_picsys->priv.sw.buf.height < 0 || p_picsys->priv.sw.buf.height < 0 ||
(unsigned)p_picsys->priv.sw.buf.width < p_window->fmt.i_width || (unsigned)p_picsys->priv.sw.buf.width < p_window->fmt.i_width ||
(unsigned)p_picsys->priv.sw.buf.height < p_window->fmt.i_height) { (unsigned)p_picsys->priv.sw.buf.height < p_window->fmt.i_height) {
AndroidWindow_UnlockPicture(sys, p_window, p_pic); AndroidWindow_UnlockPicture(sys, p_window, p_pic, false);
return -1; return -1;
} }
...@@ -689,30 +689,36 @@ static int DefaultLockPicture(picture_t *p_pic) ...@@ -689,30 +689,36 @@ static int DefaultLockPicture(picture_t *p_pic)
return AndroidWindow_LockPicture(sys, sys->p_window, p_pic); return AndroidWindow_LockPicture(sys, sys->p_window, p_pic);
} }
static void DefaultUnlockPicture(picture_t *p_pic) static void DefaultUnlockPicture(picture_t *p_pic, bool b_render)
{ {
picture_sys_t *p_picsys = p_pic->p_sys; picture_sys_t *p_picsys = p_pic->p_sys;
vout_display_sys_t *sys = p_picsys->p_vd_sys; vout_display_sys_t *sys = p_picsys->p_vd_sys;
AndroidWindow_UnlockPicture(sys, sys->p_window, p_pic); AndroidWindow_UnlockPicture(sys, sys->p_window, p_pic, b_render);
} }
static int LockPicture(picture_t *p_pic) static void UnlockPicture(picture_t *p_pic, bool b_render)
{ {
picture_sys_t *p_picsys = p_pic->p_sys; picture_sys_t *p_picsys = p_pic->p_sys;
p_picsys->b_render = false; if (p_picsys->b_locked && p_picsys->pf_unlock_pic)
if (p_picsys->pf_lock_pic) p_picsys->pf_unlock_pic(p_pic, b_render);
return p_picsys->pf_lock_pic(p_pic); p_picsys->b_locked = false;
return 0;
} }
static void UnlockPicture(picture_t *p_pic) static int PoolLockPicture(picture_t *p_pic)
{ {
picture_sys_t *p_picsys = p_pic->p_sys; picture_sys_t *p_picsys = p_pic->p_sys;
if (p_picsys->pf_unlock_pic) if (p_picsys->pf_lock_pic && p_picsys->pf_lock_pic(p_pic) != 0)
p_picsys->pf_unlock_pic(p_pic); return -1;
p_picsys->b_locked = true;
return 0;
}
static void PoolUnlockPicture(picture_t *p_pic)
{
UnlockPicture(p_pic, false);
} }
static picture_pool_t *PoolAlloc(vout_display_t *vd, unsigned requested_count) static picture_pool_t *PoolAlloc(vout_display_t *vd, unsigned requested_count)
...@@ -750,8 +756,8 @@ static picture_pool_t *PoolAlloc(vout_display_t *vd, unsigned requested_count) ...@@ -750,8 +756,8 @@ static picture_pool_t *PoolAlloc(vout_display_t *vd, unsigned requested_count)
memset(&pool_cfg, 0, sizeof(pool_cfg)); memset(&pool_cfg, 0, sizeof(pool_cfg));
pool_cfg.picture_count = requested_count; pool_cfg.picture_count = requested_count;
pool_cfg.picture = pp_pics; pool_cfg.picture = pp_pics;
pool_cfg.lock = LockPicture; pool_cfg.lock = PoolLockPicture;
pool_cfg.unlock = UnlockPicture; pool_cfg.unlock = PoolUnlockPicture;
pool = picture_pool_NewExtended(&pool_cfg); pool = picture_pool_NewExtended(&pool_cfg);
error: error:
...@@ -804,7 +810,7 @@ static void SubpictureDisplay(vout_display_t *vd, subpicture_t *subpicture) ...@@ -804,7 +810,7 @@ static void SubpictureDisplay(vout_display_t *vd, subpicture_t *subpicture)
&sys->p_sub_pic->format); &sys->p_sub_pic->format);
picture_BlendSubpicture(sys->p_sub_pic, sys->p_spu_blend, subpicture); picture_BlendSubpicture(sys->p_sub_pic, sys->p_spu_blend, subpicture);
} }
AndroidWindow_UnlockPicture(sys, sys->p_sub_window, sys->p_sub_pic); AndroidWindow_UnlockPicture(sys, sys->p_sub_window, sys->p_sub_pic, true);
} }
static picture_pool_t *Pool(vout_display_t *vd, unsigned requested_count) static picture_pool_t *Pool(vout_display_t *vd, unsigned requested_count)
...@@ -820,10 +826,9 @@ static void Display(vout_display_t *vd, picture_t *picture, ...@@ -820,10 +826,9 @@ static void Display(vout_display_t *vd, picture_t *picture,
subpicture_t *subpicture) subpicture_t *subpicture)
{ {
vout_display_sys_t *sys = vd->sys; vout_display_sys_t *sys = vd->sys;
picture_sys_t *p_picsys = picture->p_sys;
/* refcount lowers to 0, and pool_cfg.unlock is called */ /* refcount lowers to 0, and pool_cfg.unlock is called */
p_picsys->b_render = true; UnlockPicture(picture, true);
picture_Release(picture); picture_Release(picture);
if (subpicture) { if (subpicture) {
......
...@@ -40,7 +40,7 @@ struct picture_sys_t ...@@ -40,7 +40,7 @@ struct picture_sys_t
vout_display_sys_t *p_vd_sys; vout_display_sys_t *p_vd_sys;
int (*pf_lock_pic)(picture_t *); int (*pf_lock_pic)(picture_t *);
void (*pf_unlock_pic)(picture_t *); void (*pf_unlock_pic)(picture_t *, bool b_render);
union { union {
struct { struct {
...@@ -53,7 +53,7 @@ struct picture_sys_t ...@@ -53,7 +53,7 @@ struct picture_sys_t
ANativeWindow_Buffer buf; ANativeWindow_Buffer buf;
} sw; } sw;
} priv; } priv;
bool b_render; bool b_locked;
}; };
#endif #endif
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