aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorksooo <3226626+ksooo@users.noreply.github.com>2023-01-14 12:47:05 +0100
committerksooo <3226626+ksooo@users.noreply.github.com>2023-02-26 00:23:04 +0100
commitd72dbbe3e2294c793886ff6c974fbeb70a4510bd (patch)
treea345d220a80b0fc23f05f93f3f6c3326aebbbc61
parentdb47f82ea1573d80845af549f31193255d027131 (diff)
[PVR] Rework PVR windows late init.
-rw-r--r--xbmc/pvr/PVRManager.cpp8
-rw-r--r--xbmc/pvr/PVRManager.h6
-rw-r--r--xbmc/pvr/windows/GUIWindowPVRBase.cpp57
-rw-r--r--xbmc/pvr/windows/GUIWindowPVRBase.h3
-rw-r--r--xbmc/pvr/windows/GUIWindowPVRGuide.cpp11
5 files changed, 34 insertions, 51 deletions
diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp
index 02a8e8c4cc..72d96ae5f6 100644
--- a/xbmc/pvr/PVRManager.cpp
+++ b/xbmc/pvr/PVRManager.cpp
@@ -682,6 +682,7 @@ bool CPVRManager::UpdateComponents(ManagerState stateToCheck,
{
CLog::LogFC(LOGDEBUG, LOGPVR, "All created PVR clients gone!");
m_knownClients.clear(); // start over
+ PublishEvent(PVREvent::ClientsInvalidated);
return false;
}
@@ -717,6 +718,7 @@ bool CPVRManager::UpdateComponents(ManagerState stateToCheck,
{
CLog::LogF(LOGERROR, "Failed to load PVR providers.");
m_knownClients.clear(); // start over
+ PublishEvent(PVREvent::ClientsInvalidated);
return false;
}
@@ -724,11 +726,10 @@ bool CPVRManager::UpdateComponents(ManagerState stateToCheck,
{
CLog::LogF(LOGERROR, "Failed to load PVR channels / groups.");
m_knownClients.clear(); // start over
+ PublishEvent(PVREvent::ClientsInvalidated);
return false;
}
- PublishEvent(PVREvent::ChannelGroupsLoaded);
-
// Load all timers
if (progressHandler)
progressHandler->UpdateProgress(g_localizeStrings.Get(19237), 50); // Loading timers
@@ -737,6 +738,7 @@ bool CPVRManager::UpdateComponents(ManagerState stateToCheck,
{
CLog::LogF(LOGERROR, "Failed to load PVR timers.");
m_knownClients.clear(); // start over
+ PublishEvent(PVREvent::ClientsInvalidated);
return false;
}
@@ -748,9 +750,11 @@ bool CPVRManager::UpdateComponents(ManagerState stateToCheck,
{
CLog::LogF(LOGERROR, "Failed to load PVR recordings.");
m_knownClients.clear(); // start over
+ PublishEvent(PVREvent::ClientsInvalidated);
return false;
}
+ PublishEvent(PVREvent::ClientsInvalidated);
return true;
}
diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h
index b2a4ebc570..06bcb44e89 100644
--- a/xbmc/pvr/PVRManager.h
+++ b/xbmc/pvr/PVRManager.h
@@ -60,7 +60,6 @@ enum class PVREvent
ChannelGroup,
ChannelGroupInvalidated,
ChannelGroupsInvalidated,
- ChannelGroupsLoaded,
// Recording events
RecordingsInvalidated,
@@ -70,6 +69,9 @@ enum class PVREvent
Timers,
TimersInvalidated,
+ // Client events
+ ClientsInvalidated,
+
// EPG events
Epg,
EpgActiveItem,
@@ -84,7 +86,7 @@ enum class PVREvent
// Item events
CurrentItem,
- // Syetem events
+ // System events
SystemSleep,
SystemWake,
};
diff --git a/xbmc/pvr/windows/GUIWindowPVRBase.cpp b/xbmc/pvr/windows/GUIWindowPVRBase.cpp
index bca551b14c..96a14b50f7 100644
--- a/xbmc/pvr/windows/GUIWindowPVRBase.cpp
+++ b/xbmc/pvr/windows/GUIWindowPVRBase.cpp
@@ -135,12 +135,15 @@ CGUIWindowPVRBase::CGUIWindowPVRBase(bool bRadio, int id, const std::string& xml
// prevent removable drives to appear in directory listing (base class default behavior).
m_rootDir.AllowNonLocalSources(false);
- RegisterObservers();
+ CServiceBroker::GetPVRManager().Events().Subscribe(this, &CGUIWindowPVRBase::Notify);
}
CGUIWindowPVRBase::~CGUIWindowPVRBase()
{
- UnregisterObservers();
+ if (m_channelGroup)
+ m_channelGroup->Events().Unsubscribe(this);
+
+ CServiceBroker::GetPVRManager().Events().Unsubscribe(this);
}
void CGUIWindowPVRBase::UpdateSelectedItemPath()
@@ -149,25 +152,6 @@ void CGUIWindowPVRBase::UpdateSelectedItemPath()
m_bRadio, m_viewControl.GetSelectedItemPath());
}
-void CGUIWindowPVRBase::RegisterObservers()
-{
- CServiceBroker::GetPVRManager().Events().Subscribe(this, &CGUIWindowPVRBase::Notify);
-
- std::unique_lock<CCriticalSection> lock(m_critSection);
- if (m_channelGroup)
- m_channelGroup->Events().Subscribe(this, &CGUIWindowPVRBase::Notify);
-};
-
-void CGUIWindowPVRBase::UnregisterObservers()
-{
- {
- std::unique_lock<CCriticalSection> lock(m_critSection);
- if (m_channelGroup)
- m_channelGroup->Events().Unsubscribe(this);
- }
- CServiceBroker::GetPVRManager().Events().Unsubscribe(this);
-};
-
void CGUIWindowPVRBase::Notify(const PVREvent& event)
{
// call virtual event handler function
@@ -327,32 +311,24 @@ bool CGUIWindowPVRBase::OnMessage(CGUIMessage& message)
{
switch (static_cast<PVREvent>(message.GetParam1()))
{
- case PVREvent::ChannelGroupsLoaded:
- {
- // late init
- InitChannelGroup();
- m_channelGroupsSelector->Initialize(this, m_bRadio);
- m_channelGroupsSelector->SelectChannelGroup(GetChannelGroup());
- RegisterObservers();
- HideProgressDialog();
- Refresh(true);
- m_viewControl.SetFocused();
- break;
- }
case PVREvent::ManagerStarted:
- [[fallthrough]];
+ case PVREvent::ClientsInvalidated:
case PVREvent::ChannelGroupsInvalidated:
{
- std::shared_ptr<CPVRChannelGroup> group =
- CServiceBroker::GetPVRManager().PlaybackState()->GetActiveChannelGroup(m_bRadio);
- m_channelGroupsSelector->Initialize(this, m_bRadio);
- m_channelGroupsSelector->SelectChannelGroup(group);
- SetChannelGroup(std::move(group));
+ if (InitChannelGroup())
+ {
+ m_channelGroupsSelector->Initialize(this, m_bRadio);
+ m_channelGroupsSelector->SelectChannelGroup(GetChannelGroup());
+ HideProgressDialog();
+ Refresh(true);
+ m_viewControl.SetFocused();
+ }
break;
}
default:
break;
}
+
if (IsActive())
{
// Only the active window must set the selected item path which is shared
@@ -439,6 +415,9 @@ bool CGUIWindowPVRBase::OpenChannelGroupSelectionDialog()
bool CGUIWindowPVRBase::InitChannelGroup()
{
+ if (!CServiceBroker::GetPVRManager().IsStarted())
+ return false;
+
std::shared_ptr<CPVRChannelGroup> group;
if (m_channelGroupPath.empty())
{
diff --git a/xbmc/pvr/windows/GUIWindowPVRBase.h b/xbmc/pvr/windows/GUIWindowPVRBase.h
index 81aa2556d8..1fe27bb828 100644
--- a/xbmc/pvr/windows/GUIWindowPVRBase.h
+++ b/xbmc/pvr/windows/GUIWindowPVRBase.h
@@ -112,9 +112,6 @@ namespace PVR
virtual void UpdateSelectedItemPath();
- void RegisterObservers();
- void UnregisterObservers();
-
CCriticalSection m_critSection;
std::string m_channelGroupPath;
bool m_bRadio;
diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp
index 0669ee84a3..f4c247f910 100644
--- a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp
+++ b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp
@@ -572,18 +572,19 @@ bool CGUIWindowPVRGuideBase::OnMessage(CGUIMessage& message)
{
switch (static_cast<PVREvent>(message.GetParam1()))
{
- case PVREvent::ChannelGroupsLoaded:
- // late init
- InitChannelGroup();
- InitEpgGridControl();
+ case PVREvent::ManagerStarted:
+ if (InitChannelGroup())
+ InitEpgGridControl();
break;
case PVREvent::ChannelGroup:
case PVREvent::ChannelGroupInvalidated:
+ case PVREvent::ClientsInvalidated:
case PVREvent::ChannelPlaybackStopped:
case PVREvent::Epg:
case PVREvent::EpgContainer:
- Refresh(true);
+ if (InitChannelGroup())
+ Refresh(true);
break;
case PVREvent::Timers: