Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix seek when close to end of program

When seeking repeatedly close to the end of the program in liveTV, it would cause playback to jump immediately to the next program.
The cause was RingBuffer:: IsNearEnd didn’t report if we were close to the end of the file, but if there was little left to read in the ringbuffer. However, when seeking the buffer can be emptied, causing IsNearEnd to always return true
Additionally, with very low bitrate stream (like with the HLS recorder), we could sometimes miss over significant length of video.

A positive side effect is that there’s now no pause whatsoever between two liveTV program,s at worse about 20 frames dropped.

Ref #12076
  • Loading branch information...
commit c24e2e72966f0936f7dbb3f79f421038dbd41579 1 parent ed52e84
@jyavenard jyavenard authored
View
4 mythtv/libs/libmythtv/mythplayer.cpp
@@ -2768,10 +2768,10 @@ void MythPlayer::JumpToProgram(void)
ChangeSpeed();
// check that we aren't too close to the end of program.
- // and if so set it to 15s from the end if completed recordings
+ // and if so set it to 10s from the end if completed recordings
// or 3s if live
long long duration = player_ctx->tvchain->GetLengthAtCurPos();
- int maxpos = player_ctx->tvchain->HasNext() ? 15 : 3;
+ int maxpos = player_ctx->tvchain->HasNext() ? 10 : 3;
if (nextpos > (duration - maxpos))
{
View
15 mythtv/libs/libmythtv/ringbuffer.cpp 100755 → 100644
@@ -421,8 +421,13 @@ void RingBuffer::CalcReadAheadThresh(void)
bool RingBuffer::IsNearEnd(double fps, uint vvf) const
{
rwlock.lockForRead();
- int sz = ReadBufAvail();
- uint rbs = readblocksize;
+ long long sz2 = ReadBufAvail();
+ poslock.lockForRead();
+ long long rp = readpos;
+ poslock.unlock();
+ long long sz = GetRealFileSize() - rp;
+ sz = max(sz, sz2);
+
// telecom kilobytes (i.e. 1000 per k not 1024)
uint tmp = (uint) max(abs(rawbitrate * playspeed), 0.5f * rawbitrate);
uint kbits_per_sec = min(rawbitrate * 3, tmp);
@@ -434,11 +439,11 @@ bool RingBuffer::IsNearEnd(double fps, uint vvf) const
double bytes_per_frame = kbits_per_sec * (1000.0/8.0) / fps;
double readahead_frames = sz / bytes_per_frame;
- bool near_end = ((vvf + readahead_frames) < 20.0) || (sz < rbs*1.5);
+ bool near_end = (vvf + readahead_frames) < 20.0;
LOG(VB_PLAYBACK, LOG_INFO, LOC + "IsReallyNearEnd()" +
QString(" br(%1KB)").arg(kbits_per_sec/8) +
- QString(" sz(%1KB)").arg(sz / 1000) +
+ QString(" sz(%1KB)").arg(sz / 1000LL) +
QString(" vfl(%1)").arg(vvf) +
QString(" frh(%1)").arg(((uint)readahead_frames)) +
QString(" ne:%1").arg(near_end));
@@ -926,7 +931,7 @@ void RingBuffer::run(void)
rbwlock.unlock();
poslock.unlock();
- LOG(VB_FILE, LOG_DEBUG, LOC +
+ LOG(VB_FILE, LOG_INFO, LOC +
QString("total read so far: %1 bytes")
.arg(internalreadpos));
}
Please sign in to comment.
Something went wrong with that request. Please try again.