[vlc-commits] demux:mkv: use CurrentEdition() where possible and check for NULL returns
Steve Lhomme
git at videolan.org
Wed Feb 14 16:48:22 CET 2018
vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Feb 14 14:06:04 2018 +0100| [9c4d7a42da0eba4ebc4757c3c227848548192000] | committer: Hugo Beauzée-Luyssen
demux:mkv: use CurrentEdition() where possible and check for NULL returns
(cherry picked from commit f75afcab241d3dc2ca5860460820ff858bdb558d)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=9c4d7a42da0eba4ebc4757c3c227848548192000
---
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 aea6937664..c06f429d98 100644
--- a/modules/demux/mkv/demux.cpp
+++ b/modules/demux/mkv/demux.cpp
@@ -614,7 +614,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 37a9708882..d7c7aded25 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -426,7 +426,7 @@ bool virtual_segment_c::UpdateCurrentToChapter( demux_t & demux )
{
demux_sys_t & sys = *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;
@@ -441,7 +441,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 );
}
@@ -520,9 +520,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 )
{
@@ -574,7 +574,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