From 316718a140ed5c498b8b84d1c6d0c11fc2838580 Mon Sep 17 00:00:00 2001 From: Mark Kendall Date: Tue, 15 Feb 2011 10:03:22 +0800 Subject: [PATCH] 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 e45da57be5cee702fe9d --- mythtv/libs/libmythtv/RingBuffer.cpp | 33 +++++++++++----------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/mythtv/libs/libmythtv/RingBuffer.cpp b/mythtv/libs/libmythtv/RingBuffer.cpp index be291242f2a..8b59616d996 100644 --- a/mythtv/libs/libmythtv/RingBuffer.cpp +++ b/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; } }