Permalink
Browse files

Live TV: Disable the oldfile ringbuffer optimization for program tran…

…sitions.

Refs #10490.  Using the LiveTVChain in the frontend ringbuffer to
control the oldfile flag in the backend ringbuffer is just too tricky
to get right and too easy to subsequently break, so we disable that
mechanism completely.  The consequence is that the backend ringbuffer
may cause a 0.3 second pause waiting for more data at true EOF (but
buffering on the frontend will probably hide that).  If the oldfile
optimization during live TV is really needed, it's probably better for
the backend recorded to control it.
  • Loading branch information...
stichnot committed Apr 22, 2012
1 parent a72b694 commit 2e56c2563a75ec2c3c97996de838119f0ea6de6a
Showing with 24 additions and 10 deletions.
  1. +24 −1 mythtv/libs/libmythtv/livetvchain.cpp
  2. +0 −9 mythtv/libs/libmythtv/ringbuffer.cpp
@@ -37,23 +37,31 @@ LiveTVChain::~LiveTVChain()
QString LiveTVChain::InitializeNewChain(const QString &seed)
{
+ QMutexLocker lock(&m_lock);
+
QDateTime curdt = QDateTime::currentDateTime();
m_id = QString("live-%1-%2").arg(seed).arg(curdt.toString(Qt::ISODate));
return m_id;
}
void LiveTVChain::SetHostPrefix(const QString &prefix)
{
+ QMutexLocker lock(&m_lock);
+
m_hostprefix = prefix;
}
void LiveTVChain::SetCardType(const QString &type)
{
+ QMutexLocker lock(&m_lock);
+
m_cardtype = type;
}
void LiveTVChain::LoadFromExistingChain(const QString &id)
{
+ QMutexLocker lock(&m_lock);
+
m_id = id;
ReloadAll();
}
@@ -188,6 +196,8 @@ void LiveTVChain::DeleteProgram(ProgramInfo *pginfo)
void LiveTVChain::BroadcastUpdate(void)
{
+ QMutexLocker lock(&m_lock);
+
QString message = QString("LIVETV_CHAIN UPDATE %1").arg(m_id);
MythEvent me(message);
gCoreContext->dispatch(me);
@@ -357,6 +367,8 @@ int LiveTVChain::GetLengthAtCurPos(void)
int LiveTVChain::TotalSize(void) const
{
+ QMutexLocker lock(&m_lock);
+
return m_chain.count();
}
@@ -373,6 +385,8 @@ void LiveTVChain::SetProgram(const ProgramInfo &pginfo)
bool LiveTVChain::HasNext(void) const
{
+ QMutexLocker lock(&m_lock);
+
return ((int)m_chain.count() - 1 > m_curpos);
}
@@ -397,9 +411,10 @@ void LiveTVChain::ClearSwitch(void)
ProgramInfo *LiveTVChain::GetSwitchProgram(bool &discont, bool &newtype,
int &newid)
{
- ReloadAll();
QMutexLocker lock(&m_lock);
+ ReloadAll();
+
if (m_switchid < 0 || m_curpos == m_switchid)
{
ClearSwitch();
@@ -506,6 +521,8 @@ void LiveTVChain::SwitchTo(int num)
*/
void LiveTVChain::SwitchToNext(bool up)
{
+ QMutexLocker lock(&m_lock);
+
#if 0
LOG(VB_PLAYBACK, LOG_DEBUG, LOC + "SwitchToNext("<<(up?"up":"down")<<")");
#endif
@@ -517,12 +534,16 @@ void LiveTVChain::SwitchToNext(bool up)
void LiveTVChain::JumpTo(int num, int pos)
{
+ QMutexLocker lock(&m_lock);
+
m_jumppos = pos;
SwitchTo(num);
}
void LiveTVChain::JumpToNext(bool up, int pos)
{
+ QMutexLocker lock(&m_lock);
+
m_jumppos = pos;
SwitchToNext(up);
}
@@ -532,6 +553,8 @@ void LiveTVChain::JumpToNext(bool up, int pos)
*/
int LiveTVChain::GetJumpPos(void)
{
+ QMutexLocker lock(&m_lock);
+
int ret = m_jumppos;
m_jumppos = 0;
return ret;
@@ -728,7 +728,6 @@ void RingBuffer::run(void)
struct timeval lastread, now;
int readtimeavg = 300;
bool ignore_for_read_timing = true;
- QString did_set_oldfile("");
gettimeofday(&lastread, NULL); // this is just to keep gcc happy
@@ -847,14 +846,6 @@ void RingBuffer::run(void)
"Reading enough data to start playback");
}
- if (did_set_oldfile != filename && remotefile && livetvchain &&
- livetvchain->HasNext())
- {
- LOG(VB_FILE, LOG_DEBUG, LOC + QString("did_set_oldfile=%1").arg(did_set_oldfile));
- remotefile->SetTimeout(true);
- did_set_oldfile = filename;
- }
-
LOG(VB_FILE, LOG_DEBUG, LOC +
QString("safe_read(...@%1, %2) -- begin")
.arg(rbwpos).arg(totfree));

0 comments on commit 2e56c25

Please sign in to comment.