summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaylor Ralph <tralph@mythtv.org>2011-08-12 09:55:42 (GMT)
committer Taylor Ralph <tralph@mythtv.org>2011-08-12 09:55:42 (GMT)
commit1cf65bccbd186fcfdb8d55e31232a8cfe6fdb1a3 (patch)
treee9395e4956ea75803d164730601b4dde7fabc788
parentc212ca818ff4e4c053f8aa1cfc079902e74e2cfe (diff)
RingBuffer: Optimize readahead buffer to completely fill if readblocksize > totfree.
This allows the readahead buffer to fill if the readblocksize is greater than buffer free by temporarily reducing the read size to a size that will fit. With this change the buffers reach 99% for all videos. Backports d9506371d04a0dff4f6358e1f7cc81781ff1ae40 from master.
-rw-r--r--mythtv/libs/libmythtv/RingBuffer.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/mythtv/libs/libmythtv/RingBuffer.cpp b/mythtv/libs/libmythtv/RingBuffer.cpp
index cb077f7..51af10f 100644
--- a/mythtv/libs/libmythtv/RingBuffer.cpp
+++ b/mythtv/libs/libmythtv/RingBuffer.cpp
@@ -1147,8 +1147,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;
@@ -1165,12 +1164,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);
@@ -1205,7 +1208,7 @@ void RingBuffer::run(void)
readtimeavg = 225;
}
}
- ignore_for_read_timing = false;
+ ignore_for_read_timing = (totfree < readblocksize) ? true : false;
lastread = now;
rbwlock.lockForRead();