Skip to content
Browse files

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...
1 parent 2cc858c commit 91ec76e8afba1833a7cb64f17429910f29b39404 @stichnot stichnot committed Jan 5, 2013
Showing with 16 additions and 11 deletions.
  1. +4 −1 mythtv/libs/libmythtv/mythplayer.cpp
  2. +12 −10 mythtv/libs/libmythtv/tv_play.cpp
View
5 mythtv/libs/libmythtv/mythplayer.cpp
@@ -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))
@@ -2907,6 +2908,7 @@ void MythPlayer::EventLoop(void)
return;
}
+ Pause();
SetPlaying(false);
return;
}
@@ -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)
View
22 mythtv/libs/libmythtv/tv_play.cpp
@@ -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),
@@ -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)
{
@@ -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)

0 comments on commit 91ec76e

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