From f77d001e945387ecb00fd88c53b45bb74ae0f396 Mon Sep 17 00:00:00 2001 From: Jim Stichnoth Date: Sat, 25 Feb 2012 06:32:43 -0800 Subject: [PATCH] Fix minor problems editing in-progress recordings. Revert 5d7c01d08, and add logic that also updates the edit bar when the total number of frames in the recording changes. Modify 1ce3d21e3 to use a better test for an in-progress recording. If the recording finishes during the editing session, the original test would continue to indicate that the recording was in-progress. Binary version is updated. Refs #10329. --- mythtv/libs/libmythbase/mythversion.h | 2 +- mythtv/libs/libmythtv/deletemap.cpp | 6 ++++-- mythtv/libs/libmythtv/deletemap.h | 6 +++++- mythtv/libs/libmythtv/mythplayer.cpp | 28 +++++++++++++-------------- mythtv/libs/libmythtv/mythplayer.h | 1 + 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/mythtv/libs/libmythbase/mythversion.h b/mythtv/libs/libmythbase/mythversion.h index 3b34dc3a210..43ace75bdbb 100644 --- a/mythtv/libs/libmythbase/mythversion.h +++ b/mythtv/libs/libmythbase/mythversion.h @@ -12,7 +12,7 @@ /// Update this whenever the plug-in API changes. /// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and /// libmythui class methods used by plug-ins. -#define MYTH_BINARY_VERSION "0.25.20120225-1" +#define MYTH_BINARY_VERSION "0.25.20120225-2" /** \brief Increment this whenever the MythTV network protocol changes. * diff --git a/mythtv/libs/libmythtv/deletemap.cpp b/mythtv/libs/libmythtv/deletemap.cpp index 5bfa7564d0d..84b20bcb0f9 100644 --- a/mythtv/libs/libmythtv/deletemap.cpp +++ b/mythtv/libs/libmythtv/deletemap.cpp @@ -5,6 +5,7 @@ #include "mythcontext.h" #include "osd.h" #include "deletemap.h" +#include "mythplayer.h" #define LOC QString("DelMap: ") #define EDIT_CHECK do { \ @@ -92,7 +93,7 @@ bool DeleteMap::HandleAction(QString &action, uint64_t frame, Add(frame, total, MARK_CUT_START, QObject::tr("Cut to End")); // If the recording is still in progress, add an explicit end // mark at the end. - if (m_ctx->playingInfo->GetRecordingStatus() == rsRecording) + if (m_ctx->player && m_ctx->player->IsWatchingInprogress()) Add(total - 1, total, MARK_CUT_END, ""); } else if (action == "NEWCUT") @@ -172,9 +173,10 @@ void DeleteMap::UpdateOSD(uint64_t frame, uint64_t total, double frame_rate, posMap.insert("position", (float)((double)frame/(double)total)); osd->SetValues("osd_program_editor", posMap, kOSDTimeout_None); osd->SetText("osd_program_editor", infoMap, kOSDTimeout_None); - //if (m_changed) + if (m_changed || total != m_cachedTotalForOSD) osd->SetRegions("osd_program_editor", m_deleteMap, total); m_changed = false; + m_cachedTotalForOSD = total; } /// Set the edit mode and optionally hide the edit mode OSD. diff --git a/mythtv/libs/libmythtv/deletemap.h b/mythtv/libs/libmythtv/deletemap.h index f111ca3b57d..e64d1a2372a 100644 --- a/mythtv/libs/libmythtv/deletemap.h +++ b/mythtv/libs/libmythtv/deletemap.h @@ -23,7 +23,10 @@ class MTV_PUBLIC DeleteMap m_nextCutStartIsValid(false), m_nextCutStart(0), m_changed(true), m_seekamountpos(4), m_seekamount(30), - m_ctx(0), m_undoStackPointer(-1) { Push(""); } + m_ctx(0), m_cachedTotalForOSD(0), m_undoStackPointer(-1) + { + Push(""); + } void SetPlayerContext(PlayerContext *ctx) { m_ctx = ctx; } bool HandleAction(QString &action, uint64_t frame, uint64_t played, @@ -90,6 +93,7 @@ class MTV_PUBLIC DeleteMap int m_seekamountpos; int m_seekamount; PlayerContext *m_ctx; + uint64_t m_cachedTotalForOSD; // Invariant: m_undoStack[m_undoStackPointer].deleteMap == m_deleteMap QVector m_undoStack; diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp index 7957a617959..57320b7ec0d 100644 --- a/mythtv/libs/libmythtv/mythplayer.cpp +++ b/mythtv/libs/libmythtv/mythplayer.cpp @@ -310,6 +310,12 @@ void MythPlayer::SetWatchingRecording(bool mode) decoder->setWatchingRecording(mode); } +bool MythPlayer::IsWatchingInprogress(void) const +{ + return watchingrecording && player_ctx->recorder && + player_ctx->recorder->IsValidRecorder(); +} + void MythPlayer::PauseBuffer(void) { bufferPauseLock.lock(); @@ -2692,8 +2698,7 @@ void MythPlayer::EventLoop(void) SetScanType(resetScan); // refresh the position map for an in-progress recording while editing - if (hasFullPositionMap && watchingrecording && player_ctx->recorder && - player_ctx->recorder->IsValidRecorder() && deleteMap.IsEditing()) + if (hasFullPositionMap && IsWatchingInprogress() && deleteMap.IsEditing()) { if (editUpdateTimer.elapsed() > 2000) { @@ -3470,8 +3475,7 @@ long long MythPlayer::CalcMaxFFTime(long long ff, bool setjump) const bool islivetvcur = (livetv && player_ctx->tvchain && !player_ctx->tvchain->HasNext()); - if (livetv || (watchingrecording && player_ctx->recorder && - player_ctx->recorder->IsValidRecorder())) + if (livetv || IsWatchingInprogress()) maxtime = (long long)(3.0 * video_frame_rate); long long ret = ff; @@ -3491,8 +3495,7 @@ long long MythPlayer::CalcMaxFFTime(long long ff, bool setjump) const } } } - else if (islivetvcur || (watchingrecording && player_ctx->recorder && - player_ctx->recorder->IsValidRecorder())) + else if (islivetvcur || IsWatchingInprogress()) { long long behind = player_ctx->recorder->GetFramesWritten() - framesPlayed; @@ -3555,8 +3558,7 @@ bool MythPlayer::IsNearEnd(void) long long margin = (long long)(video_frame_rate * 2); margin = (long long) (margin * audio.GetStretchFactor()); - bool watchingTV = watchingrecording && player_ctx->recorder && - player_ctx->recorder->IsValidRecorder(); + bool watchingTV = IsWatchingInprogress(); framesRead = decoder->GetFramesRead(); @@ -3634,8 +3636,7 @@ void MythPlayer::WaitForSeek(uint64_t frame, bool override_seeks, !player_ctx->tvchain->HasNext()); uint64_t max = totalFrames; - if ((islivetvcur || (watchingrecording && player_ctx->recorder && - player_ctx->recorder->IsValidRecorder()))) + if (islivetvcur || IsWatchingInprogress()) { max = (uint64_t)player_ctx->recorder->GetFramesWritten(); } @@ -4487,9 +4488,7 @@ int MythPlayer::GetStatusbarPos(void) const { double spos = 0.0; - if ((livetv) || - (watchingrecording && player_ctx->recorder && - player_ctx->recorder->IsValidRecorder())) + if (livetv || IsWatchingInprogress()) { spos = 1000.0 * framesPlayed / player_ctx->recorder->GetFramesWritten(); } @@ -4590,8 +4589,7 @@ void MythPlayer::calcSliderPos(osdInfo &info, bool paddedFields) playbackLen = player_ctx->tvchain->GetLengthAtCurPos(); islive = true; } - else if (watchingrecording && player_ctx->recorder && - player_ctx->recorder->IsValidRecorder()) + else if (IsWatchingInprogress()) { playbackLen = (int)(((float)player_ctx->recorder->GetFramesWritten() / diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h index ceea325d5d9..9a15db68953 100644 --- a/mythtv/libs/libmythtv/mythplayer.h +++ b/mythtv/libs/libmythtv/mythplayer.h @@ -215,6 +215,7 @@ class MTV_PUBLIC MythPlayer bool HasTVChainNext(void) const; bool CanSupportDoubleRate(void); bool GetScreenShot(int width = 0, int height = 0, QString filename = ""); + bool IsWatchingInprogress(void) const; // Non-const gets virtual char *GetScreenGrabAtFrame(uint64_t frameNum, bool absolute,