Permalink
Browse files

Fix potential deadlocks.

when changing channel very quickly, and depending on when a cancel would be called, we could enter various deadlocks.
  • Loading branch information...
jyavenard committed Aug 11, 2013
1 parent 229a426 commit 0a32a1dd8058f0e1c835de28e74856943aaa12d6
Showing with 12 additions and 5 deletions.
  1. +12 −5 mythtv/libs/libmythtv/HLS/httplivestreambuffer.cpp
@@ -959,8 +959,9 @@ class StreamWorker : public MThread
}
void Seek(int val)
{
QMutexLocker lock(&m_lock);
m_lock.lock();
m_segment = val;
m_lock.unlock();
Wakeup();
}
bool IsAtEnd(bool lock = false)
@@ -1011,7 +1012,6 @@ class StreamWorker : public MThread
}
int CurrentLiveBuffer(void)
{
QMutexLocker lock(&m_lock);
return m_parent->NumSegments() - m_segment;
}
void SetBuffer(int val)
@@ -1021,6 +1021,8 @@ class StreamWorker : public MThread
}
void AddSegmentToStream(int segnum, int stream)
{
if (m_interrupted)
return;
QMutexLocker lock(&m_lock);
m_segmap.insert(segnum, stream);
}
@@ -1133,11 +1135,15 @@ class StreamWorker : public MThread
{
uint64_t bw = m_bandwidth;
int err = hls->DownloadSegmentData(dnldsegment, bw, m_stream);
if (m_interrupted)
{
// interrupt only
Wakeup();
break;
}
bw = AverageNewBandwidth(bw);
if (err != RET_OK)
{
if (m_interrupted)
break;
retries++;
LOG(VB_PLAYBACK, LOG_DEBUG, LOC +
QString("download failed, retry #%1").arg(retries));
@@ -1269,8 +1275,9 @@ class PlaylistWorker : public MThread
void Wakeup(void)
{
QMutexLocker lock(&m_lock);
m_lock.lock();
m_wokenup = true;
m_lock.unlock();
// send a wake signal
m_waitcond.wakeAll();
}

0 comments on commit 0a32a1d

Please sign in to comment.