Skip to content
Permalink
Browse files

Faster pausing when switching programs in live tv.

See http://code.mythtv.org/trac/ticket/9511 and
http://code.mythtv.org/trac/ticket/9546 for details.

In summary, if we are near the end of the buffer when in live tv, force
the reload of the tv chain and return immediately from
RingBuffer::WaitFroAvail - before we hit the 'generalWait' condition.

Manually cherry-picked from e45da57
  • Loading branch information
Mark Kendall
Mark Kendall committed Feb 15, 2011
1 parent ad1543a commit 316718a140ed5c498b8b84d1c6d0c11fc2838580
Showing with 13 additions and 20 deletions.
  1. +13 −20 mythtv/libs/libmythtv/RingBuffer.cpp
@@ -1405,6 +1405,14 @@ bool RingBuffer::WaitForAvail(int count)
int avail = ReadBufAvail();
count = (ateof && avail < count) ? avail : count;

if (livetvchain && setswitchtonext && avail < count)
{
VERBOSE(VB_IMPORTANT, LOC + "Checking to see if there's a "
"new livetv program to switch to..");
livetvchain->ReloadAll();
return false;
}

MythTimer t;
t.start();
while ((avail < count) && !stopreads &&
@@ -1414,7 +1422,7 @@ bool RingBuffer::WaitForAvail(int count)
generalWait.wait(&rwlock, 250);
avail = ReadBufAvail();

if ((ateof || setswitchtonext) && avail < count)
if (ateof && avail < count)
count = avail;

if (avail < count)
@@ -1433,28 +1441,13 @@ bool RingBuffer::WaitForAvail(int count)
" seconds for data \n\t\t\tto become available..." +
QString(" %2 < %3")
.arg(avail).arg(count));
if (livetvchain)
{
VERBOSE(VB_IMPORTANT, "Checking to see if there's a "
"new livetv program to switch to..");
livetvchain->ReloadAll();
}
}

bool quit = livetvchain && (livetvchain->NeedsToSwitch() ||
livetvchain->NeedsToJump() ||
setswitchtonext);

if (elapsed > 16000 || quit)
if (elapsed > 16000)
{
if (!quit)
VERBOSE(VB_IMPORTANT, LOC_ERR + "Waited " +
QString("%1").arg(elapsed/1000) +
" seconds for data, aborting.");
else
VERBOSE(VB_IMPORTANT, LOC + "Timing out wait due to "
"impending livetv switch.");

VERBOSE(VB_IMPORTANT, LOC_ERR + "Waited " +
QString("%1").arg(elapsed/1000) +
" seconds for data, aborting.");
return false;
}
}

0 comments on commit 316718a

Please sign in to comment.
You can’t perform that action at this time.