demux/mkv: do not calculate duration for infinite clusters
[vlc.git] / modules / demux / mkv / matroska_segment.cpp
index 3e0bb4e..f2557a0 100644 (file)
@@ -686,7 +686,8 @@ bool matroska_segment_c::Preload( )
 
     b_preloaded = true;
 
-    EnsureDuration();
+    if( cluster == NULL || cluster->IsFiniteSize() )
+        EnsureDuration();
 
     return true;
 }
@@ -1026,6 +1027,12 @@ void matroska_segment_c::EnsureDuration()
             return;
         ParseCluster( p_last_cluster, false, SCOPE_PARTIAL_DATA );
 
+        if( p_last_cluster->IsFiniteSize() == false )
+        {
+            es.I_O().setFilePointer( i_current_position, seek_beginning );
+            return;
+        }
+
         // use the last block + duration
         uint64 i_last_timecode = p_last_cluster->GlobalTimecode();
         for( unsigned int i = 0; i < p_last_cluster->ListSize(); i++ )