rendered paste bodydiff --git a/mythtv/libs/libmythtv/ringbuffer.cpp b/mythtv/libs/libmythtv/ringbuffer.cpp
index e361be2..89ce76a 100644
--- a/mythtv/libs/libmythtv/ringbuffer.cpp
+++ b/mythtv/libs/libmythtv/ringbuffer.cpp
@@ -339,7 +339,7 @@ void RingBuffer::CalcReadAheadThresh(void)
readblocksize = max(readblocksize, CHUNK);
// loop without sleeping if the buffered data is less than this
- fill_threshold = 3 * bufferSize / 8;
+ fill_threshold = 7 * bufferSize / 8;
const uint KB32 = 32*1024;
const uint KB64 = 64*1024;
@@ -667,15 +667,19 @@ void RingBuffer::CreateReadAheadBuffer(void)
return;
}
+VERBOSE(VB_IMPORTANT, LOC + QString("read %1 write %2 internal %3")
+ .arg(rbrpos).arg(rbwpos).arg(internalreadpos));
+
bufferSize = newsize;
if (readAheadBuffer)
{
+ bool ahead = rbrpos > rbwpos;
char* newbuffer = new char[bufferSize + 1024];
memcpy(newbuffer, readAheadBuffer + rbwpos, oldsize - rbwpos);
memcpy(newbuffer + (oldsize - rbwpos), readAheadBuffer, rbwpos);
delete [] readAheadBuffer;
readAheadBuffer = newbuffer;
- rbrpos = rbrpos + oldsize - rbwpos;
+ rbrpos = ahead ? (rbrpos - rbwpos) : (rbrpos + oldsize - rbwpos);
rbwpos = oldsize;
}
else
@@ -686,8 +690,11 @@ void RingBuffer::CreateReadAheadBuffer(void)
poslock.unlock();
rwlock.unlock();
- VERBOSE(VB_FILE, LOC + QString("Created readAheadBuffer: %1Mb")
+ VERBOSE(VB_IMPORTANT, LOC + QString("Created readAheadBuffer: %1Mb")
.arg(newsize >> 20));
+
+VERBOSE(VB_IMPORTANT, LOC + QString("read %1 write %2 internal %3")
+ .arg(rbrpos).arg(rbwpos).arg(internalreadpos));
}
void RingBuffer::run(void)
@@ -905,7 +912,7 @@ void RingBuffer::run(void)
if (!request_pause &&
(used >= fill_threshold || ateof || setswitchtonext))
{
- generalWait.wait(&rwlock, 1000);
+ generalWait.wait(&rwlock, 10);
}
else if (readsallowed)
{ // if reads are allowed release the lock and yield so the