[vlc-devel] [PATCH 6/8] decoder: add VLCDEC_RELOAD status

Thomas Guillem thomas at gllm.fr
Wed Feb 8 19:53:53 CET 2017


This replaces the decoder_RequestReload() function.
---
 include/vlc_codec.h              | 11 ++++-------
 modules/codec/omxil/mediacodec.c |  7 ++++---
 modules/codec/videotoolbox.m     |  3 +--
 src/input/decoder.c              |  7 +++++--
 src/libvlccore.sym               |  1 -
 5 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index 24b18054de..0a7decfd3f 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -69,6 +69,7 @@ struct decoder_t
 
 #   define VLCDEC_SUCCESS   VLC_SUCCESS
 #   define VLCDEC_ECRITICAL VLC_EGENERIC
+#   define VLCDEC_RELOAD    (-100)
     /* This function is called to decode one packetized block.
      *
      * The module implementation will own the input block (p_block) and should
@@ -84,6 +85,8 @@ struct decoder_t
      *  VLCDEC_SUCCESS: pf_decode will be called again
      *  VLCDEC_ECRITICAL: in case of critical error, pf_decode won't be called
      *  again.
+     *  VLCDEC_RELOAD: Request that the decoder should be reloaded. The current
+     *  module will be unloaded. Reloading a module may cause a loss of frames.
      */
     int                 ( * pf_decode )   ( decoder_t *, block_t *p_block );
 
@@ -114,6 +117,7 @@ struct decoder_t
      * pf_packetize function will be called as long as the module return an
      * output block).
      */
+
     block_t *           ( * pf_packetize )( decoder_t *, block_t **pp_block );
     /* */
     void                ( * pf_flush ) ( decoder_t * );
@@ -352,13 +356,6 @@ VLC_API block_t * decoder_NewAudioBuffer( decoder_t *, int i_size ) VLC_USED;
  */
 VLC_API subpicture_t * decoder_NewSubpicture( decoder_t *, const subpicture_updater_t * ) VLC_USED;
 
-/*
- * Request that the decoder should be reloaded. The current module will be
- * unloaded. Reloading a module may cause a loss of frames. There is no
- * warranty that pf_decode_* callbacks won't be called again after this call.
- */
-VLC_API void decoder_RequestReload( decoder_t * );
-
 /**
  * This function gives all input attachments at once.
  *
diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 36bad57f5a..fa2d99492d 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -1576,13 +1576,14 @@ end:
     {
         if (!p_sys->b_has_format)
         {
+            vlc_mutex_unlock(&p_sys->lock);
             /* Add an empty variable so that mediacodec won't be loaded again
              * for this ES */
             if (var_Create(p_dec, "mediacodec-failed", VLC_VAR_VOID)
              == VLC_SUCCESS)
-                decoder_RequestReload(p_dec);
-            vlc_mutex_unlock(&p_sys->lock);
-            return VLCDEC_SUCCESS;
+                return VLCDEC_RELOAD;
+            else
+                return VLCDEC_SUCCESS;
         }
         else
         {
diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index a63b91748a..88be016216 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -1140,10 +1140,9 @@ reload:
     /* Add an empty variable so that videotoolbox won't be loaded again for
      * this ES */
     if (var_Create(p_dec, "videotoolbox-failed", VLC_VAR_VOID) == VLC_SUCCESS)
-        decoder_RequestReload(p_dec);
+        return VLCDEC_RELOAD;
     else
         return VLCDEC_ECRITICAL;
-    return VLCDEC_SUCCESS;
 }
 
 static int UpdateVideoFormat(decoder_t *p_dec, CVPixelBufferRef imageBuffer)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 596243cfaf..0ef8ea7ac6 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -620,7 +620,7 @@ subpicture_t *decoder_NewSubpicture( decoder_t *p_decoder,
     return p_subpicture;
 }
 
-void decoder_RequestReload( decoder_t * p_dec )
+static void RequestReload( decoder_t * p_dec )
 {
     decoder_owner_sys_t *p_owner = p_dec->p_owner;
     /* Don't override reload if it's RELOAD_DECODER_AOUT */
@@ -1103,7 +1103,7 @@ static int DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio,
         if( status == AOUT_DEC_CHANGED )
         {
             /* Only reload the decoder */
-            decoder_RequestReload( p_dec );
+            RequestReload( p_dec );
         }
         else if( status == AOUT_DEC_FAILED )
         {
@@ -1258,6 +1258,9 @@ static void DecoderDecode( decoder_t *p_dec, block_t *p_block )
         case VLCDEC_ECRITICAL:
             p_owner->error = true;
             break;
+        case VLCDEC_RELOAD:
+            RequestReload( p_dec );
+            break;
         default:
             vlc_assert_unreachable();
     }
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 7b9657a4b1..150409e073 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -81,7 +81,6 @@ decoder_GetDisplayRate
 decoder_GetInputAttachments
 decoder_NewAudioBuffer
 decoder_NewSubpicture
-decoder_RequestReload
 decoder_SynchroChoose
 decoder_SynchroDate
 decoder_SynchroDecode
-- 
2.11.0



More information about the vlc-devel mailing list