From 7ae934e4e2a7f1b5e70a4a00afc5242bc02b5095 Mon Sep 17 00:00:00 2001 From: Glenn-1990 Date: Sun, 19 Jul 2015 20:44:02 +0200 Subject: [PATCH 1/7] include satpos in mux description --- src/HTSPDemuxer.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/HTSPDemuxer.cpp b/src/HTSPDemuxer.cpp index a5ec887c..85c43082 100644 --- a/src/HTSPDemuxer.cpp +++ b/src/HTSPDemuxer.cpp @@ -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); @@ -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); From 92c99a97a892973976e669a0b08a31b9b7a7242d Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Tue, 11 Aug 2015 17:55:48 +0200 Subject: [PATCH 2/7] Improve connection handling on suspend/wakeup. --- src/HTSPConnection.cpp | 61 +++++++++++++++++++++++++++++++++--------- src/Tvheadend.h | 15 ++++++++++- src/client.cpp | 7 ++--- 3 files changed, 66 insertions(+), 17 deletions(-) diff --git a/src/HTSPConnection.cpp b/src/HTSPConnection.cpp index 0047a243..ca90b1bc 100644 --- a/src/HTSPConnection.cpp +++ b/src/HTSPConnection.cpp @@ -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) { } @@ -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 */ @@ -223,8 +243,6 @@ bool CHTSPConnection::ReadMessage ( void ) return false; } cnt += r; - if (cnt < len) - printf("partial read\n"); } /* Deserialize */ @@ -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; } @@ -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; } @@ -500,10 +520,9 @@ void CHTSPConnection::Register ( void ) return; } - /* Rate limit retry */ fail: - Sleep(5000); - Disconnect(); + if (!m_suspended) + Disconnect(); } /* @@ -517,6 +536,8 @@ void* CHTSPConnection::Process ( void ) while (!IsStopped()) { + tvhdebug("new connection requested"); + CStdString host = settings.strHostname; int port, timeout; port = settings.iPortHTSP; @@ -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; @@ -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)) @@ -569,6 +603,7 @@ void* CHTSPConnection::Process ( void ) { if (!ReadMessage()) { + tvhdebug("attempting reconnect"); break; } } diff --git a/src/Tvheadend.h b/src/Tvheadend.h index 317ad90a..7124723a 100644 --- a/src/Tvheadend.h +++ b/src/Tvheadend.h @@ -197,6 +197,9 @@ class CHTSPConnection bool WaitForConnection ( void ); inline PLATFORM::CMutex& Mutex ( void ) { return m_mutex; } + + void OnSleep ( void ); + void OnWake ( void ); private: void* Process ( void ); @@ -220,6 +223,8 @@ class CHTSPConnection CHTSPResponseList m_messages; std::vector m_capabilities; + + bool m_suspended; }; /* @@ -495,7 +500,7 @@ class CTvheadend } inline bool HasCapability(const std::string &capability) const { - return m_conn.HasCapability(capability); + return m_conn.HasCapability(capability); } inline bool IsConnected ( void ) const { @@ -505,6 +510,14 @@ class CTvheadend { m_conn.Disconnect(); } + inline void OnSleep ( void ) + { + m_conn.OnSleep(); + } + inline void OnWake ( void ) + { + m_conn.OnWake(); + } /* * Demuxer (pass-thru) diff --git a/src/client.cpp b/src/client.cpp index ed9de04e..5c26a6e9 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -273,9 +273,10 @@ void ADDON_Announce /* XBMC/System */ if (!strcmp(sender, "xbmc") && !strcmp(flag, "System")) { - /* Wake - close connection (it'll most likely need remaking) */ - if (!strcmp("OnWake", message)) - tvh->Disconnect(); + if (!strcmp("OnSleep", message)) + tvh->OnSleep(); + else if (!strcmp("OnWake", message)) + tvh->OnWake(); } } From 5efc89949cc605de8146f22f17d8ae7252725549 Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Sat, 19 Sep 2015 17:43:58 +0300 Subject: [PATCH 3/7] reduce connection mutex lock scope in CHTSPVFS --- src/HTSPVFS.cpp | 44 +++++++++++++++++++++++++++++--------------- src/Tvheadend.h | 1 - 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/HTSPVFS.cpp b/src/HTSPVFS.cpp index f2a4854c..aa9b7521 100644 --- a/src/HTSPVFS.cpp +++ b/src/HTSPVFS.cpp @@ -102,8 +102,6 @@ void CHTSPVFS::Connected ( void ) bool CHTSPVFS::Open ( const PVR_RECORDING &rec ) { - CLockObject lock(m_conn.Mutex()); - /* Close existing */ Close(); @@ -174,7 +172,6 @@ int CHTSPVFS::Read ( unsigned char *buf, unsigned int len ) long long CHTSPVFS::Seek ( long long pos, int whence ) { - CLockObject lock(m_conn.Mutex()); if (m_fileId == 0) return -1; m_bSeekDone = false; @@ -183,7 +180,6 @@ long long CHTSPVFS::Seek ( long long pos, int whence ) long long CHTSPVFS::Tell ( void ) { - CLockObject lock(m_conn.Mutex()); if (m_fileId == 0) return -1; return m_offset; @@ -192,7 +188,6 @@ long long CHTSPVFS::Tell ( void ) long long CHTSPVFS::Size ( void ) { int64_t ret = -1; - CLockObject lock(m_conn.Mutex()); htsmsg_t *m; /* Build */ @@ -202,7 +197,12 @@ long long CHTSPVFS::Size ( void ) tvhtrace("vfs stat id=%d", m_fileId); /* Send */ - if ((m = m_conn.SendAndWait("fileStat", m)) == NULL) + { + CLockObject lock(m_conn.Mutex()); + m = m_conn.SendAndWait("fileStat", m); + } + + if (m == NULL) return -1; /* Get size. Note: 'size' field is optional. */ @@ -231,10 +231,15 @@ bool CHTSPVFS::SendFileOpen ( bool force ) tvhdebug("vfs open file=%s", m_path.c_str()); /* Send */ - if (force) - m = m_conn.SendAndWait0("fileOpen", m); - else - m = m_conn.SendAndWait("fileOpen", m); + { + CLockObject lock(m_conn.Mutex()); + + if (force) + m = m_conn.SendAndWait0("fileOpen", m); + else + m = m_conn.SendAndWait("fileOpen", m); + } + if (m == NULL) return false; @@ -262,7 +267,11 @@ void CHTSPVFS::SendFileClose ( void ) tvhdebug("vfs close id=%d", m_fileId); /* Send */ - m = m_conn.SendAndWait("fileClose", m); + { + CLockObject lock(m_conn.Mutex()); + m = m_conn.SendAndWait("fileClose", m); + } + if (m) htsmsg_destroy(m); } @@ -285,10 +294,15 @@ long long CHTSPVFS::SendFileSeek ( int64_t pos, int whence, bool force ) m_fileId, whence, (long long)pos); /* Send */ - if (force) - m = m_conn.SendAndWait0("fileSeek", m); - else - m = m_conn.SendAndWait("fileSeek", m); + { + CLockObject lock(m_conn.Mutex()); + + if (force) + m = m_conn.SendAndWait0("fileSeek", m); + else + m = m_conn.SendAndWait("fileSeek", m); + } + if (m == NULL) return false; diff --git a/src/Tvheadend.h b/src/Tvheadend.h index 7124723a..f158910a 100644 --- a/src/Tvheadend.h +++ b/src/Tvheadend.h @@ -572,7 +572,6 @@ class CTvheadend } inline void VfsClose ( void ) { - PLATFORM::CLockObject lock(m_conn.Mutex()); m_vfs.Close(); } inline int VfsRead ( unsigned char *buf, unsigned int len ) From bdfef9838e15b2cfdcc190e7a0a5074345a945a3 Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Sat, 19 Sep 2015 18:32:17 +0300 Subject: [PATCH 4/7] simplify CHTSPVFS drastically by removing the intermediate circular buffer and threading. Fixes #92, fixes #99. --- CMakeLists.txt | 2 - src/CircBuffer.cpp | 143 ------------------------------------------ src/CircBuffer.h | 55 ----------------- src/HTSPVFS.cpp | 150 ++++++++++++--------------------------------- src/Tvheadend.h | 24 +------- src/client.cpp | 2 +- 6 files changed, 44 insertions(+), 332 deletions(-) delete mode 100644 src/CircBuffer.cpp delete mode 100644 src/CircBuffer.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 98c4d715..d920e1d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/CircBuffer.cpp b/src/CircBuffer.cpp deleted file mode 100644 index bed0a90b..00000000 --- a/src/CircBuffer.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2005-2012 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#include "CircBuffer.h" -#include -#include -#include - -using namespace PLATFORM; - -CCircBuffer::CCircBuffer(void) - : m_buffer(NULL), m_alloc(0), m_size(0), m_count(0), m_pin(0), m_pout(0) -{ -} - -CCircBuffer::~CCircBuffer(void) -{ - unalloc(); -} - -void CCircBuffer::alloc(size_t size) -{ - if (size > m_alloc) { - m_alloc = size; - - // don't allow memory to leak on realloc failure - unsigned char * buffer = (unsigned char*) realloc(m_buffer, size); - - if (!buffer) - ::free(m_buffer); - else - m_buffer = buffer; - } - m_size = size; - reset(); -} - -void CCircBuffer::unalloc(void) -{ - if(m_buffer) - ::free(m_buffer); - - m_buffer = NULL; - m_alloc = 0; - m_size = 0; - reset(); -} - -void CCircBuffer::reset(void) -{ - CLockObject lock(m_mutex); - m_pin = 0; - m_pout = 0; - m_count = 0; -} - -size_t CCircBuffer::size(void) const -{ - CLockObject lock(m_mutex); - return m_size; -} - -size_t CCircBuffer::avail(void) const -{ - CLockObject lock(m_mutex); - return m_count; -} - -size_t CCircBuffer::free(void) const -{ - CLockObject lock(m_mutex); - return m_size - m_count - 1; -} - -ssize_t CCircBuffer::write(const unsigned char* data, size_t len) -{ - CLockObject lock(m_mutex); - if (m_size < 2) - return -1; - if (len > free()) - len = free(); - if (m_pin < m_pout) - memcpy(m_buffer+m_pin, data, len); - else { - size_t pt1, pt2; - pt1 = m_size - m_pin; - if (len < pt1) { - pt1 = len; - pt2 = 0; - } else { - pt2 = len - pt1; - } - memcpy(m_buffer+m_pin, data, pt1); - memcpy(m_buffer, data+pt1, pt2); - } - m_pin = (m_pin + len) % m_size; - m_count += len; - return len; -} - -ssize_t CCircBuffer::read(unsigned char* data, size_t len) -{ - CLockObject lock(m_mutex); - if (m_size < 2) - return -1; - if (len > avail()) - len = avail(); - if (m_pout < m_pin) - memcpy(data, m_buffer+m_pout, len); - else { - size_t pt1, pt2; - pt1 = m_size - m_pout; - if (len < pt1) { - pt1 = len; - pt2 = 0; - } else { - pt2 = len - pt1; - } - memcpy(data, m_buffer+m_pout, pt1); - memcpy(data+pt1, m_buffer, pt2); - } - m_pout = ((m_pout + m_size) + len) % m_size; - m_count -= len; - return len; -} diff --git a/src/CircBuffer.h b/src/CircBuffer.h deleted file mode 100644 index 28ab7197..00000000 --- a/src/CircBuffer.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -/* - * Copyright (C) 2005-2012 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#include "platform/os.h" -#include "platform/threads/mutex.h" - -class CCircBuffer -{ -public: - CCircBuffer (void); - ~CCircBuffer (void); - - void alloc (size_t); - void unalloc (void); - void reset (void); - - size_t size (void) const; - size_t avail (void) const; - size_t free (void) const; - - ssize_t write (const unsigned char* data, size_t len); - ssize_t read (unsigned char* data, size_t len); - -protected: - unsigned char * m_buffer; - size_t m_alloc; - size_t m_size; - size_t m_count; - size_t m_pin; - size_t m_pout; - -private: - mutable PLATFORM::CMutex m_mutex; - -}; diff --git a/src/HTSPVFS.cpp b/src/HTSPVFS.cpp index aa9b7521..567d1d3a 100644 --- a/src/HTSPVFS.cpp +++ b/src/HTSPVFS.cpp @@ -36,50 +36,16 @@ using namespace std; using namespace ADDON; using namespace PLATFORM; -/* -* The buffer thread -*/ -void *CHTSPVFS::Process(void) -{ - while (!IsStopped()) - { - while (m_fileId && m_buffer.free() > 0) - { - if (!SendFileRead()) - continue; - - CLockObject lock(m_mutex); - m_bHasData = true; - m_condition.Broadcast(); - } - - // Take a break, we're either stopped or full - CLockObject lock(m_mutex); - m_condition.Wait(m_mutex, 1000); - } - - return NULL; -} - /* * VFS handler */ CHTSPVFS::CHTSPVFS ( CHTSPConnection &conn ) - : m_conn(conn), m_path(""), m_fileId(0), m_offset(0), - m_bHasData(false), - m_bSeekDone(true), - m_currentReadLength(INITAL_READ_LENGTH) + : m_conn(conn), m_path(""), m_fileId(0), m_offset(0) { - m_buffer.alloc(MAX_BUFFER_SIZE); - - // Start the buffer thread - CreateThread(); } CHTSPVFS::~CHTSPVFS ( void ) { - // Stop the buffer thread - StopThread(); } void CHTSPVFS::Connected ( void ) @@ -127,54 +93,29 @@ void CHTSPVFS::Close ( void ) m_offset = 0; m_fileId = 0; m_path = ""; - - Reset(); -} - -void CHTSPVFS::Reset() -{ - CLockObject lock(m_mutex); - m_buffer.reset(); - m_bHasData = false; - m_bSeekDone = true; - m_currentReadLength = INITAL_READ_LENGTH; - m_seekCondition.Signal(); } -int CHTSPVFS::Read ( unsigned char *buf, unsigned int len ) +ssize_t CHTSPVFS::Read ( unsigned char *buf, unsigned int len ) { - ssize_t ret; - CLockObject lock(m_mutex); - /* Not opened */ if (!m_fileId) return -1; - m_seekCondition.Wait(m_mutex, m_bSeekDone, 5000); - - /* Signal that we need more data in the buffer. Reset the read length to the - requested length so we don't wait unnecessarily long */ - if (m_buffer.avail() < len) - { - m_bHasData = false; - m_currentReadLength = len; - m_condition.Broadcast(); - } + /* Read */ + int read = SendFileRead(buf, len); - /* Wait for data */ - m_condition.Wait(m_mutex, m_bHasData, 5000); + /* Update */ + if (read > 0) + m_offset += read; - /* Read */ - ret = m_buffer.read(buf, len); - m_offset += ret; - return (int)ret; + return read; } long long CHTSPVFS::Seek ( long long pos, int whence ) { if (m_fileId == 0) return -1; - m_bSeekDone = false; + return SendFileSeek(pos, whence); } @@ -182,6 +123,7 @@ long long CHTSPVFS::Tell ( void ) { if (m_fileId == 0) return -1; + return m_offset; } @@ -304,52 +246,44 @@ long long CHTSPVFS::SendFileSeek ( int64_t pos, int whence, bool force ) } if (m == NULL) - return false; + { + tvherror("vfs fileSeek failed"); + return -1; + } - /* Get new offset. Note: 'offset' field is optional.*/ + /* Get new offset */ if (htsmsg_get_s64(m, "offset", &ret)) + { ret = -1; + tvherror("vfs fileSeek response: 'offset' missing'"); - htsmsg_destroy(m); - /* Update */ - if (ret >= 0) + } + else { tvhtrace("vfs seek offset=%lld", (long long)ret); m_offset = ret; - - Reset(); } - else - tvherror("vfs fileSeek failed"); + + /* Cleanup */ + htsmsg_destroy(m); return ret; } -bool CHTSPVFS::SendFileRead() +ssize_t CHTSPVFS::SendFileRead(unsigned char *buf, unsigned int len) { htsmsg_t *m; - const void *buf; - size_t len; - size_t readLength; - - { - CLockObject lock(m_mutex); - - /* Determine read length */ - if (m_currentReadLength > m_buffer.free()) - readLength = m_buffer.free(); - else - readLength = m_currentReadLength; - } + const void *buffer; + ssize_t read; /* Build */ m = htsmsg_create_map(); htsmsg_add_u32(m, "id", m_fileId); - htsmsg_add_s64(m, "size", readLength); + htsmsg_add_s64(m, "size", len); tvhtrace("vfs read id=%d size=%d", - m_fileId, readLength); + m_fileId, len); /* Send */ { @@ -358,30 +292,26 @@ bool CHTSPVFS::SendFileRead() } if (m == NULL) - return false; + { + tvherror("vfs fileRead failed"); + return -1; + } - /* Process */ - if (htsmsg_get_bin(m, "data", &buf, &len)) + /* Get Data */ + if (htsmsg_get_bin(m, "data", &buffer, reinterpret_cast(&read))) { - htsmsg_destroy(m); tvherror("malformed fileRead response: 'data' missing"); - return false; - } + read = -1; /* Store */ - if (m_buffer.write((unsigned char*)buf, len) != (ssize_t)len) + } + else { - htsmsg_destroy(m); - tvherror("vfs partial buffer write"); - return false; + memcpy(buf, buffer, read); } - /* Gradually increase read length */ - CLockObject lock(m_mutex); - - if (m_currentReadLength * 2 < MAX_READ_LENGTH) - m_currentReadLength *= 2; - + /* Cleanup */ htsmsg_destroy(m); - return true; + + return read; } diff --git a/src/Tvheadend.h b/src/Tvheadend.h index f158910a..b1717161 100644 --- a/src/Tvheadend.h +++ b/src/Tvheadend.h @@ -29,7 +29,6 @@ #include "kodi/xbmc_codec_types.h" #include "kodi/xbmc_stream_utils.hpp" #include "kodi/libXBMC_addon.h" -#include "CircBuffer.h" #include "Settings.h" #include "HTSPTypes.h" #include "AsyncState.h" @@ -292,7 +291,6 @@ class CHTSPDemuxer * HTSP VFS - recordings */ class CHTSPVFS - : public PLATFORM::CThread { friend class CTvheadend; @@ -308,33 +306,17 @@ class CHTSPVFS uint32_t m_fileId; int64_t m_offset; - CCircBuffer m_buffer; - PLATFORM::CMutex m_mutex; - bool m_bHasData; - bool m_bSeekDone; - PLATFORM::CCondition m_condition; - PLATFORM::CCondition m_seekCondition; - size_t m_currentReadLength; - bool Open ( const PVR_RECORDING &rec ); void Close ( void ); - int Read ( unsigned char *buf, unsigned int len ); + ssize_t Read ( unsigned char *buf, unsigned int len ); long long Seek ( long long pos, int whence ); long long Tell ( void ); long long Size ( void ); - void Reset ( void ); - - void *Process(); bool SendFileOpen ( bool force = false ); void SendFileClose ( void ); - bool SendFileRead ( void ); + ssize_t SendFileRead ( unsigned char *buf, unsigned int len ); long long SendFileSeek ( int64_t pos, int whence, bool force = false ); - - static const int MAX_BUFFER_SIZE = 5242880; // 5 MB - static const int INITAL_READ_LENGTH = 131072; // 128 KB - static const int MAX_READ_LENGTH = 1048576; // 1 MB - }; /* @@ -574,7 +556,7 @@ class CTvheadend { m_vfs.Close(); } - inline int VfsRead ( unsigned char *buf, unsigned int len ) + inline ssize_t VfsRead ( unsigned char *buf, unsigned int len ) { return m_vfs.Read(buf, len); } diff --git a/src/client.cpp b/src/client.cpp index 5c26a6e9..d4c2d0ad 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -546,7 +546,7 @@ void CloseRecordedStream(void) int ReadRecordedStream(unsigned char *pBuffer, unsigned int iBufferSize) { - return tvh->VfsRead(pBuffer, iBufferSize); + return static_cast(tvh->VfsRead(pBuffer, iBufferSize)); } long long SeekRecordedStream(long long iPosition, int iWhence /* = SEEK_SET */) From 9c1b2b472566b6e4f89ca6c5679b46a7b74cbfc4 Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Sat, 19 Sep 2015 18:33:45 +0300 Subject: [PATCH 5/7] remove unused includes and using statements --- src/HTSPVFS.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/HTSPVFS.cpp b/src/HTSPVFS.cpp index 567d1d3a..db1aade3 100644 --- a/src/HTSPVFS.cpp +++ b/src/HTSPVFS.cpp @@ -20,20 +20,14 @@ */ #include "platform/threads/mutex.h" -#include "platform/threads/atomics.h" -#include "platform/util/timeutils.h" -#include "platform/sockets/tcp.h" extern "C" { #include "libhts/htsmsg_binary.h" -#include "libhts/sha1.h" } #include "Tvheadend.h" -#include "client.h" using namespace std; -using namespace ADDON; using namespace PLATFORM; /* From 74e849191ca61d6198273ab0823f96fb444a47aa Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Mon, 21 Sep 2015 17:42:40 +0300 Subject: [PATCH 6/7] don't treat "channel" as required in dvrEntryAdd messages, fixes #74 --- src/Tvheadend.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Tvheadend.cpp b/src/Tvheadend.cpp index 4d0dd666..e623f038 100644 --- a/src/Tvheadend.cpp +++ b/src/Tvheadend.cpp @@ -1374,12 +1374,6 @@ void CTvheadend::ParseRecordingAddOrUpdate ( htsmsg_t *msg, bool bAdd ) return; } - if (htsmsg_get_u32(msg, "channel", &channel) && bAdd) - { - tvherror("malformed dvrEntryAdd: 'channel' missing"); - return; - } - if (htsmsg_get_s64(msg, "start", &start) && bAdd) { tvherror("malformed dvrEntryAdd: 'start' missing"); @@ -1402,10 +1396,15 @@ void CTvheadend::ParseRecordingAddOrUpdate ( htsmsg_t *msg, bool bAdd ) SRecording &rec = m_recordings[id]; rec.id = id; rec.del = false; - UPDATE(rec.channel, channel); UPDATE(rec.start, start); UPDATE(rec.stop, stop); + /* Channel is optional, it may not exist anymore */ + if (!htsmsg_get_u32(msg, "channel", &channel)) + { + UPDATE(rec.channel, channel); + } + if (!htsmsg_get_s64(msg, "startExtra", &startExtra)) { UPDATE(rec.startExtra, startExtra); From 4cf416386f37d521eb8d309922da7321ffba4c9f Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Mon, 21 Sep 2015 00:11:39 +0300 Subject: [PATCH 7/7] bumped version to 2.1.18 --- pvr.hts/addon.xml | 2 +- pvr.hts/changelog.txt | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pvr.hts/addon.xml b/pvr.hts/addon.xml index 96873ed2..6b774ac8 100644 --- a/pvr.hts/addon.xml +++ b/pvr.hts/addon.xml @@ -1,7 +1,7 @@  diff --git a/pvr.hts/changelog.txt b/pvr.hts/changelog.txt index e3531107..34353aab 100644 --- a/pvr.hts/changelog.txt +++ b/pvr.hts/changelog.txt @@ -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