[vlc-devel] [PATCH 2/3] mediacodec: release pictures after decoder close

Alexandre Janniaux ajanni at videolabs.io
Tue Feb 16 13:46:39 UTC 2021


Avoid trying to queue picture after the closing of the decoder. Indeed,
the mediacodec loop cannot be killed yet at the decoder close function
because it is still needed for the integrity of the picture still used
in the pipeline.
---
 modules/codec/omxil/mediacodec.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 07e1107879..df0afad13e 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -115,6 +115,7 @@ typedef struct decoder_sys_t
     bool            b_aborted;
     bool            b_drained;
     bool            b_adaptive;
+    bool            b_closed;
     int             i_decode_flags;
 
     enum es_format_category_e cat;
@@ -846,6 +847,7 @@ static int OpenDecoder(vlc_object_t *p_this, pf_MediaCodecApi_init pf_init)
     p_sys->video.i_mpeg_dar_num = 0;
     p_sys->video.i_mpeg_dar_den = 0;
     p_sys->video.surfacetexture = NULL;
+    p_sys->b_closed = false;
 
     if (pf_init(&p_sys->api) != 0)
     {
@@ -1058,6 +1060,8 @@ static void CloseDecoder(vlc_object_t *p_this)
     decoder_sys_t *p_sys = p_dec->p_sys;
 
     vlc_mutex_lock(&p_sys->lock);
+    p_sys->b_closed = true;
+
     /* Unblock output thread waiting in dequeue_out */
     DecodeFlushLocked(p_sys);
     /* Cancel the output thread */
@@ -1415,8 +1419,9 @@ static void *OutThread(void *data)
 
         vlc_mutex_lock(&p_sys->lock);
 
-        /* Ignore dequeue_out errors caused by flush */
-        if (p_sys->b_flush_out)
+        /* Ignore dequeue_out errors caused by flush, or late picture being
+         * dequeued after close. */
+        if (p_sys->b_flush_out || p_sys->b_closed)
         {
             /* If i_index >= 0, Release it. There is no way to know if i_index
              * is owned by us, so don't check the error. */
-- 
2.30.1



More information about the vlc-devel mailing list