aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Borges de Freitas <92enen@gmail.com>2024-03-23 10:37:24 +0000
committerGitHub <noreply@github.com>2024-03-23 10:37:24 +0000
commit3281dcd82838da0df0027b48adf0292a4c799b6d (patch)
tree6f702871598e8760a3de0b1b8d1586b22a27ca9a
parentc976aa91cd739ac580510bf22d49269eeab9893f (diff)
parent43ceb82b4eac7d89a41411b0b40014da1d0469b7 (diff)
Merge pull request #24881 from enen92/stacks_bp
stacks: make InitializeStackStartPartAndOffset return optional and ha…
-rw-r--r--xbmc/application/Application.cpp10
-rw-r--r--xbmc/application/ApplicationStackHelper.cpp4
-rw-r--r--xbmc/application/ApplicationStackHelper.h4
3 files changed, 13 insertions, 5 deletions
diff --git a/xbmc/application/Application.cpp b/xbmc/application/Application.cpp
index 3309927de0..e1db281f08 100644
--- a/xbmc/application/Application.cpp
+++ b/xbmc/application/Application.cpp
@@ -2334,10 +2334,16 @@ bool CApplication::PlayStack(CFileItem& item, bool bRestart)
if (!stackHelper->InitializeStack(item))
return false;
- int startoffset = stackHelper->InitializeStackStartPartAndOffset(item);
+ std::optional<int> startoffset = stackHelper->InitializeStackStartPartAndOffset(item);
+ if (!startoffset)
+ {
+ CLog::LogF(LOGERROR, "Failed to obtain start offset for stack {}. Aborting playback.",
+ item.GetDynPath());
+ return false;
+ }
CFileItem selectedStackPart = stackHelper->GetCurrentStackPartFileItem();
- selectedStackPart.SetStartOffset(startoffset);
+ selectedStackPart.SetStartOffset(startoffset.value());
if (item.HasProperty("savedplayerstate"))
{
diff --git a/xbmc/application/ApplicationStackHelper.cpp b/xbmc/application/ApplicationStackHelper.cpp
index f8070c0d1e..e2c303a0e1 100644
--- a/xbmc/application/ApplicationStackHelper.cpp
+++ b/xbmc/application/ApplicationStackHelper.cpp
@@ -80,7 +80,7 @@ bool CApplicationStackHelper::InitializeStack(const CFileItem & item)
return true;
}
-int CApplicationStackHelper::InitializeStackStartPartAndOffset(const CFileItem& item)
+std::optional<int> CApplicationStackHelper::InitializeStackStartPartAndOffset(const CFileItem& item)
{
CVideoDatabase dbs;
int64_t startoffset = 0;
@@ -162,7 +162,7 @@ int CApplicationStackHelper::InitializeStackStartPartAndOffset(const CFileItem&
if (!CDVDFileInfo::GetFileDuration(GetStackPartFileItem(i).GetPath(), duration))
{
m_currentStack->Clear();
- return false;
+ return std::nullopt;
}
totalTimeMs += duration;
// set end time in every part
diff --git a/xbmc/application/ApplicationStackHelper.h b/xbmc/application/ApplicationStackHelper.h
index 6af0044372..4cdbc39e42 100644
--- a/xbmc/application/ApplicationStackHelper.h
+++ b/xbmc/application/ApplicationStackHelper.h
@@ -13,6 +13,7 @@
#include <map>
#include <memory>
+#include <optional>
#include <string>
class CFileItem;
@@ -36,8 +37,9 @@ public:
/*!
\brief Initialize stack times for each part, start & end, total time, and current part number if resume offset is specified.
\param item the FileItem object that is the stack
+ \returns the part offset if available, nullopt in case of errors
*/
- int InitializeStackStartPartAndOffset(const CFileItem& item);
+ std::optional<int> InitializeStackStartPartAndOffset(const CFileItem& item);
/*!
\brief returns the current part number