[vlc-commits] demux:mkv: use CurrentEdition() where possible and check for NULL returns
Steve Lhomme
git at videolan.org
Wed Feb 14 15:22:17 CET 2018
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Feb 14 14:06:04 2018 +0100| [f75afcab241d3dc2ca5860460820ff858bdb558d] | committer: Steve Lhomme
demux:mkv: use CurrentEdition() where possible and check for NULL returns
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f75afcab241d3dc2ca5860460820ff858bdb558d
---
modules/demux/mkv/demux.cpp | 2 +-
modules/demux/mkv/virtual_segment.cpp | 12 +++++++-----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/modules/demux/mkv/demux.cpp b/modules/demux/mkv/demux.cpp
index c8584b1b71..36c4d35889 100644
--- a/modules/demux/mkv/demux.cpp
+++ b/modules/demux/mkv/demux.cpp
@@ -617,7 +617,7 @@ bool demux_sys_t::PreloadLinked()
return false;
/* Set current chapter */
- p_current_vsegment->p_current_vchapter = p_current_vsegment->veditions[p_current_vsegment->i_current_edition]->getChapterbyTimecode(0);
+ p_current_vsegment->p_current_vchapter = p_current_vsegment->CurrentEdition()->getChapterbyTimecode(0);
msg_Dbg( &demuxer, "NEW START CHAPTER uid=%" PRId64, p_current_vsegment->p_current_vchapter && p_current_vsegment->p_current_vchapter->p_chapter ?
p_current_vsegment->p_current_vchapter->p_chapter->i_uid : 0 );
diff --git a/modules/demux/mkv/virtual_segment.cpp b/modules/demux/mkv/virtual_segment.cpp
index b5a9f5a033..d7c9836d4a 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -420,7 +420,7 @@ bool virtual_segment_c::UpdateCurrentToChapter( demux_t & demux )
{
demux_sys_t & sys = *(demux_sys_t *)demux.p_sys;
virtual_chapter_c *p_cur_vchapter = NULL;
- virtual_edition_c *p_cur_vedition = veditions[ i_current_edition ];
+ virtual_edition_c *p_cur_vedition = CurrentEdition();
bool b_has_seeked = false;
@@ -435,7 +435,7 @@ bool virtual_segment_c::UpdateCurrentToChapter( demux_t & demux )
{
if ( p_current_vchapter != NULL && p_current_vchapter->ContainsTimestamp( sys.i_pts - VLC_TS_0 ))
p_cur_vchapter = p_current_vchapter;
- else
+ else if (p_cur_vedition != NULL)
p_cur_vchapter = p_cur_vedition->getChapterbyTimecode( sys.i_pts - VLC_TS_0 );
}
@@ -514,9 +514,9 @@ bool virtual_segment_c::Seek( demux_t & demuxer, mtime_t i_mk_date,
/* find the actual time for an ordered edition */
- if ( p_vchapter == NULL )
+ if ( p_vchapter == NULL && CurrentEdition() )
/* 1st, we need to know in which chapter we are */
- p_vchapter = veditions[ i_current_edition ]->getChapterbyTimecode( i_mk_date );
+ p_vchapter = CurrentEdition()->getChapterbyTimecode( i_mk_date );
if ( p_vchapter != NULL )
{
@@ -568,7 +568,9 @@ virtual_chapter_c * virtual_chapter_c::FindChapter( int64_t i_find_uid )
virtual_chapter_c * virtual_segment_c::FindChapter( int64_t i_find_uid )
{
- virtual_edition_c * p_edition = veditions[i_current_edition];
+ virtual_edition_c * p_edition = CurrentEdition();
+ if (unlikely(p_edition == NULL))
+ return NULL;
for( size_t i = 0; i < p_edition->vchapters.size(); i++ )
{
More information about the vlc-commits
mailing list