Skip to content

Commit

Permalink
Merge pull request #103 from Jalle19/isengard-updates
Browse files Browse the repository at this point in the history
Isengard backports
  • Loading branch information
Jalle19 committed Sep 22, 2015
2 parents 9b05d4c + 4cf4163 commit 016b0b3
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 384 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ add_definitions(-DUSE_DEMUX)
# Sources and headers
set(HTS_SOURCES src/AsyncState.cpp
src/AsyncState.h
src/CircBuffer.cpp
src/CircBuffer.h
src/client.h
src/client.cpp
src/HTSPConnection.cpp
Expand Down
2 changes: 1 addition & 1 deletion pvr.hts/addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.hts"
version="2.1.17"
version="2.1.18"
name="Tvheadend HTSP Client"
provider-name="Adam Sutton, Sam Stenvall, Lars Op den Kamp, Kai Sommerfeld">
<requires>
Expand Down
6 changes: 6 additions & 0 deletions pvr.hts/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2.1.18
- added: include satpos in mux description
- improved: Do not try to reconnect to tvh while suspending or not fully awake again.
- simplified recording playback handling, fixes random skipping to the beginning of recordings
- fixed: recordings from channels that have been deleted since were not available in Kodi

2.1.17
- fixed: provide a transitional package to fix upgrade path

Expand Down
143 changes: 0 additions & 143 deletions src/CircBuffer.cpp

This file was deleted.

55 changes: 0 additions & 55 deletions src/CircBuffer.h

This file was deleted.

61 changes: 48 additions & 13 deletions src/HTSPConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void *CHTSPRegister::Process ( void )
CHTSPConnection::CHTSPConnection ()
: m_socket(NULL), m_regThread(this), m_ready(false), m_seq(0),
m_serverName(""), m_serverVersion(""), m_htspVersion(0),
m_webRoot(""), m_challenge(NULL), m_challengeLen(0)
m_webRoot(""), m_challenge(NULL), m_challengeLen(0), m_suspended(false)
{
}

Expand Down Expand Up @@ -171,6 +171,26 @@ bool CHTSPConnection::HasCapability(const std::string &capability) const
!= m_capabilities.end();
}

void CHTSPConnection::OnSleep ( void )
{
CLockObject lock(m_mutex);

tvhtrace("going to sleep (OnSleep)");

/* close connection, prevent reconnect while suspending/suspended */
m_suspended = true;
}

void CHTSPConnection::OnWake ( void )
{
CLockObject lock(m_mutex);

tvhtrace("waking up (OnWake)");

/* recreate connection */
m_suspended = false;
}

/*
* Close the connection
*/
Expand Down Expand Up @@ -223,8 +243,6 @@ bool CHTSPConnection::ReadMessage ( void )
return false;
}
cnt += r;
if (cnt < len)
printf("partial read\n");
}

/* Deserialize */
Expand Down Expand Up @@ -299,7 +317,8 @@ bool CHTSPConnection::SendMessage0 ( const char *method, htsmsg_t *msg )
{
tvherror("failed to write (%s)",
m_socket->GetError().c_str());
Disconnect();
if (!m_suspended)
Disconnect();
return false;
}

Expand Down Expand Up @@ -337,7 +356,8 @@ htsmsg_t *CHTSPConnection::SendAndWait0 ( const char *method, htsmsg_t *msg, int
{
//XBMC->QueueNotification(QUEUE_ERROR, "Command %s failed: No response received", method);
tvherror("Command %s failed: No response received", method);
Disconnect();
if (!m_suspended)
Disconnect();
return NULL;
}

Expand Down Expand Up @@ -500,10 +520,9 @@ void CHTSPConnection::Register ( void )
return;
}

/* Rate limit retry */
fail:
Sleep(5000);
Disconnect();
if (!m_suspended)
Disconnect();
}

/*
Expand All @@ -517,6 +536,8 @@ void* CHTSPConnection::Process ( void )

while (!IsStopped())
{
tvhdebug("new connection requested");

CStdString host = settings.strHostname;
int port, timeout;
port = settings.iPortHTSP;
Expand All @@ -528,11 +549,6 @@ void* CHTSPConnection::Process ( void )
if (m_socket)
delete m_socket;
tvh->Disconnected();
if (!log)
tvhdebug("connecting to %s:%d", host.c_str(), port);
else
tvhtrace("connecting to %s:%d", host.c_str(), port);
log = true;
m_socket = new CTcpSocket(host.c_str(), port);
m_ready = false;
m_seq = 0;
Expand All @@ -542,6 +558,24 @@ void* CHTSPConnection::Process ( void )
}
}

while (m_suspended)
{
tvhdebug("suspended. Waiting for wakeup...");

/* Wait for wakeup */
Sleep(1000);
}

if (!log)
{
tvhdebug("connecting to %s:%d", host.c_str(), port);
log = true;
}
else
{
tvhtrace("connecting to %s:%d", host.c_str(), port);
}

/* Connect */
tvhtrace("waiting for connection...");
if (!m_socket->Open(timeout))
Expand Down Expand Up @@ -569,6 +603,7 @@ void* CHTSPConnection::Process ( void )
{
if (!ReadMessage())
{
tvhdebug("attempting reconnect");
break;
}
}
Expand Down
21 changes: 16 additions & 5 deletions src/HTSPDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,22 @@ void CHTSPDemuxer::ParseSourceInfo ( htsmsg_t *m )
if (!m) return;

tvhtrace("demux sourceInfo:");

/* include position in mux name
* as users might receive multiple satellite positions */
m_sourceInfo.si_mux.clear();
if ((str = htsmsg_get_str(m, "satpos")) != NULL)
{
tvhtrace(" satpos : %s", str);
m_sourceInfo.si_mux.append(str);
m_sourceInfo.si_mux.append(": ");
}
if ((str = htsmsg_get_str(m, "mux")) != NULL)
{
tvhtrace(" mux : %s", str);
m_sourceInfo.si_mux.append(str);
}

if ((str = htsmsg_get_str(m, "adapter")) != NULL)
{
tvhtrace(" adapter : %s", str);
Expand All @@ -544,11 +560,6 @@ void CHTSPDemuxer::ParseSourceInfo ( htsmsg_t *m )
tvhtrace(" network : %s", str);
m_sourceInfo.si_network = str;
}
if ((str = htsmsg_get_str(m, "mux")) != NULL)
{
tvhtrace(" mux : %s", str);
m_sourceInfo.si_mux = str;
}
if ((str = htsmsg_get_str(m, "provider")) != NULL)
{
tvhtrace(" provider : %s", str);
Expand Down
Loading

0 comments on commit 016b0b3

Please sign in to comment.