Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Play closer to the end of the video.
Refs #6974.  When the end of the recording is reached, don't exit the
player immediately.  Instead, pause playback and let exiting be
handled by either the end-of-playback timer event or the
end-of-recording-delete-prompt timer event.  This removes IsNearEnd()
from end-of-playback consideration, as well as the randomness of where
in the 250ms window the timer events fire.

IsNearEnd() is still used in other places (e.g. to control playback
speed and bookmarking behavior near the end of a recording).  The
IsNearEnd() calculation is changed to depend on the number of frames
played by the player rather than the number of frames read by the
decoder thread, making IsNearEnd() more predictable and reliable.

Note that this does not address the original issue in #6974, which
involves allowing the accumulated decoded frames to be displayed after
the decoder reaches EOF.
  • Loading branch information
stichnot committed Jan 5, 2013
1 parent 2cc858c commit 91ec76e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
5 changes: 4 additions & 1 deletion mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -2891,7 +2891,8 @@ void MythPlayer::EventLoop(void)
}

// Handle end of file
if (GetEof() && !allpaused)
if ((GetEof() && !allpaused) ||
(!GetEditMode() && framesPlayed >= deleteMap.GetLastFrame()))
{
#ifdef USING_MHEG
if (interactiveTV && interactiveTV->StreamStarted(false))
Expand All @@ -2907,6 +2908,7 @@ void MythPlayer::EventLoop(void)
return;
}

Pause();
SetPlaying(false);
return;
}
Expand Down Expand Up @@ -3687,6 +3689,7 @@ bool MythPlayer::IsNearEnd(void)
bool watchingTV = IsWatchingInprogress();

framesRead = decoder->GetFramesRead();
framesRead = framesPlayed;

if (!player_ctx->IsPIP() &&
player_ctx->GetState() == kState_WatchingPreRecorded)
Expand Down
22 changes: 12 additions & 10 deletions mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -951,7 +951,7 @@ TV::TV(void)
tryUnflaggedSkip(false),
smartForward(false),
ff_rew_repos(1.0f), ff_rew_reverse(false),
jumped_back(false),
jumped_back(false), // XXX unused, remove this field
vbimode(VBIMode::None),
// State variables
switchToInputId(0),
Expand Down Expand Up @@ -3300,6 +3300,12 @@ void TV::HandleEndOfPlaybackTimerEvent(void)
continue;
}

// If the end of playback is destined to pop up the end of
// recording delete prompt, then don't exit the player here.
if (ctx->GetState() == kState_WatchingPreRecorded &&
db_end_of_rec_exit_prompt && !inPlaylist && !underNetworkControl)
continue;

ForceNextStateNone(ctx);
if (mctx == ctx)
{
Expand Down Expand Up @@ -3351,16 +3357,12 @@ void TV::HandleEndOfRecordingExitPromptTimerEvent(void)
}
ReturnOSDLock(mctx, osd);

bool do_prompt = false;
bool do_prompt;
mctx->LockDeletePlayer(__FILE__, __LINE__);
if (mctx->GetState() == kState_WatchingPreRecorded && mctx->player)
{
if (!mctx->player->IsNearEnd())
jumped_back = false;

do_prompt = mctx->player->IsNearEnd() && !jumped_back &&
!mctx->player->IsEmbedding() && !mctx->player->IsPaused();
}
do_prompt = (mctx->GetState() == kState_WatchingPreRecorded &&
mctx->player &&
!mctx->player->IsEmbedding() &&
!mctx->player->IsPlaying());
mctx->UnlockDeletePlayer(__FILE__, __LINE__);

if (do_prompt)
Expand Down

0 comments on commit 91ec76e

Please sign in to comment.