diff --git a/mythtv/libs/libmythtv/ringbuffer.cpp b/mythtv/libs/libmythtv/ringbuffer.cpp index 72e6d4e..9c54c27 100644 --- a/mythtv/libs/libmythtv/ringbuffer.cpp +++ b/mythtv/libs/libmythtv/ringbuffer.cpp @@ -27,8 +27,8 @@ #include "compat.h" #include "util.h" -// about one second at 35mbit -const uint RingBuffer::kBufferSize = 4 * 1024 * 1024; +// about two seconds at 35mbit +const uint RingBuffer::kBufferSize = 8 * 1024 * 1024; const int RingBuffer::kDefaultOpenTimeout = 2000; // ms const int RingBuffer::kLiveTVOpenTimeout = 10000; @@ -181,7 +181,8 @@ RingBuffer::RingBuffer(void) : ateof(false), readsallowed(false), setswitchtonext(false), rawbitrate(8000), playspeed(1.0f), - fill_threshold(65536), fill_min(-1), + slow_threshold(65536), very_slow_threshold(65536), + fill_min(-1), readblocksize(CHUNK), wanttoread(0), numfailures(0), commserror(false), oldfile(false), livetvchain(NULL), @@ -304,8 +305,9 @@ void RingBuffer::UpdatePlaySpeed(float play_speed) } /** \fn RingBuffer::CalcReadAheadThresh(void) - * \brief Calculates fill_min, fill_threshold, and readblocksize - * from the estimated effective bitrate of the stream. + * \brief Calculates fill_min, slow_threshold, very_slow_threshold, + * and readblocksize from the estimated effective bitrate + * of the stream. * * WARNING: Must be called with rwlock in write lock state. * @@ -318,7 +320,8 @@ void RingBuffer::CalcReadAheadThresh(void) readblocksize = max(readblocksize, CHUNK); // loop without sleeping if the buffered data is less than this - fill_threshold = kBufferSize / 8; + slow_threshold = 1 * kBufferSize / 4; + very_slow_threshold = 7 * kBufferSize / 8; const uint KB32 = 32*1024; const uint KB64 = 64*1024; @@ -345,7 +348,7 @@ void RingBuffer::CalcReadAheadThresh(void) VERBOSE(VB_FILE, LOC + QString("CalcReadAheadThresh(%1 Kb)\n\t\t\t -> " "threshhold(%2 KB) min read(%3 KB) blk size(%4 KB)") - .arg(estbitrate).arg(fill_threshold/1024) + .arg(estbitrate).arg(very_slow_threshold/1024) .arg(fill_min/1024).arg(readblocksize/1024)); } @@ -834,9 +837,13 @@ void RingBuffer::run(void) { // yield if we have nothing to do... if (!request_pause && - (used >= fill_threshold || ateof || setswitchtonext)) + (used >= very_slow_threshold || ateof || setswitchtonext)) { - generalWait.wait(&rwlock, 1000); + generalWait.wait(&rwlock, 500); + } + else if (used >= slow_threshold) + { + generalWait.wait(&rwlock, 50); } } } diff --git a/mythtv/libs/libmythtv/ringbuffer.h b/mythtv/libs/libmythtv/ringbuffer.h index 69a5c0b..4dce566 100644 --- a/mythtv/libs/libmythtv/ringbuffer.h +++ b/mythtv/libs/libmythtv/ringbuffer.h @@ -188,7 +188,8 @@ class MTV_PUBLIC RingBuffer : protected QThread bool ignorereadahead; // protected by rwlock uint rawbitrate; // protected by rwlock float playspeed; // protected by rwlock - int fill_threshold; // protected by rwlock + int slow_threshold; // protected by rwlock + int very_slow_threshold;// protected by rwlock int fill_min; // protected by rwlock int readblocksize; // protected by rwlock int wanttoread; // protected by rwlock