Skip to content

Commit

Permalink
Connection state change (backport) (#233)
Browse files Browse the repository at this point in the history
Change initial connection to connecting state and defer going into unreachable state to avoid event disruption on startup.

Co-authored-by: emveepee <nospam>
  • Loading branch information
emveepee authored Apr 1, 2023
1 parent 5b6fe85 commit cf8b434
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pvr.nextpvr/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.nextpvr"
version="20.4.0"
version="20.4.1"
name="NextPVR PVR Client"
provider-name="Graeme Blackley">
<requires>@ADDON_DEPENDS@
Expand Down
3 changes: 3 additions & 0 deletions pvr.nextpvr/changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 5 additions & 10 deletions src/pvrclient-nextpvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit cf8b434

Please sign in to comment.