[vlc-devel] [PATCH 6/8] mediacodec: do not sleep waiting for pictures anymore

Steve Lhomme robux4 at ycbcr.xyz
Tue Jul 28 11:08:39 CEST 2020


We have a pool of 64 surfaces but the decoder will only request less than that.
We let the decoder decide how many pictures it wants depending on the codec
and provide surfaces when it has an available picture.

This works because we do the decoder_NewPicture(), possibly blocking for an
available picture, before attaching the picture context of the surface.
---
 modules/codec/omxil/mediacodec.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 05582c9fccc..b546b250ba1 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -586,10 +586,7 @@ static struct android_picture_ctx *
 GetPictureContext(decoder_t *p_dec, unsigned index)
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
-    bool slept = false;
 
-    for (;;)
-    {
         for (size_t i = 0; i < ARRAY_SIZE(p_sys->video.apic_ctxs); ++i)
         {
             struct android_picture_ctx *apctx = &p_sys->video.apic_ctxs[i];
@@ -610,14 +607,7 @@ GetPictureContext(decoder_t *p_dec, unsigned index)
                 atomic_store(&apctx->refs, 0);
             }
         }
-
-        /* This is very unlikely since there are generally more picture
-         * contexts than android MediaCodec buffers */
-        if (!slept)
-            msg_Warn(p_dec, "waiting for more picture contexts (unlikely)");
-        vlc_tick_sleep(VOUT_OUTMEM_SLEEP);
-        slept = true;
-    }
+        vlc_assert_unreachable();
 }
 
 static int
-- 
2.26.2



More information about the vlc-devel mailing list