From cf8b43429d6c0bb919cad46295f6a7e0948c195a Mon Sep 17 00:00:00 2001 From: emveepee Date: Sat, 1 Apr 2023 14:36:32 -0400 Subject: [PATCH] Connection state change (backport) (#233) Change initial connection to connecting state and defer going into unreachable state to avoid event disruption on startup. Co-authored-by: emveepee --- pvr.nextpvr/addon.xml.in | 2 +- pvr.nextpvr/changelog.txt | 3 +++ src/pvrclient-nextpvr.cpp | 15 +++++---------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/pvr.nextpvr/addon.xml.in b/pvr.nextpvr/addon.xml.in index a42cd845..12ac9c48 100644 --- a/pvr.nextpvr/addon.xml.in +++ b/pvr.nextpvr/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ diff --git a/pvr.nextpvr/changelog.txt b/pvr.nextpvr/changelog.txt index 2c7bfa2b..708795e0 100644 --- a/pvr.nextpvr/changelog.txt +++ b/pvr.nextpvr/changelog.txt @@ -1,3 +1,6 @@ +v20.4.1 +- Connection change, start in connecting state, defer unreachable state. + v20.4.0 - Add support for multiple NextPVR instances - Adjust for Nexus change in Channel Group order diff --git a/src/pvrclient-nextpvr.cpp b/src/pvrclient-nextpvr.cpp index 7b1e811d..4d02bd5c 100644 --- a/src/pvrclient-nextpvr.cpp +++ b/src/pvrclient-nextpvr.cpp @@ -151,6 +151,9 @@ ADDON_STATUS cPVRClientNextPVR::Connect(bool sendWOL) if (sendWOL) SendWakeOnLan(); + if (m_connectionState == PVR_CONNECTION_STATE_UNKNOWN) + SetConnectionState(PVR_CONNECTION_STATE_CONNECTING); + m_request.ClearSID(); tinyxml2::XMLDocument doc; if (m_firstSessionInitiate == 0) @@ -217,13 +220,8 @@ ADDON_STATUS cPVRClientNextPVR::Connect(bool sendWOL) { status = ADDON_STATUS_OK; // backend should continue to connnect and ignore client until reachable - // avoid event logging in unreachable set so leave it connecting - if (m_connectionState != PVR_CONNECTION_STATE_UNKNOWN) - { - SetConnectionState(PVR_CONNECTION_STATE_SERVER_UNREACHABLE); - } - m_connectionState = PVR_CONNECTION_STATE_SERVER_UNREACHABLE; UpdateServerCheck(); + m_connectionState = PVR_CONNECTION_STATE_SERVER_UNREACHABLE; } else { @@ -426,7 +424,7 @@ bool cPVRClientNextPVR::IsUp() { UpdateServerCheck(); Connect(false); - if (m_connectionState == PVR_CONNECTION_STATE_SERVER_UNREACHABLE) + if (m_coreState == PVR_CONNECTION_STATE_CONNECTING && (time(nullptr) > m_firstSessionInitiate + FAST_SLOW_POLL_TRANSITION)) SetConnectionState(PVR_CONNECTION_STATE_SERVER_UNREACHABLE); } } @@ -985,9 +983,6 @@ PVR_ERROR cPVRClientNextPVR::GetTimersAmount(int& amount) PVR_ERROR cPVRClientNextPVR::GetTimers(kodi::addon::PVRTimersResultSet& results) { - if (m_connectionState == PVR_CONNECTION_STATE_CONNECTING) - SetConnectionState(PVR_CONNECTION_STATE_CONNECTED); - return m_timers.GetTimers(results); }