Skip to content

Commit

Permalink
Merge pull request #174 from AlwinEsch/Nexus-change
Browse files Browse the repository at this point in the history
fix read errors during Kodi's start and connection restart
  • Loading branch information
AlwinEsch authored Jan 16, 2022
2 parents 021a238 + 95d949f commit df8fdfa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pvr.vdr.vnsi/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.vdr.vnsi"
version="20.2.1"
version="20.2.2"
name="VDR VNSI Client"
provider-name="Team Kodi, FernetMenta">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
3 changes: 3 additions & 0 deletions pvr.vdr.vnsi/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v20.2.2
- Fix connection errors on Kodi start and during backend reconnections

v20.2.1
- Fix crash on some channels

Expand Down
20 changes: 13 additions & 7 deletions src/ClientInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ CVNSIClientInstance::~CVNSIClientInstance()
m_running = false;
if (m_thread.joinable())
m_thread.join();
if (m_startInformThread.joinable())
m_startInformThread.join();
Close();
}

Expand All @@ -116,13 +118,15 @@ void CVNSIClientInstance::OnReconnect()
{
EnableStatusInterface(true, false);

kodi::addon::CInstancePVRClient::ConnectionStateChange("vnsi connection established",
PVR_CONNECTION_STATE_CONNECTED,
kodi::addon::GetLocalizedString(30045));
m_startInformThread = std::thread([&]() {
kodi::addon::CInstancePVRClient::ConnectionStateChange("vnsi connection established",
PVR_CONNECTION_STATE_CONNECTED,
kodi::addon::GetLocalizedString(30045));

kodi::addon::CInstancePVRClient::TriggerChannelUpdate();
kodi::addon::CInstancePVRClient::TriggerTimerUpdate();
kodi::addon::CInstancePVRClient::TriggerRecordingUpdate();
kodi::addon::CInstancePVRClient::TriggerChannelUpdate();
kodi::addon::CInstancePVRClient::TriggerTimerUpdate();
kodi::addon::CInstancePVRClient::TriggerRecordingUpdate();
});
}

bool CVNSIClientInstance::Start(const std::string& hostname,
Expand Down Expand Up @@ -1751,7 +1755,9 @@ std::unique_ptr<cResponsePacket> CVNSIClientInstance::ReadResult(cRequestPacket*

std::unique_lock<std::recursive_mutex> lock(m_queue.m_mutex);
if (cVNSISession::TransmitMessage(vrp) &&
message.m_condition.wait_for(lock, std::chrono::milliseconds(CVNSISettings::Get().GetConnectTimeout() * 1000)) == std::cv_status::timeout)
message.m_condition.wait_for(
lock, std::chrono::seconds(CVNSISettings::Get().GetConnectTimeout())) ==
std::cv_status::timeout)
{
kodi::Log(ADDON_LOG_ERROR, "%s - request timed out after %d seconds", __func__,
CVNSISettings::Get().GetConnectTimeout());
Expand Down
1 change: 1 addition & 0 deletions src/ClientInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,5 @@ class ATTR_DLL_LOCAL CVNSIClientInstance : public kodi::addon::CInstancePVRClien

std::atomic<bool> m_running = {false};
std::thread m_thread;
std::thread m_startInformThread;
};

0 comments on commit df8fdfa

Please sign in to comment.