[vlc-devel] [PATCH 6/9] mkv: use a reference for the virtual_segment as we never prepare for a NULL one

Steve Lhomme robux4 at videolabs.io
Thu Mar 17 16:53:05 CET 2016


it is always done after PreloadLinked() which guarantees it's not NULL
assume we start at timestamp 0 on the first call
---
 modules/demux/mkv/demux.cpp | 10 +++++-----
 modules/demux/mkv/demux.hpp |  2 +-
 modules/demux/mkv/mkv.cpp   |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/modules/demux/mkv/demux.cpp b/modules/demux/mkv/demux.cpp
index 21ab2f4..4c6d1cc 100644
--- a/modules/demux/mkv/demux.cpp
+++ b/modules/demux/mkv/demux.cpp
@@ -776,15 +776,15 @@ void demux_sys_t::FreeUnused()
     }
 }
 
-bool demux_sys_t::PreparePlayback( virtual_segment_c *p_new_vsegment, mtime_t i_mk_date )
+bool demux_sys_t::PreparePlayback( virtual_segment_c & new_vsegment, mtime_t i_mk_date )
 {
-    if ( p_new_vsegment != NULL && p_new_vsegment != p_current_vsegment )
+    if ( p_current_vsegment != &new_vsegment )
     {
         if ( p_current_vsegment->CurrentSegment() != NULL )
             p_current_vsegment->CurrentSegment()->UnSelect();
 
-        p_current_vsegment = p_new_vsegment;
-        i_current_title = p_new_vsegment->i_sys_title;
+        p_current_vsegment = &new_vsegment;
+        i_current_title = p_current_vsegment->i_sys_title;
     }
     if( !p_current_vsegment->CurrentSegment() )
         return false;
@@ -809,7 +809,7 @@ void demux_sys_t::JumpTo( virtual_segment_c & vsegment, virtual_chapter_c & vcha
     // if the segment is not part of the current segment, select the new one
     if ( &vsegment != p_current_vsegment )
     {
-        PreparePlayback( &vsegment, vchapter.i_mk_virtual_start_time );
+        PreparePlayback( vsegment, vchapter.i_mk_virtual_start_time );
     }
 
     if ( !vchapter.p_chapter || !vchapter.p_chapter->Enter( true ) )
diff --git a/modules/demux/mkv/demux.hpp b/modules/demux/mkv/demux.hpp
index dd7c86e..f5b0b0d 100644
--- a/modules/demux/mkv/demux.hpp
+++ b/modules/demux/mkv/demux.hpp
@@ -383,7 +383,7 @@ public:
     void PreloadFamily( const matroska_segment_c & of_segment );
     bool PreloadLinked();
     void FreeUnused();
-    bool PreparePlayback( virtual_segment_c *p_new_vsegment, mtime_t i_mk_date = 0 );
+    bool PreparePlayback( virtual_segment_c & new_vsegment, mtime_t i_mk_date );
     matroska_stream_c *AnalyseAllSegmentsFound( demux_t *p_demux, EbmlStream *p_estream, bool b_initial = false );
     void JumpTo( virtual_segment_c & vsegment, virtual_chapter_c & vchapter );
 
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index 9901aa6..41da7e4 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -249,7 +249,7 @@ static int Open( vlc_object_t * p_this )
         msg_Warn( p_demux, "This file references other files, you may want to enable the preload of local directory");
 
     if ( !p_sys->PreloadLinked() ||
-         !p_sys->PreparePlayback( NULL ) )
+         !p_sys->PreparePlayback( *p_sys->p_current_vsegment, 0 ) )
     {
         msg_Err( p_demux, "cannot use the segment" );
         goto error;
-- 
2.7.1



More information about the vlc-devel mailing list