[vlc-commits] mkv: use a reference for the virtual_segment as we never prepare for a NULL one

Steve Lhomme git at videolan.org
Thu Mar 17 17:07:11 CET 2016


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Thu Mar 17 16:53:05 2016 +0100| [623f77ed4339b0aaa376b69d5c0a00b5f4535d6b] | committer: Jean-Baptiste Kempf

mkv: use a reference for the virtual_segment as we never prepare for a NULL one

it is always done after PreloadLinked() which guarantees it's not NULL
assume we start at timestamp 0 on the first call

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=623f77ed4339b0aaa376b69d5c0a00b5f4535d6b
---

 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 2ba131f..275a0cf 100644
--- a/modules/demux/mkv/demux.cpp
+++ b/modules/demux/mkv/demux.cpp
@@ -771,15 +771,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;
@@ -804,7 +804,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;



More information about the vlc-commits mailing list