Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix LiveTV when using HLS
IPTVFeederLive::Open is expected to return immediately and not to block for a long time, otherwise the Event thread isn't running and cause the frontend to disconnect prematurely.
Thanks to DanielK for his hint and feedback.

Fixes #10934
  • Loading branch information
jyavenard committed Aug 9, 2012
1 parent b8e7df5 commit 8c551e6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
17 changes: 16 additions & 1 deletion mythtv/libs/libmythtv/HLS/httplivestreambuffer.cpp
Expand Up @@ -1470,6 +1470,21 @@ HLSRingBuffer::HLSRingBuffer(const QString &lfilename) :
OpenFile(lfilename); OpenFile(lfilename);
} }


HLSRingBuffer::HLSRingBuffer(const QString &lfilename, bool open) :
RingBuffer(kRingBuffer_HLS),
m_playback(new HLSPlayback()),
m_meta(false), m_error(false), m_aesmsg(false),
m_startup(0), m_bitrate(0), m_seektoend(false),
m_streamworker(NULL), m_playlistworker(NULL), m_fd(NULL),
m_interrupted(false)
{
startreadahead = false;
if (open)
{
OpenFile(lfilename);
}
}

HLSRingBuffer::~HLSRingBuffer() HLSRingBuffer::~HLSRingBuffer()
{ {
QWriteLocker lock(&rwlock); QWriteLocker lock(&rwlock);
Expand Down Expand Up @@ -2195,7 +2210,7 @@ int HLSRingBuffer::Prefetch(int count)
.arg(count)); .arg(count));
m_streamworker->Lock(); m_streamworker->Lock();
m_streamworker->Wakeup(); m_streamworker->Wakeup();
while (!m_error && (retries < 20) && while (!m_error && !m_interrupted && (retries < 20) &&
(m_streamworker->CurrentPlaybackBuffer(false) < count) && (m_streamworker->CurrentPlaybackBuffer(false) < count) &&
!m_streamworker->IsAtEnd()) !m_streamworker->IsAtEnd())
{ {
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/HLS/httplivestreambuffer.h
Expand Up @@ -44,6 +44,7 @@ class HLSRingBuffer : public RingBuffer
{ {
public: public:
HLSRingBuffer(const QString &lfilename); HLSRingBuffer(const QString &lfilename);
HLSRingBuffer(const QString &lfilename, bool open);
virtual ~HLSRingBuffer(); virtual ~HLSRingBuffer();


virtual bool IsOpen(void) const; virtual bool IsOpen(void) const;
Expand Down
13 changes: 10 additions & 3 deletions mythtv/libs/libmythtv/iptv/iptvfeederhls.cpp
Expand Up @@ -23,7 +23,7 @@


IPTVFeederHLS::IPTVFeederHLS() : IPTVFeederHLS::IPTVFeederHLS() :
m_buffer(new uint8_t[BUFFER_SIZE]), m_hls(NULL), m_buffer(new uint8_t[BUFFER_SIZE]), m_hls(NULL),
m_interrupted(false), m_running(false) m_interrupted(false), m_running(false), m_init(false)
{ {
} }


Expand Down Expand Up @@ -58,7 +58,8 @@ bool IPTVFeederHLS::Open(const QString &url)
return true; return true;
} }


m_hls = new HLSRingBuffer(url); m_url = url;
m_hls = new HLSRingBuffer(url, false);


LOG(VB_RECORD, LOG_INFO, LOC + "Open() -- end"); LOG(VB_RECORD, LOG_INFO, LOC + "Open() -- end");


Expand All @@ -73,7 +74,12 @@ void IPTVFeederHLS::Run(void)
m_lock.unlock(); m_lock.unlock();


m_hls->Continue(); m_hls->Continue();
while (!m_interrupted) if (!m_init)
{
m_init = m_hls->OpenFile(m_url);
}

while (!m_interrupted && m_init)
{ {
if (m_hls == NULL) if (m_hls == NULL)
break; break;
Expand Down Expand Up @@ -130,6 +136,7 @@ void IPTVFeederHLS::Close(void)
QMutexLocker lock(&m_lock); QMutexLocker lock(&m_lock);
delete m_hls; delete m_hls;
m_hls = NULL; m_hls = NULL;
m_init = false;


LOG(VB_RECORD, LOG_INFO, LOC + "Close() -- end"); LOG(VB_RECORD, LOG_INFO, LOC + "Close() -- end");
} }
2 changes: 2 additions & 0 deletions mythtv/libs/libmythtv/iptv/iptvfeederhls.h
Expand Up @@ -34,11 +34,13 @@ class IPTVFeederHLS : public IPTVFeederLive


private: private:
uint8_t *m_buffer; uint8_t *m_buffer;
QString m_url;
HLSRingBuffer *m_hls; HLSRingBuffer *m_hls;
mutable QMutex m_lock; mutable QMutex m_lock;
QWaitCondition m_waitcond; QWaitCondition m_waitcond;
bool m_interrupted; bool m_interrupted;
bool m_running; bool m_running;
bool m_init;
}; };


#endif #endif

0 comments on commit 8c551e6

Please sign in to comment.