demux: mkv: do not use the file if there's no usable stream/segment
authorSteve Lhomme <robux4@ycbcr.xyz>
Wed, 24 Jul 2019 10:01:20 +0000 (12:01 +0200)
committerHugo Beauzée-Luyssen <hugo@beauzee.fr>
Wed, 14 Aug 2019 12:03:49 +0000 (14:03 +0200)
Ref #22474

Signed-off-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
modules/demux/mkv/demux.cpp
modules/demux/mkv/demux.hpp
modules/demux/mkv/mkv.cpp

index b2f6507..6fde3aa 100644 (file)
@@ -259,7 +259,7 @@ bool demux_sys_t::PreloadLinked()
     return true;
 }
 
-void demux_sys_t::FreeUnused()
+bool demux_sys_t::FreeUnused()
 {
     auto sIt = std::remove_if(begin(streams), end(streams), [](const matroska_stream_c* p_s) {
         return !p_s->isUsed();
@@ -275,6 +275,8 @@ void demux_sys_t::FreeUnused()
     for (auto it = sgIt; it != end(opened_segments); ++it)
         delete *it;
     opened_segments.erase(sgIt, end(opened_segments));
+
+    return !streams.empty() && !opened_segments.empty();
 }
 
 bool demux_sys_t::PreparePlayback( virtual_segment_c & new_vsegment, vlc_tick_t i_mk_date )
index 5004fc2..e684279 100644 (file)
@@ -99,7 +99,7 @@ public:
 
     void PreloadFamily( const matroska_segment_c & of_segment );
     bool PreloadLinked();
-    void FreeUnused();
+    bool FreeUnused();
     bool PreparePlayback( virtual_segment_c & new_vsegment, vlc_tick_t i_mk_date );
     bool AnalyseAllSegmentsFound( demux_t *p_demux, matroska_stream_c * );
     void JumpTo( virtual_segment_c & vsegment, virtual_chapter_c & vchapter );
index c452d07..1b055ce 100644 (file)
@@ -254,7 +254,11 @@ static int Open( vlc_object_t * p_this )
         goto error;
     }
 
-    p_sys->FreeUnused();
+    if (!p_sys->FreeUnused())
+    {
+        msg_Err( p_demux, "no usable segment" );
+        goto error;
+    }
 
     return VLC_SUCCESS;