Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

RingBuffer: Optimize readahead buffer to completely fill if readblock…

…size > 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 d950637 from master.
  • Loading branch information...
commit 1cf65bccbd186fcfdb8d55e31232a8cfe6fdb1a3 1 parent c212ca8
tralph tralph authored

Showing 1 changed file with 8 additions and 5 deletions. Show diff stats Hide diff stats

  1. +8 5 mythtv/libs/libmythtv/RingBuffer.cpp
13 mythtv/libs/libmythtv/RingBuffer.cpp
@@ -1147,8 +1147,7 @@ void RingBuffer::run(void)
1147 1147
1148 1148 // These are conditions where we don't want to go through
1149 1149 // the loop if they are true.
1150   - if (((totfree < readblocksize) && readsallowed) ||
1151   - (ignorereadpos >= 0) || commserror || stopreads)
  1150 + if ((ignorereadpos >= 0) || commserror || stopreads)
1152 1151 {
1153 1152 ignore_for_read_timing |=
1154 1153 (ignorereadpos >= 0) || commserror || stopreads;
@@ -1165,12 +1164,16 @@ void RingBuffer::run(void)
1165 1164 totfree = ReadBufFree();
1166 1165 }
1167 1166
  1167 + const uint KB32 = 32*1024;
1168 1168 int read_return = -1;
1169   - if (totfree >= readblocksize && !commserror &&
  1169 + if (totfree >= KB32 && !commserror &&
1170 1170 !ateof && !setswitchtonext)
1171 1171 {
1172 1172 // limit the read size
1173   - totfree = readblocksize;
  1173 + if (readblocksize > totfree)
  1174 + totfree = (int)(totfree / KB32) * KB32; // must be multiple of 32KB
  1175 + else
  1176 + totfree = readblocksize;
1174 1177
1175 1178 // adapt blocksize
1176 1179 gettimeofday(&now, NULL);
@@ -1205,7 +1208,7 @@ void RingBuffer::run(void)
1205 1208 readtimeavg = 225;
1206 1209 }
1207 1210 }
1208   - ignore_for_read_timing = false;
  1211 + ignore_for_read_timing = (totfree < readblocksize) ? true : false;
1209 1212 lastread = now;
1210 1213
1211 1214 rbwlock.lockForRead();

0 comments on commit 1cf65bc

Please sign in to comment.
Something went wrong with that request. Please try again.