[vlc-devel] [PATCH] android_window: render picture on Display, and not via pool.pic_unlock
Thomas Guillem
thomas at gllm.fr
Thu Nov 20 15:36:50 CET 2014
---
modules/codec/omxil/android_mediacodec.c | 3 +-
modules/codec/omxil/omxil.c | 8 ++---
modules/video_output/android/android_window.c | 42 +++++++++++++++------------
modules/video_output/android/android_window.h | 4 +--
4 files changed, 31 insertions(+), 26 deletions(-)
diff --git a/modules/codec/omxil/android_mediacodec.c b/modules/codec/omxil/android_mediacodec.c
index 5cc0e27..00bea88 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -619,7 +619,7 @@ static void CloseDecoder(vlc_object_t *p_this)
/*****************************************************************************
* 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;
@@ -637,7 +637,6 @@ static void UnlockPicture(picture_t* p_pic)
}
uint32_t i_index = p_picsys->priv.hw.i_index;
- bool b_render = p_picsys->b_render;
p_sys->inflight_picture[i_index] = NULL;
/* Release the MediaCodec buffer. */
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 95abfb2..03814d0 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -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 );
@@ -2589,7 +2589,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 +2610,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,7 +2618,7 @@ static void UnlockPicture( picture_t* p_pic )
goto end;
}
- if( p_picsys->b_render )
+ 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 );
diff --git a/modules/video_output/android/android_window.c b/modules/video_output/android/android_window.c
index 644fa9e..bff8884 100644
--- a/modules/video_output/android/android_window.c
+++ b/modules/video_output/android/android_window.c
@@ -465,7 +465,8 @@ static int AndroidWindow_Setup(vout_display_sys_t *sys,
static void AndroidWindow_UnlockPicture(vout_display_sys_t *sys,
android_window *p_window,
- picture_t *p_pic)
+ picture_t *p_pic,
+ bool b_render)
{
picture_sys_t *p_picsys = p_pic->p_sys;
@@ -475,8 +476,7 @@ static void AndroidWindow_UnlockPicture(vout_display_sys_t *sys,
if (p_handle == NULL)
return;
- sys->anwp.unlockData(p_window->p_handle_priv, p_handle,
- p_picsys->b_render);
+ sys->anwp.unlockData(p_window->p_handle_priv, p_handle, b_render);
} else
sys->anw.unlockAndPost(p_window->p_handle);
}
@@ -506,7 +506,7 @@ static int AndroidWindow_LockPicture(vout_display_sys_t *sys,
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.height < p_window->fmt.i_height) {
- AndroidWindow_UnlockPicture(sys, p_window, p_pic);
+ AndroidWindow_UnlockPicture(sys, p_window, p_pic, false);
return -1;
}
@@ -689,30 +689,36 @@ static int DefaultLockPicture(picture_t *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;
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;
- p_picsys->b_render = false;
- if (p_picsys->pf_lock_pic)
- return p_picsys->pf_lock_pic(p_pic);
- return 0;
+ if (p_picsys->b_locked && p_picsys->pf_unlock_pic)
+ p_picsys->pf_unlock_pic(p_pic, b_render);
+ p_picsys->b_locked = false;
}
-static void UnlockPicture(picture_t *p_pic)
+static int PoolLockPicture(picture_t *p_pic)
{
picture_sys_t *p_picsys = p_pic->p_sys;
- if (p_picsys->pf_unlock_pic)
- p_picsys->pf_unlock_pic(p_pic);
+ if (p_picsys->pf_lock_pic && p_picsys->pf_lock_pic(p_pic) != 0)
+ 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)
@@ -750,8 +756,8 @@ static picture_pool_t *PoolAlloc(vout_display_t *vd, unsigned requested_count)
memset(&pool_cfg, 0, sizeof(pool_cfg));
pool_cfg.picture_count = requested_count;
pool_cfg.picture = pp_pics;
- pool_cfg.lock = LockPicture;
- pool_cfg.unlock = UnlockPicture;
+ pool_cfg.lock = PoolLockPicture;
+ pool_cfg.unlock = PoolUnlockPicture;
pool = picture_pool_NewExtended(&pool_cfg);
error:
@@ -804,7 +810,7 @@ static void SubpictureDisplay(vout_display_t *vd, subpicture_t *subpicture)
&sys->p_sub_pic->format);
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)
@@ -823,7 +829,7 @@ static void Display(vout_display_t *vd, picture_t *picture,
picture_sys_t *p_picsys = picture->p_sys;
/* refcount lowers to 0, and pool_cfg.unlock is called */
- p_picsys->b_render = true;
+ UnlockPicture(picture, true);
picture_Release(picture);
if (subpicture) {
diff --git a/modules/video_output/android/android_window.h b/modules/video_output/android/android_window.h
index 68101c8..3aa4921 100644
--- a/modules/video_output/android/android_window.h
+++ b/modules/video_output/android/android_window.h
@@ -40,7 +40,7 @@ struct picture_sys_t
vout_display_sys_t *p_vd_sys;
int (*pf_lock_pic)(picture_t *);
- void (*pf_unlock_pic)(picture_t *);
+ void (*pf_unlock_pic)(picture_t *, bool b_render);
union {
struct {
@@ -53,7 +53,7 @@ struct picture_sys_t
ANativeWindow_Buffer buf;
} sw;
} priv;
- bool b_render;
+ bool b_locked;
};
#endif
--
2.1.1
More information about the vlc-devel
mailing list