[vlc-devel] [PATCH 1/8] decoder: initialise callbacks regarding of the fmt

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


---
 include/vlc_codec.h | 20 +++++---------------
 src/input/decoder.c | 15 ++++++++++++---
 2 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index af7b979fe2..eb4a5c3f41 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -24,6 +24,8 @@
 #ifndef VLC_CODEC_H
 #define VLC_CODEC_H 1
 
+#include <assert.h>
+
 #include <vlc_block.h>
 #include <vlc_es.h>
 #include <vlc_picture.h>
@@ -273,11 +275,7 @@ VLC_API void decoder_AbortPictures( decoder_t *dec, bool b_abort );
  */
 static inline int decoder_QueueVideo( decoder_t *dec, picture_t *p_pic )
 {
-    if( !dec->pf_queue_video )
-    {
-        picture_Release( p_pic );
-        return -1;
-    }
+    assert( dec->pf_queue_video != NULL );
     return dec->pf_queue_video( dec, p_pic );
 }
 
@@ -292,11 +290,7 @@ static inline int decoder_QueueVideo( decoder_t *dec, picture_t *p_pic )
  */
 static inline int decoder_QueueAudio( decoder_t *dec, block_t *p_aout_buf )
 {
-    if( !dec->pf_queue_audio )
-    {
-        block_Release( p_aout_buf );
-        return -1;
-    }
+    assert( dec->pf_queue_audio != NULL );
     return dec->pf_queue_audio( dec, p_aout_buf );
 }
 
@@ -311,11 +305,7 @@ static inline int decoder_QueueAudio( decoder_t *dec, block_t *p_aout_buf )
  */
 static inline int decoder_QueueSub( decoder_t *dec, subpicture_t *p_spu )
 {
-    if( !dec->pf_queue_sub )
-    {
-        subpicture_Delete( p_spu );
-        return -1;
-    }
+    assert( dec->pf_queue_sub != NULL );
     return dec->pf_queue_sub( dec, p_spu );
 }
 
diff --git a/src/input/decoder.c b/src/input/decoder.c
index c985bb4c4b..a9a3bcdd14 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1704,9 +1704,6 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
     p_dec->pf_get_attachments  = DecoderGetInputAttachments;
     p_dec->pf_get_display_date = DecoderGetDisplayDate;
     p_dec->pf_get_display_rate = DecoderGetDisplayRate;
-    p_dec->pf_queue_video = DecoderQueueVideo;
-    p_dec->pf_queue_audio = DecoderQueueAudio;
-    p_dec->pf_queue_sub = DecoderQueueSpu;
 
     /* Load a packetizer module if the input is not already packetized */
     if( p_sout == NULL && !fmt->b_packetized )
@@ -1732,6 +1729,18 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
     if( LoadDecoder( p_dec, p_sout != NULL, fmt ) )
         return p_dec;
 
+    switch( p_dec->fmt_out.i_cat )
+    {
+        case VIDEO_ES:
+            p_dec->pf_queue_video = DecoderQueueVideo;
+            break;
+        case AUDIO_ES:
+            p_dec->pf_queue_audio = DecoderQueueAudio;
+            break;
+        case SPU_ES:
+            p_dec->pf_queue_sub = DecoderQueueSpu;
+            break;
+    }
     /* Copy ourself the input replay gain */
     if( fmt->i_cat == AUDIO_ES )
     {
-- 
2.11.0



More information about the vlc-devel mailing list