Skip to content

Commit 94d27c6

Browse files
committed
Fix the DeleteMap tracker for in-progress recordings.
When a cutlist is created, the DeleteMap tracker was simulating an artificial cut region starting from the current last frame. For in-progress recordings, this resulted in playback prematurely exiting when that frame was reached. The tracker is now tracks only true cut regions and avoids the premature exit.
1 parent c5c73bf commit 94d27c6

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

mythtv/libs/libmythtv/deletemap.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,18 @@ bool DeleteMap::IsTemporaryMark(uint64_t frame) const
549549
}
550550

551551
/**
552-
* \brief Returns the next or previous mark. If these do not exist, returns
553-
* either zero (the first frame) or total (the last frame).
552+
* \brief Returns the next or previous mark. If these do not exist,
553+
* returns either zero (the first frame) or total (the last
554+
* frame). If hasMark is non-NULL, it is set to true if the
555+
* next/previous mark exists, and false otherwise.
554556
*/
555557
uint64_t DeleteMap::GetNearestMark(
556-
uint64_t frame, uint64_t total, bool right) const
558+
uint64_t frame, uint64_t total, bool right,
559+
bool *hasMark) const
557560
{
558561
uint64_t result;
562+
if (hasMark)
563+
*hasMark = true;
559564
frm_dir_map_t::const_iterator it = m_deleteMap.begin();
560565
if (right)
561566
{
@@ -574,6 +579,8 @@ uint64_t DeleteMap::GetNearestMark(
574579
result = it.key();
575580
}
576581
}
582+
if (hasMark)
583+
*hasMark = false;
577584
return result;
578585
}
579586

@@ -740,6 +747,7 @@ void DeleteMap::SaveMap(uint64_t total, bool isAutoSave)
740747
void DeleteMap::TrackerReset(uint64_t frame, uint64_t total)
741748
{
742749
m_nextCutStart = 0;
750+
m_nextCutStartIsValid = false;
743751
if (IsEmpty())
744752
return;
745753

@@ -748,16 +756,19 @@ void DeleteMap::TrackerReset(uint64_t frame, uint64_t total)
748756
{
749757
if (cutpoint.value() == MARK_CUT_START)
750758
{
759+
m_nextCutStartIsValid = true;
751760
m_nextCutStart = cutpoint.key();
752761
}
753762
else
754763
{
755764
++cutpoint;
756-
m_nextCutStart = cutpoint != m_deleteMap.end() ? cutpoint.key() : total;
765+
m_nextCutStartIsValid = (cutpoint != m_deleteMap.end());
766+
m_nextCutStart = m_nextCutStartIsValid ? cutpoint.key() : total;
757767
}
758768
}
759769
else
760-
m_nextCutStart = GetNearestMark(frame, total, !IsInDelete(frame));
770+
m_nextCutStart = GetNearestMark(frame, total, !IsInDelete(frame),
771+
&m_nextCutStartIsValid);
761772
LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Tracker next CUT_START: %1")
762773
.arg(m_nextCutStart));
763774
}
@@ -768,7 +779,7 @@ void DeleteMap::TrackerReset(uint64_t frame, uint64_t total)
768779
*/
769780
bool DeleteMap::TrackerWantsToJump(uint64_t frame, uint64_t total, uint64_t &to)
770781
{
771-
if (IsEmpty() || frame < m_nextCutStart)
782+
if (IsEmpty() || !m_nextCutStartIsValid || frame < m_nextCutStart)
772783
return false;
773784

774785
to = GetNearestMark(m_nextCutStart, total, true);

mythtv/libs/libmythtv/deletemap.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ typedef struct DeleteMapUndoEntry
1919
class MTV_PUBLIC DeleteMap
2020
{
2121
public:
22-
DeleteMap(): m_editing(false), m_nextCutStart(0), m_changed(true),
22+
DeleteMap(): m_editing(false),
23+
m_nextCutStartIsValid(false),
24+
m_nextCutStart(0), m_changed(true),
2325
m_seekamountpos(4), m_seekamount(30),
2426
m_ctx(0), m_undoStackPointer(-1) { Push(""); }
2527

@@ -56,7 +58,8 @@ class MTV_PUBLIC DeleteMap
5658
void Move(uint64_t frame, uint64_t to, uint64_t total);
5759

5860
bool IsInDelete(uint64_t frame) const;
59-
uint64_t GetNearestMark(uint64_t frame, uint64_t total, bool right) const;
61+
uint64_t GetNearestMark(uint64_t frame, uint64_t total, bool right,
62+
bool *hasMark = 0) const;
6063
bool IsTemporaryMark(uint64_t frame) const;
6164
bool HasTemporaryMark(void) const;
6265
uint64_t GetLastFrame(uint64_t total) const;
@@ -79,6 +82,7 @@ class MTV_PUBLIC DeleteMap
7982
void Push(QString undoMessage);
8083

8184
bool m_editing;
85+
bool m_nextCutStartIsValid;
8286
uint64_t m_nextCutStart;
8387
frm_dir_map_t m_deleteMap;
8488
QString m_seekText;

0 commit comments

Comments
 (0)