[vlc-devel] [PATCH 4/8] mkv:matroska_segment: handle track init failure

Steve Lhomme robux4 at videolabs.io
Mon Jul 31 15:02:56 CEST 2017


We should not use a track that failed to be initialized properly.
The logic of the return value is inverted to be more readable. Before
it would never fail anyway.
---
 modules/demux/mkv/matroska_segment.hpp       | 2 +-
 modules/demux/mkv/matroska_segment_parse.cpp | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment.hpp b/modules/demux/mkv/matroska_segment.hpp
index 5c81ae65c2..b2116b7c36 100644
--- a/modules/demux/mkv/matroska_segment.hpp
+++ b/modules/demux/mkv/matroska_segment.hpp
@@ -166,7 +166,7 @@ private:
     bool ParseCluster( KaxCluster *cluster, bool b_update_start_time = true, ScopeMode read_fully = SCOPE_ALL_DATA );
     bool ParseSimpleTags( SimpleTag* out, KaxTagSimple *tag, int level = 50 );
     void IndexAppendCluster( KaxCluster *cluster );
-    int32_t TrackInit( mkv_track_t * p_tk );
+    bool TrackInit( mkv_track_t * p_tk );
     void ComputeTrackPriority();
     void EnsureDuration();
 
diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index 7fa5da49cc..71c174155b 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -692,7 +692,7 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
             return;
         }
 #endif
-        if( TrackInit( &track ) )
+        if( !TrackInit( &track ) )
         {
             msg_Err(&sys.demuxer, "Couldn't init track %u", track.i_number );
             es_format_Clean( &track.fmt );
@@ -1286,13 +1286,13 @@ bool matroska_segment_c::ParseCluster( KaxCluster *cluster, bool b_update_start_
 }
 
 
-int32_t matroska_segment_c::TrackInit( mkv_track_t * p_tk )
+bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
 {
     if( p_tk->codec.empty() )
     {
         msg_Err( &sys.demuxer, "Empty codec id" );
         p_tk->fmt.i_codec = VLC_CODEC_UNKNOWN;
-        return 0;
+        return true;
     }
 
     struct HandlerPayload {
@@ -1891,7 +1891,8 @@ int32_t matroska_segment_c::TrackInit( mkv_track_t * p_tk )
     {
         msg_Err( &sys.demuxer, "Error when trying to initiate track (codec: %s): %s",
           p_tk->codec.c_str(), e.what () );
+        return false;
     }
 
-    return 0;
+    return true;
 }
-- 
2.12.1



More information about the vlc-devel mailing list