From 91ec76e8afba1833a7cb64f17429910f29b39404 Mon Sep 17 00:00:00 2001 From: Jim Stichnoth Date: Sat, 5 Jan 2013 08:21:19 -0800 Subject: [PATCH] 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. --- mythtv/libs/libmythtv/mythplayer.cpp | 5 ++++- mythtv/libs/libmythtv/tv_play.cpp | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp index 8dde46a047c..56eeb53d4a7 100644 --- a/mythtv/libs/libmythtv/mythplayer.cpp +++ b/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) diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp index 26f1182e2d6..19aed79f1c2 100644 --- a/mythtv/libs/libmythtv/tv_play.cpp +++ b/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)