Skip to content

Commit

Permalink
Faster pausing when switching programs in live tv.
Browse files Browse the repository at this point in the history
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 committed Feb 15, 2011
1 parent ad1543a commit 316718a
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions mythtv/libs/libmythtv/RingBuffer.cpp
Expand Up @@ -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 &&
Expand All @@ -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)
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 316718a

Please sign in to comment.