[vlc-commits] mediacodec: release pictures after decoder close

Alexandre Janniaux git at videolan.org
Thu Mar 4 17:12:01 UTC 2021


vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Tue Feb 16 14:46:39 2021 +0100| [1fa05cf40605a459c6a256a2073c96b9ac21c15f] | committer: Alexandre Janniaux

mediacodec: release pictures after decoder close

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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1fa05cf40605a459c6a256a2073c96b9ac21c15f
---

 modules/codec/omxil/mediacodec.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 07e1107879..2bcc27c704 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -115,6 +115,11 @@ typedef struct decoder_sys_t
     bool            b_aborted;
     bool            b_drained;
     bool            b_adaptive;
+
+    /* If true, the decoder_t object has been closed and decoder_* functions
+     * are now unavailable. */
+    bool            b_decoder_dead;
+
     int             i_decode_flags;
 
     enum es_format_category_e cat;
@@ -846,6 +851,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_decoder_dead = false;
 
     if (pf_init(&p_sys->api) != 0)
     {
@@ -1058,6 +1064,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 +1423,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_decoder_dead)
         {
             /* 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. */



More information about the vlc-commits mailing list