aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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