aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorksooo <3226626+ksooo@users.noreply.github.com>2023-11-26 14:06:14 +0100
committerksooo <3226626+ksooo@users.noreply.github.com>2023-12-06 12:59:34 +0100
commit9316a52bff32042f76f0ce544c0741cc7a99d360 (patch)
treef9df8eb5e8f2e6527893b9768d483cd748991e73
parent49ba27934d228aa7c963dc38b8a143dc8cbd1f23 (diff)
[video] CVideoPlayActionProcessorBase: make m_item a std::shared_ptr.
-rw-r--r--xbmc/favourites/GUIWindowFavourites.cpp19
-rw-r--r--xbmc/listproviders/DirectoryProvider.cpp16
-rw-r--r--xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp3
-rw-r--r--xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp2
-rw-r--r--xbmc/pvr/guilib/PVRGUIRecordingsPlayActionProcessor.h6
-rw-r--r--xbmc/pvr/windows/GUIWindowPVRRecordings.cpp23
-rw-r--r--xbmc/video/dialogs/GUIDialogVideoInfo.cpp25
-rw-r--r--xbmc/video/guilib/VideoPlayActionProcessor.cpp2
-rw-r--r--xbmc/video/guilib/VideoPlayActionProcessor.h6
-rw-r--r--xbmc/video/windows/GUIWindowVideoBase.cpp8
10 files changed, 61 insertions, 49 deletions
diff --git a/xbmc/favourites/GUIWindowFavourites.cpp b/xbmc/favourites/GUIWindowFavourites.cpp
index 762697af3e..f47bf6e93e 100644
--- a/xbmc/favourites/GUIWindowFavourites.cpp
+++ b/xbmc/favourites/GUIWindowFavourites.cpp
@@ -94,18 +94,21 @@ protected:
class CVideoPlayActionProcessor : public VIDEO::GUILIB::CVideoPlayActionProcessorBase
{
public:
- explicit CVideoPlayActionProcessor(CFileItem& item) : CVideoPlayActionProcessorBase(item) {}
+ explicit CVideoPlayActionProcessor(const ::std::shared_ptr<CFileItem>& item)
+ : CVideoPlayActionProcessorBase(item)
+ {
+ }
protected:
bool OnResumeSelected() override
{
- FAVOURITES_UTILS::ExecuteAction({"PlayMedia", m_item, "resume"});
+ FAVOURITES_UTILS::ExecuteAction({"PlayMedia", *m_item, "resume"});
return true;
}
bool OnPlaySelected() override
{
- FAVOURITES_UTILS::ExecuteAction({"PlayMedia", m_item, "noresume"});
+ FAVOURITES_UTILS::ExecuteAction({"PlayMedia", *m_item, "noresume"});
return true;
}
};
@@ -154,24 +157,24 @@ bool CGUIWindowFavourites::OnAction(const CAction& action)
if (!target)
return false;
- CFileItem item{*target};
+ const auto item{std::make_shared<CFileItem>(*target)};
// video play action setting is for files and folders...
- if (item.HasVideoInfoTag() || (item.m_bIsFolder && VIDEO_UTILS::IsItemPlayable(item)))
+ if (item->HasVideoInfoTag() || (item->m_bIsFolder && VIDEO_UTILS::IsItemPlayable(*item)))
{
CVideoPlayActionProcessor proc{item};
if (proc.Process())
return true;
}
- if (CPlayerUtils::IsItemPlayable(item))
+ if (CPlayerUtils::IsItemPlayable(*item))
{
- CFavouritesURL target{item, {}};
+ CFavouritesURL target{*item, {}};
if (target.GetAction() != CFavouritesURL::Action::PLAY_MEDIA)
{
// build a playmedia execute string for given target
target = CFavouritesURL{CFavouritesURL::Action::PLAY_MEDIA,
- {StringUtils::Paramify(item.GetPath())}};
+ {StringUtils::Paramify(item->GetPath())}};
}
return FAVOURITES_UTILS::ExecuteAction(target);
}
diff --git a/xbmc/listproviders/DirectoryProvider.cpp b/xbmc/listproviders/DirectoryProvider.cpp
index b581cf6e2a..598a8d685d 100644
--- a/xbmc/listproviders/DirectoryProvider.cpp
+++ b/xbmc/listproviders/DirectoryProvider.cpp
@@ -537,29 +537,31 @@ private:
class CVideoPlayActionProcessor : public VIDEO::GUILIB::CVideoPlayActionProcessorBase
{
public:
- explicit CVideoPlayActionProcessor(CFileItem& item) : CVideoPlayActionProcessorBase(item) {}
+ explicit CVideoPlayActionProcessor(const std::shared_ptr<CFileItem>& item)
+ : CVideoPlayActionProcessorBase(item)
+ {
+ }
protected:
bool OnResumeSelected() override
{
- ExecuteAction({"PlayMedia", m_item, "resume"});
+ ExecuteAction({"PlayMedia", *m_item, "resume"});
return true;
}
bool OnPlaySelected() override
{
//! @todo get rid of special handling for movie versions
- if (m_item.GetVideoInfoTag()->m_type == MediaTypeMovie)
+ if (m_item->GetVideoInfoTag()->m_type == MediaTypeMovie)
{
- auto videoItem = std::make_shared<CFileItem>(m_item);
CGUIDialogVideoVersion::PlayVideoVersion(
- videoItem,
+ m_item,
[](const std::shared_ptr<CFileItem>& item) {
ExecuteAction({"PlayMedia", *item.get(), "noresume"});
});
}
else
- ExecuteAction({"PlayMedia", m_item, "noresume"});
+ ExecuteAction({"PlayMedia", *m_item, "noresume"});
return true;
}
@@ -616,7 +618,7 @@ bool CDirectoryProvider::OnPlay(const CGUIListItemPtr& item)
if (targetItem.HasVideoInfoTag() ||
(targetItem.m_bIsFolder && VIDEO_UTILS::IsItemPlayable(targetItem)))
{
- CVideoPlayActionProcessor proc{targetItem};
+ CVideoPlayActionProcessor proc{std::make_shared<CFileItem>(targetItem)};
if (proc.Process())
return true;
}
diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp
index 9b8ed4fa4a..c3c20264e0 100644
--- a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp
+++ b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp
@@ -140,8 +140,7 @@ bool CGUIDialogPVRGuideInfo::OnClickButtonPlay(const CGUIMessage& message)
const auto recording{CPVRItem(m_progItem).GetRecording()};
if (recording)
{
- CFileItem item{recording};
- CGUIPVRRecordingsPlayActionProcessor proc{item};
+ CGUIPVRRecordingsPlayActionProcessor proc{std::make_shared<CFileItem>(recording)};
proc.Process();
if (proc.UserCancelled())
Open();
diff --git a/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp b/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp
index a9458f54b3..f6af16e05c 100644
--- a/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp
+++ b/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp
@@ -60,7 +60,7 @@ bool CGUIDialogPVRRecordingInfo::OnClickButtonPlay(const CGUIMessage& message)
if (m_recordItem)
{
- CGUIPVRRecordingsPlayActionProcessor proc{*m_recordItem};
+ CGUIPVRRecordingsPlayActionProcessor proc{m_recordItem};
proc.Process();
if (proc.UserCancelled())
Open();
diff --git a/xbmc/pvr/guilib/PVRGUIRecordingsPlayActionProcessor.h b/xbmc/pvr/guilib/PVRGUIRecordingsPlayActionProcessor.h
index 14225bc3b6..80df2dfc96 100644
--- a/xbmc/pvr/guilib/PVRGUIRecordingsPlayActionProcessor.h
+++ b/xbmc/pvr/guilib/PVRGUIRecordingsPlayActionProcessor.h
@@ -19,7 +19,7 @@ namespace PVR
class CGUIPVRRecordingsPlayActionProcessor : public VIDEO::GUILIB::CVideoPlayActionProcessorBase
{
public:
- explicit CGUIPVRRecordingsPlayActionProcessor(CFileItem& item)
+ explicit CGUIPVRRecordingsPlayActionProcessor(const std::shared_ptr<CFileItem>& item)
: CVideoPlayActionProcessorBase(item)
{
}
@@ -27,7 +27,7 @@ public:
protected:
bool OnResumeSelected() override
{
- m_item.SetStartOffset(STARTOFFSET_RESUME);
+ m_item->SetStartOffset(STARTOFFSET_RESUME);
Play();
return true;
}
@@ -42,7 +42,7 @@ private:
void Play()
{
CServiceBroker::GetPVRManager().Get<PVR::GUI::Playback>().PlayRecording(
- m_item, false /* no resume check */);
+ *m_item, false /* no resume check */);
}
};
} // namespace PVR
diff --git a/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp b/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp
index d939d741b5..0764f4e33d 100644
--- a/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp
+++ b/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp
@@ -280,37 +280,40 @@ private:
class CVideoPlayActionProcessor : public CVideoPlayActionProcessorBase
{
public:
- explicit CVideoPlayActionProcessor(CFileItem& item) : CVideoPlayActionProcessorBase(item) {}
+ explicit CVideoPlayActionProcessor(const std::shared_ptr<CFileItem>& item)
+ : CVideoPlayActionProcessorBase(item)
+ {
+ }
protected:
bool OnResumeSelected() override
{
- if (m_item.m_bIsFolder)
+ if (m_item->m_bIsFolder)
{
- m_item.SetStartOffset(STARTOFFSET_RESUME);
+ m_item->SetStartOffset(STARTOFFSET_RESUME);
CServiceBroker::GetPVRManager().Get<PVR::GUI::Playback>().PlayRecordingFolder(
- m_item, false /* no resume check */);
+ *m_item, false /* no resume check */);
}
else
{
CServiceBroker::GetPVRManager().Get<PVR::GUI::Playback>().ResumePlayRecording(
- m_item, true /* fall back to play if no resume possible */);
+ *m_item, true /* fall back to play if no resume possible */);
}
return true;
}
bool OnPlaySelected() override
{
- if (m_item.m_bIsFolder)
+ if (m_item->m_bIsFolder)
{
- m_item.SetStartOffset(0);
+ m_item->SetStartOffset(0);
CServiceBroker::GetPVRManager().Get<PVR::GUI::Playback>().PlayRecordingFolder(
- m_item, false /* no resume check */);
+ *m_item, false /* no resume check */);
}
else
{
CServiceBroker::GetPVRManager().Get<PVR::GUI::Playback>().PlayRecording(
- m_item, false /* no resume check */);
+ *m_item, false /* no resume check */);
}
return true;
}
@@ -346,7 +349,7 @@ bool CGUIWindowPVRRecordingsBase::OnMessage(CGUIMessage& message)
if (!item->IsParentFolder() && message.GetParam1() == ACTION_PLAYER_PLAY)
{
- CVideoPlayActionProcessor proc{*item};
+ CVideoPlayActionProcessor proc{item};
bReturn = proc.Process();
}
else if (item->m_bIsFolder)
diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp
index eae46427ab..e1e781b9b7 100644
--- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp
+++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp
@@ -715,12 +715,15 @@ namespace
class CVideoPlayActionProcessor : public CVideoPlayActionProcessorBase
{
public:
- explicit CVideoPlayActionProcessor(CFileItem& item) : CVideoPlayActionProcessorBase(item) {}
+ explicit CVideoPlayActionProcessor(const std::shared_ptr<CFileItem>& item)
+ : CVideoPlayActionProcessorBase(item)
+ {
+ }
protected:
bool OnResumeSelected() override
{
- m_item.SetStartOffset(STARTOFFSET_RESUME);
+ m_item->SetStartOffset(STARTOFFSET_RESUME);
Play();
return true;
}
@@ -734,21 +737,21 @@ protected:
private:
void Play()
{
- m_item.SetProperty("playlist_type_hint", PLAYLIST::TYPE_VIDEO);
- const ContentUtils::PlayMode mode{m_item.GetProperty("CheckAutoPlayNextItem").asBoolean()
+ m_item->SetProperty("playlist_type_hint", PLAYLIST::TYPE_VIDEO);
+ const ContentUtils::PlayMode mode{m_item->GetProperty("CheckAutoPlayNextItem").asBoolean()
? ContentUtils::PlayMode::CHECK_AUTO_PLAY_NEXT_ITEM
: ContentUtils::PlayMode::PLAY_ONLY_THIS};
//! @todo get rid of special handling for movie versions
- if (m_item.GetStartOffset() != STARTOFFSET_RESUME &&
- m_item.GetVideoInfoTag()->m_type == MediaTypeMovie)
+ if (m_item->GetStartOffset() != STARTOFFSET_RESUME &&
+ m_item->GetVideoInfoTag()->m_type == MediaTypeMovie)
{
- CGUIDialogVideoVersion::PlayVideoVersion(std::make_shared<CFileItem>(m_item),
+ CGUIDialogVideoVersion::PlayVideoVersion(m_item,
[mode](const std::shared_ptr<CFileItem>& item)
{ VIDEO_UTILS::PlayItem(item, "", mode); });
}
else
- VIDEO_UTILS::PlayItem(std::make_shared<CFileItem>(m_item), "", mode);
+ VIDEO_UTILS::PlayItem(m_item, "", mode);
}
};
} // unnamed namespace
@@ -797,7 +800,7 @@ void CGUIDialogVideoInfo::Play(bool resume)
if (resume)
{
- CVideoPlayActionProcessor proc{*m_movieItem};
+ CVideoPlayActionProcessor proc{m_movieItem};
proc.Process(PLAY_ACTION_RESUME);
}
else
@@ -805,13 +808,13 @@ void CGUIDialogVideoInfo::Play(bool resume)
if (GetControl(CONTROL_BTN_RESUME))
{
// if dialog has a resume button, play button has always the purpose to start from beginning
- CVideoPlayActionProcessor proc{*m_movieItem};
+ CVideoPlayActionProcessor proc{m_movieItem};
proc.Process(PLAY_ACTION_PLAY_FROM_BEGINNING);
}
else
{
// play button acts according to default play action setting
- CVideoPlayActionProcessor proc{*m_movieItem};
+ CVideoPlayActionProcessor proc{m_movieItem};
proc.Process();
if (proc.UserCancelled())
{
diff --git a/xbmc/video/guilib/VideoPlayActionProcessor.cpp b/xbmc/video/guilib/VideoPlayActionProcessor.cpp
index 6e0e75fdae..0c01f2caa4 100644
--- a/xbmc/video/guilib/VideoPlayActionProcessor.cpp
+++ b/xbmc/video/guilib/VideoPlayActionProcessor.cpp
@@ -62,7 +62,7 @@ PlayAction CVideoPlayActionProcessorBase::ChoosePlayOrResume()
{
PlayAction action = PLAY_ACTION_PLAY_FROM_BEGINNING;
- const std::string resumeString = VIDEO_UTILS::GetResumeString(m_item);
+ const std::string resumeString = VIDEO_UTILS::GetResumeString(*m_item);
if (!resumeString.empty())
{
CContextButtons choices;
diff --git a/xbmc/video/guilib/VideoPlayActionProcessor.h b/xbmc/video/guilib/VideoPlayActionProcessor.h
index ea57549178..d3f447b98b 100644
--- a/xbmc/video/guilib/VideoPlayActionProcessor.h
+++ b/xbmc/video/guilib/VideoPlayActionProcessor.h
@@ -10,6 +10,8 @@
#include "video/guilib/VideoPlayAction.h"
+#include <memory>
+
class CFileItem;
namespace VIDEO
@@ -19,7 +21,7 @@ namespace GUILIB
class CVideoPlayActionProcessorBase
{
public:
- explicit CVideoPlayActionProcessorBase(CFileItem& item) : m_item(item) {}
+ explicit CVideoPlayActionProcessorBase(const std::shared_ptr<CFileItem>& item) : m_item(item) {}
virtual ~CVideoPlayActionProcessorBase() = default;
static PlayAction GetDefaultPlayAction();
@@ -33,7 +35,7 @@ protected:
virtual bool OnResumeSelected() = 0;
virtual bool OnPlaySelected() = 0;
- CFileItem& m_item;
+ std::shared_ptr<CFileItem> m_item;
bool m_userCancelled{false};
private:
diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp
index 9bb90f0ea2..d042404f8c 100644
--- a/xbmc/video/windows/GUIWindowVideoBase.cpp
+++ b/xbmc/video/windows/GUIWindowVideoBase.cpp
@@ -741,7 +741,7 @@ class CVideoPlayActionProcessor : public CVideoPlayActionProcessorBase
{
public:
CVideoPlayActionProcessor(CGUIWindowVideoBase& window,
- CFileItem& item,
+ const std::shared_ptr<CFileItem>& item,
int itemIndex,
const std::string& player)
: CVideoPlayActionProcessorBase(item),
@@ -754,13 +754,13 @@ public:
protected:
bool OnResumeSelected() override
{
- m_item.SetStartOffset(STARTOFFSET_RESUME);
+ m_item->SetStartOffset(STARTOFFSET_RESUME);
return m_window.OnFileAction(m_itemIndex, SELECT_ACTION_RESUME, m_player);
}
bool OnPlaySelected() override
{
- m_item.SetStartOffset(0);
+ m_item->SetStartOffset(0);
return m_window.OnFileAction(m_itemIndex, SELECT_ACTION_PLAY, m_player);
}
@@ -776,7 +776,7 @@ bool CGUIWindowVideoBase::OnPlayOrResumeItem(int iItem, const std::string& playe
if (iItem < 0 || iItem >= m_vecItems->Size())
return false;
- CVideoPlayActionProcessor proc{*this, *m_vecItems->Get(iItem), iItem, player};
+ CVideoPlayActionProcessor proc{*this, m_vecItems->Get(iItem), iItem, player};
return proc.Process();
}