diff --git a/mythtv/libs/libmythtv/ringbuffer.cpp b/mythtv/libs/libmythtv/ringbuffer.cpp index a288fe9733c..dbe12be9c56 100644 --- a/mythtv/libs/libmythtv/ringbuffer.cpp +++ b/mythtv/libs/libmythtv/ringbuffer.cpp @@ -734,8 +734,7 @@ void RingBuffer::run(void) // These are conditions where we don't want to go through // the loop if they are true. - if (((totfree < readblocksize) && readsallowed) || - (ignorereadpos >= 0) || commserror || stopreads) + if ((ignorereadpos >= 0) || commserror || stopreads) { ignore_for_read_timing |= (ignorereadpos >= 0) || commserror || stopreads; @@ -752,12 +751,16 @@ void RingBuffer::run(void) totfree = ReadBufFree(); } + const uint KB32 = 32*1024; int read_return = -1; - if (totfree >= readblocksize && !commserror && + if (totfree >= KB32 && !commserror && !ateof && !setswitchtonext) { // limit the read size - totfree = readblocksize; + if (readblocksize > totfree) + totfree = (int)(totfree / KB32) * KB32; // must be multiple of 32KB + else + totfree = readblocksize; // adapt blocksize gettimeofday(&now, NULL); @@ -792,7 +795,7 @@ void RingBuffer::run(void) readtimeavg = 225; } } - ignore_for_read_timing = false; + ignore_for_read_timing = (totfree < readblocksize) ? true : false; lastread = now; rbwlock.lockForRead();