[vlc-devel] [PATCH] demux:mkv: do not look for seekpoints for each track on startup
Steve Lhomme
robux4 at videolabs.io
Mon Aug 7 11:05:55 CEST 2017
If there are subtitle tracks selected we might look for a while. We just want
to start playing at that point.
---
modules/demux/mkv/demux.cpp | 8 +++++---
modules/demux/mkv/demux.hpp | 3 ++-
modules/demux/mkv/mkv.cpp | 4 ++--
modules/demux/mkv/virtual_segment.cpp | 6 ++++--
modules/demux/mkv/virtual_segment.hpp | 3 ++-
5 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/modules/demux/mkv/demux.cpp b/modules/demux/mkv/demux.cpp
index 56248e8f30..e531ec8518 100644
--- a/modules/demux/mkv/demux.cpp
+++ b/modules/demux/mkv/demux.cpp
@@ -785,7 +785,8 @@ void demux_sys_t::FreeUnused()
}
}
-bool demux_sys_t::PreparePlayback( virtual_segment_c & new_vsegment, mtime_t i_mk_date )
+bool demux_sys_t::PreparePlayback( virtual_segment_c & new_vsegment, mtime_t i_mk_date,
+ bool look_for_seekpos )
{
if ( p_current_vsegment != &new_vsegment )
{
@@ -808,8 +809,9 @@ bool demux_sys_t::PreparePlayback( virtual_segment_c & new_vsegment, mtime_t i_m
p_current_vsegment->CurrentSegment()->ESCreate( );
/* Seek to the beginning */
- p_current_vsegment->Seek(p_current_vsegment->CurrentSegment()->sys.demuxer,
- i_mk_date, p_current_vsegment->p_current_vchapter );
+ p_current_vsegment->Seek( p_current_vsegment->CurrentSegment()->sys.demuxer,
+ i_mk_date, p_current_vsegment->p_current_vchapter,
+ look_for_seekpos );
return true;
}
diff --git a/modules/demux/mkv/demux.hpp b/modules/demux/mkv/demux.hpp
index f5b0b0d9db..68e7301698 100644
--- a/modules/demux/mkv/demux.hpp
+++ b/modules/demux/mkv/demux.hpp
@@ -383,7 +383,8 @@ public:
void PreloadFamily( const matroska_segment_c & of_segment );
bool PreloadLinked();
void FreeUnused();
- bool PreparePlayback( virtual_segment_c & new_vsegment, mtime_t i_mk_date );
+ bool PreparePlayback( virtual_segment_c & new_vsegment, mtime_t i_mk_date,
+ bool look_for_seekpos = true );
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 544f42568f..1da5261c9a 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( *p_sys->p_current_vsegment, 0 ) )
+ !p_sys->PreparePlayback( *p_sys->p_current_vsegment, 0, false ) )
{
msg_Err( p_demux, "cannot use the segment" );
goto error;
@@ -488,7 +488,7 @@ static int Seek( demux_t *p_demux, mtime_t i_mk_date, double f_percent, virtual_
{
i_mk_date = int64_t( f_percent * p_sys->f_duration * 1000.0 );
}
- return p_vsegment->Seek( *p_demux, i_mk_date, p_vchapter, b_precise ) ? VLC_SUCCESS : VLC_EGENERIC;
+ return p_vsegment->Seek( *p_demux, i_mk_date, p_vchapter, true, b_precise ) ? VLC_SUCCESS : VLC_EGENERIC;
}
/* Needed by matroska_segment::Seek() and Seek */
diff --git a/modules/demux/mkv/virtual_segment.cpp b/modules/demux/mkv/virtual_segment.cpp
index a3b2e34127..e0f5dd8bfb 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -514,7 +514,8 @@ bool virtual_chapter_c::EnterAndLeave( virtual_chapter_c *p_leaving_vchapter, bo
}
bool virtual_segment_c::Seek( demux_t & demuxer, mtime_t i_mk_date,
- virtual_chapter_c *p_vchapter, bool b_precise )
+ virtual_chapter_c *p_vchapter, bool do_seek,
+ bool b_precise )
{
demux_sys_t *p_sys = demuxer.p_sys;
@@ -547,7 +548,7 @@ bool virtual_segment_c::Seek( demux_t & demuxer, mtime_t i_mk_date,
p_sys->PreparePlayback( *this, i_mk_date );
return true;
}
- else
+ if ( do_seek )
{
typedef bool( matroska_segment_c::* seek_callback_t )( demux_t &, mtime_t, mtime_t );
@@ -560,6 +561,7 @@ bool virtual_segment_c::Seek( demux_t & demuxer, mtime_t i_mk_date,
return ( p_current_vchapter->segment.*pf_seek )( demuxer, i_mk_date, i_mk_time_offset );
}
+ return true;
}
return false;
}
diff --git a/modules/demux/mkv/virtual_segment.hpp b/modules/demux/mkv/virtual_segment.hpp
index cd9dd2ae06..a3b6376fa3 100644
--- a/modules/demux/mkv/virtual_segment.hpp
+++ b/modules/demux/mkv/virtual_segment.hpp
@@ -160,7 +160,8 @@ public:
virtual_chapter_c * FindChapter( int64_t i_find_uid );
bool UpdateCurrentToChapter( demux_t & demux );
- bool Seek( demux_t & demuxer, mtime_t i_mk_date, virtual_chapter_c *p_vchapter, bool b_precise = true );
+ bool Seek( demux_t & demuxer, mtime_t i_mk_date, virtual_chapter_c *p_vchapter,
+ bool do_seek = true, bool b_precise = true );
private:
void KeepTrackSelection( matroska_segment_c & old, matroska_segment_c & next );
};
--
2.12.1
More information about the vlc-devel
mailing list