Skip to content

Commit b2da233

Browse files
committed
Cleanups to chapter methods
1 parent 8201442 commit b2da233

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/Session.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,15 +1124,15 @@ int CSession::GetChapter() const
11241124
}
11251125
}
11261126
}
1127-
return -1;
1127+
return 0;
11281128
}
11291129

11301130
int SESSION::CSession::GetChapterCount() const
11311131
{
1132-
if (m_adaptiveTree && m_adaptiveTree->m_periods.size() > 1)
1133-
return static_cast<int>(m_adaptiveTree->m_periods.size());
1132+
if (!m_adaptiveTree)
1133+
return 0;
11341134

1135-
return 0;
1135+
return static_cast<int>(m_adaptiveTree->m_periods.size());
11361136
}
11371137

11381138
const char* SESSION::CSession::GetChapterName(int ch) const

src/main.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,12 +490,21 @@ bool CInputStreamAdaptive::IsRealTimeStream()
490490
#if INPUTSTREAM_VERSION_LEVEL > 1
491491
int CInputStreamAdaptive::GetChapter()
492492
{
493+
// Provide the current chapter number
494+
// chapter numbering starts from 1, specify 0 for no chapter
493495
return m_session ? m_session->GetChapter() : 0;
494496
}
495497

496498
int CInputStreamAdaptive::GetChapterCount()
497499
{
498-
return m_session ? m_session->GetChapterCount() : 0;
500+
if (m_session)
501+
{
502+
const int count = m_session->GetChapterCount();
503+
if (count > 1)
504+
return count;
505+
}
506+
// Return 0 to prevent Kodi core from handling chapters
507+
return 0;
499508
}
500509

501510
const char* CInputStreamAdaptive::GetChapterName(int ch)

0 commit comments

Comments
 (0)