[vlc-devel] [PATCH] Handle file with no duration or 0 duration

Denis Charmet typx at dinauz.org
Mon Feb 27 23:30:41 CET 2012


Should fix #6137
---
 modules/demux/mkv/matroska_segment.hpp       |    2 +-
 modules/demux/mkv/matroska_segment_parse.cpp |    3 ++-
 modules/demux/mkv/mkv.cpp                    |   12 ++++++++----
 modules/demux/mkv/virtual_segment.cpp        |    2 +-
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment.hpp b/modules/demux/mkv/matroska_segment.hpp
index 713f498..654e1c2 100644
--- a/modules/demux/mkv/matroska_segment.hpp
+++ b/modules/demux/mkv/matroska_segment.hpp
@@ -49,7 +49,7 @@ public:
     uint64_t                i_timescale;
 
     /* duration of the segment */
-    mtime_t                 i_duration;
+    int64_t                 i_duration;
     mtime_t                 i_start_time;
 
     /* all tracks */
diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index 422fad2..3c0662a 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -839,7 +839,8 @@ void matroska_segment_c::ParseInfo( KaxInfo *info )
     }
 
     double f_dur = double(i_duration) * double(i_timescale) / 1000000.0;
-    i_duration = mtime_t(f_dur);
+    if( f_dur >= 0.0 )
+        i_duration = int64_t(f_dur);
 }
 
 
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index e8a67ea..c48bd49 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -331,9 +331,13 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_SUCCESS;
 
         case DEMUX_SET_POSITION:
-            f = (double)va_arg( args, double );
-            Seek( p_demux, -1, f, NULL );
-            return VLC_SUCCESS;
+            if( p_sys->f_duration > 0.0 )
+            {
+                f = (double)va_arg( args, double );
+                Seek( p_demux, -1, f, NULL );
+                return VLC_SUCCESS;
+            }
+            return VLC_EGENERIC;
 
         case DEMUX_GET_TIME:
             pi64 = (int64_t*)va_arg( args, int64_t * );
@@ -430,7 +434,7 @@ static void Seek( demux_t *p_demux, mtime_t i_date, double f_percent, virtual_ch
         msg_Warn( p_demux, "cannot seek so far!" );
         return;
     }
-    if( p_sys->f_duration < 0 )
+    if( p_sys->f_duration <= 0 )
     {
         msg_Warn( p_demux, "cannot seek without duration!");
         return;
diff --git a/modules/demux/mkv/virtual_segment.cpp b/modules/demux/mkv/virtual_segment.cpp
index 6dd0463..e49bb3b 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -352,7 +352,7 @@ virtual_chapter_c* virtual_edition_c::getChapterbyTimecode( int64_t time )
     for( size_t i = 0; i < chapters.size(); i++ )
     {
         if( time >= chapters[i]->i_virtual_start_time &&
-            ( chapters[i]->i_virtual_stop_time < 0 || time < chapters[i]->i_virtual_stop_time ) )
+            ( chapters[i]->i_virtual_stop_time <= 0 || time < chapters[i]->i_virtual_stop_time ) )
             /*with the current implementation only the last chapter can have a negative virtual_stop_time*/
             return chapters[i]->getSubChapterbyTimecode( time );
     }
-- 
1.7.8.3




More information about the vlc-devel mailing list