File tree Expand file tree Collapse file tree 3 files changed +15
-23
lines changed Expand file tree Collapse file tree 3 files changed +15
-23
lines changed Original file line number Diff line number Diff line change @@ -432,7 +432,14 @@ long long BDRingBuffer::GetReadPosition(void) const
432432uint32_t BDRingBuffer::GetNumChapters (void )
433433{
434434 if (m_currentTitleInfo)
435- return m_currentTitleInfo->chapter_count ;
435+ return m_currentTitleInfo->chapter_count - 1 ;
436+ return 0 ;
437+ }
438+
439+ uint32_t BDRingBuffer::GetCurrentChapter (void )
440+ {
441+ if (bdnav)
442+ return bd_get_current_chapter (bdnav);
436443 return 0 ;
437444}
438445
@@ -516,7 +523,7 @@ bool BDRingBuffer::UpdateTitleInfo(uint32_t index)
516523 m_currentTitleAngleCount = m_currentTitleInfo->angle_count ;
517524 m_currentAngle = 0 ;
518525 m_titlesize = bd_get_title_size (bdnav);
519- uint32_t chapter_count = m_currentTitleInfo-> chapter_count ;
526+ uint32_t chapter_count = GetNumChapters () ;
520527 VERBOSE (VB_IMPORTANT, LOC + QString (" Selected title/playlist: index %1. "
521528 " Duration: %2 (%3 mins) "
522529 " Number of Chapters: %4 Number of Angles: %5 "
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ class MPUBLIC BDRingBuffer : public RingBuffer
7575 virtual long long GetReadPosition (void ) const ; // RingBuffer
7676 uint64_t GetTotalReadPosition (void );
7777 uint32_t GetNumChapters (void );
78+ uint32_t GetCurrentChapter (void );
7879 uint64_t GetNumAngles (void ) { return m_currentTitleAngleCount; }
7980 uint64_t GetChapterStartTime (uint32_t chapter);
8081 uint64_t GetChapterStartFrame (uint32_t chapter);
Original file line number Diff line number Diff line change @@ -95,32 +95,16 @@ void MythBDPlayer::EventStart(void)
9595
9696int MythBDPlayer::GetNumChapters (void )
9797{
98- int num = 0 ;
9998 if (player_ctx->buffer ->BD () && player_ctx->buffer ->BD ()->IsOpen ())
100- num = player_ctx->buffer ->BD ()->GetNumChapters ();
101- if (num > 1 )
102- return num;
103- return 0 ;
99+ return player_ctx->buffer ->BD ()->GetNumChapters ();
100+ return -1 ;
104101}
105102
106103int MythBDPlayer::GetCurrentChapter (void )
107104{
108- uint total = GetNumChapters ();
109- if (!total)
110- return 0 ;
111-
112- for (int i = (total - 1 ); i > -1 ; i--)
113- {
114- uint64_t frame = player_ctx->buffer ->BD ()->GetChapterStartFrame (i);
115- if (framesPlayed >= frame)
116- {
117- VERBOSE (VB_PLAYBACK, LOC +
118- QString (" GetCurrentChapter(selected chapter %1 framenum %2)" )
119- .arg (i + 1 ).arg (frame));
120- return i + 1 ;
121- }
122- }
123- return 0 ;
105+ if (player_ctx->buffer ->BD () && player_ctx->buffer ->BD ()->IsOpen ())
106+ return player_ctx->buffer ->BD ()->GetCurrentChapter () + 1 ;
107+ return -1 ;
124108}
125109
126110int64_t MythBDPlayer::GetChapter (int chapter)
You can’t perform that action at this time.
0 commit comments