aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Zelend <ace20022@xbmc.org>2015-03-05 23:19:11 +0100
committerAndreas Zelend <ace20022@xbmc.org>2015-03-05 23:19:11 +0100
commit3750af8a76be125455025157ab9ac47594dabb0c (patch)
treeb30ad4992bb0ecdc03300fa09420d1a769340ace
parent8b9542169f87f5be10103bf1abbcfa373f63ee91 (diff)
parent75d0327fe7ea929bebf4b6fe302c2aae3dc13445 (diff)
Merge pull request #6610 from ace20022/dvd_chapters
[Fix] fixed broken dvd playback after pr #6415
-rw-r--r--xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp43
-rw-r--r--xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.h2
2 files changed, 30 insertions, 15 deletions
diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
index c7a6e4c159..708fc26fec 100644
--- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
+++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
@@ -471,6 +471,27 @@ int CDVDInputStreamNavigator::ProcessBlock(uint8_t* dest_buffer, int* read)
m_iPartCount = 0;
m_dll.dvdnav_get_position(m_dvdnav, &pos, &len);
+ // get chapters' timestamps if we have not cached them yet
+ if (m_mapTitleChapters.find(m_iTitle) == m_mapTitleChapters.end())
+ {
+ uint64_t* times = NULL;
+ uint64_t duration;
+ unsigned int entries = m_dll.dvdnav_describe_title_chapters(m_dvdnav, m_iTitle, &times, &duration);
+
+ if (entries != m_iPartCount)
+ CLog::Log(LOGDEBUG, "%s - Number of chapters/positions differ: Chapters %d, positions %d\n", __FUNCTION__, m_iPartCount, entries);
+
+ if (times)
+ {
+ // the times array stores the end timestampes of the chapters, e.g., times[0] stores the position/beginning of chapter 2
+ m_mapTitleChapters[m_iTitle][1] = 0;
+ for (int i = 0; i < entries - 1; ++i)
+ {
+ m_mapTitleChapters[m_iTitle][i + 2] = times[i] / 90000;
+ }
+ m_dll.dvdnav_free(times);
+ }
+ }
CLog::Log(LOGDEBUG, "%s - Cell change: Title %d, Chapter %d\n", __FUNCTION__, m_iTitle, m_iPart);
CLog::Log(LOGDEBUG, "%s - At position %.0f%% inside the feature\n", __FUNCTION__, 100 * (double)pos / (double)len);
//Get total segment time
@@ -1461,20 +1482,12 @@ int64_t CDVDInputStreamNavigator::GetChapterPos(int ch)
if (ch == -1 || ch > GetChapterCount())
ch = GetChapter();
- if (ch <= 1)
- return 0;
-
- uint64_t* times = NULL;
- uint64_t duration;
-
- m_dll.dvdnav_describe_title_chapters(m_dvdnav, m_iTitle, &times, &duration);
-
- int64_t result = 0;
-
- if (times)
+ std::map<int, std::map<int, int64_t>>::iterator title = m_mapTitleChapters.find(m_iTitle);
+ if (title != m_mapTitleChapters.end())
{
- result = times[ch - 2] / 90000;
- m_dll.dvdnav_free(times);
- }
- return result;
+ std::map<int, int64_t>::iterator chapter = title->second.find(ch);
+ if (chapter != title->second.end())
+ return chapter->second;
+ }
+ return 0;
}
diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.h b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.h
index d7e967cf21..cc23de2915 100644
--- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.h
+++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.h
@@ -194,5 +194,7 @@ protected:
uint8_t m_lastblock[DVD_VIDEO_BLOCKSIZE];
int m_lastevent;
+
+ std::map<int, std::map<int, int64_t>> m_mapTitleChapters;
};