[vlc-devel] [PATCH 1/2] vout: android: only use a local pool for opaque surfaces

Steve Lhomme robux4 at ycbcr.xyz
Wed Jul 31 12:21:10 CEST 2019


For non-opaque we copy in a local surface during prepare. It was already using
a single surface exposed as a pool. We do not use a pool in this case anymore.

We can remove is_slow as the core allocates its own "fast" pool in this case.
---
 modules/video_output/android/display.c | 50 +++++++++++++++++---------
 1 file changed, 34 insertions(+), 16 deletions(-)

diff --git a/modules/video_output/android/display.c b/modules/video_output/android/display.c
index edf335a8c7..195cdb8e80 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -121,6 +121,8 @@ struct vout_display_sys_t
     android_window *p_window;
     android_window *p_sub_window;
 
+    picture_t *p_prepared_pic; // local surface
+
     bool b_displayed;
     bool b_sub_invalid;
     filter_t *p_spu_blend;
@@ -600,12 +602,28 @@ static int OpenCommon(vout_display_t *vd, const vout_display_cfg_t *cfg,
 
     *fmtp = fmt;
     /* Setup vout_display */
-    vd->pool    = Pool;
+    if (sys->p_window->b_opaque)
+        vd->pool    = Pool;
+    else
+    {
+        if (AndroidWindow_Setup(sys, sys->p_window, 1) != 0)
+            goto error;
+
+        sys->p_prepared_pic = PictureAlloc(sys, &sys->p_window->fmt, false);
+        if (sys->p_prepared_pic == NULL)
+        {
+            msg_Err(vd, "cannot allocate prepare surface");
+            goto error;
+        }
+        msg_Dbg(vd, "PictureAlloc: got a frame");
+
+        UpdateVideoSize(sys, &sys->p_window->fmt);
+    }
+
     vd->prepare = Prepare;
     vd->display = Display;
     vd->control = Control;
     vd->close = Close;
-    vd->info.is_slow = !sys->p_window->b_opaque;
 
     return VLC_SUCCESS;
 
@@ -711,6 +729,8 @@ static void Close(vout_display_t *vd)
         AndroidWindow_Destroy(vd, sys->p_window);
     }
 
+    if (sys->p_prepared_pic)
+        picture_Release(sys->p_prepared_pic);
     if (sys->p_sub_pic)
         picture_Release(sys->p_sub_pic);
     if (sys->p_spu_blend)
@@ -779,8 +799,7 @@ static picture_pool_t *PoolAlloc(vout_display_t *vd, unsigned requested_count)
 
     for (i = 0; i < requested_count; i++)
     {
-        picture_t *p_pic = PictureAlloc(sys, &sys->p_window->fmt,
-                                        sys->p_window->b_opaque);
+        picture_t *p_pic = PictureAlloc(sys, &sys->p_window->fmt, true);
         if (!p_pic)
             goto error;
 
@@ -791,16 +810,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;
-    if (sys->p_window->b_opaque)
-    {
-        pool_cfg.lock      = PoolLockOpaquePicture;
-        pool_cfg.unlock    = PoolUnlockOpaquePicture;
-    }
-    else
-    {
-        pool_cfg.lock      = PoolLockPicture;
-        pool_cfg.unlock    = PoolUnlockPicture;
-    }
+    pool_cfg.lock      = PoolLockOpaquePicture;
+    pool_cfg.unlock    = PoolUnlockOpaquePicture;
     pool = picture_pool_NewExtended(&pool_cfg);
 
 error:
@@ -950,6 +961,15 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
 {
     vout_display_sys_t *sys = vd->sys;
 
+    if (!sys->p_window->b_opaque)
+    {
+        if (PoolLockPicture(sys->p_prepared_pic) == 0)
+        {
+            picture_Copy(sys->p_prepared_pic, picture);
+            PoolUnlockPicture(sys->p_prepared_pic);
+        }
+    }
+
     if (subpicture && sys->p_sub_window) {
         if (sys->b_sub_invalid) {
             sys->b_sub_invalid = false;
@@ -1009,8 +1029,6 @@ static void Display(vout_display_t *vd, picture_t *picture)
 
     if (sys->p_window->b_opaque)
         AndroidOpaquePicture_Release(picture->p_sys, true);
-    else
-        AndroidWindow_UnlockPicture(sys, sys->p_window, picture);
 
     if (sys->p_sub_pic)
         AndroidWindow_UnlockPicture(sys, sys->p_sub_window, sys->p_sub_pic);
-- 
2.17.1



More information about the vlc-devel mailing list