Skip to content

Commit

Permalink
Fix the DeleteMap tracker for in-progress recordings.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stichnot committed Feb 15, 2012
1 parent c5c73bf commit 94d27c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
23 changes: 17 additions & 6 deletions mythtv/libs/libmythtv/deletemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,18 @@ bool DeleteMap::IsTemporaryMark(uint64_t frame) const
}

/**
* \brief Returns the next or previous mark. If these do not exist, returns
* either zero (the first frame) or total (the last frame).
* \brief Returns the next or previous mark. If these do not exist,
* returns either zero (the first frame) or total (the last
* frame). If hasMark is non-NULL, it is set to true if the
* next/previous mark exists, and false otherwise.
*/
uint64_t DeleteMap::GetNearestMark(
uint64_t frame, uint64_t total, bool right) const
uint64_t frame, uint64_t total, bool right,
bool *hasMark) const
{
uint64_t result;
if (hasMark)
*hasMark = true;
frm_dir_map_t::const_iterator it = m_deleteMap.begin();
if (right)
{
Expand All @@ -574,6 +579,8 @@ uint64_t DeleteMap::GetNearestMark(
result = it.key();
}
}
if (hasMark)
*hasMark = false;
return result;
}

Expand Down Expand Up @@ -740,6 +747,7 @@ void DeleteMap::SaveMap(uint64_t total, bool isAutoSave)
void DeleteMap::TrackerReset(uint64_t frame, uint64_t total)
{
m_nextCutStart = 0;
m_nextCutStartIsValid = false;
if (IsEmpty())
return;

Expand All @@ -748,16 +756,19 @@ void DeleteMap::TrackerReset(uint64_t frame, uint64_t total)
{
if (cutpoint.value() == MARK_CUT_START)
{
m_nextCutStartIsValid = true;
m_nextCutStart = cutpoint.key();
}
else
{
++cutpoint;
m_nextCutStart = cutpoint != m_deleteMap.end() ? cutpoint.key() : total;
m_nextCutStartIsValid = (cutpoint != m_deleteMap.end());
m_nextCutStart = m_nextCutStartIsValid ? cutpoint.key() : total;
}
}
else
m_nextCutStart = GetNearestMark(frame, total, !IsInDelete(frame));
m_nextCutStart = GetNearestMark(frame, total, !IsInDelete(frame),
&m_nextCutStartIsValid);
LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Tracker next CUT_START: %1")
.arg(m_nextCutStart));
}
Expand All @@ -768,7 +779,7 @@ void DeleteMap::TrackerReset(uint64_t frame, uint64_t total)
*/
bool DeleteMap::TrackerWantsToJump(uint64_t frame, uint64_t total, uint64_t &to)
{
if (IsEmpty() || frame < m_nextCutStart)
if (IsEmpty() || !m_nextCutStartIsValid || frame < m_nextCutStart)
return false;

to = GetNearestMark(m_nextCutStart, total, true);
Expand Down
8 changes: 6 additions & 2 deletions mythtv/libs/libmythtv/deletemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ typedef struct DeleteMapUndoEntry
class MTV_PUBLIC DeleteMap
{
public:
DeleteMap(): m_editing(false), m_nextCutStart(0), m_changed(true),
DeleteMap(): m_editing(false),
m_nextCutStartIsValid(false),
m_nextCutStart(0), m_changed(true),
m_seekamountpos(4), m_seekamount(30),
m_ctx(0), m_undoStackPointer(-1) { Push(""); }

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

bool IsInDelete(uint64_t frame) const;
uint64_t GetNearestMark(uint64_t frame, uint64_t total, bool right) const;
uint64_t GetNearestMark(uint64_t frame, uint64_t total, bool right,
bool *hasMark = 0) const;
bool IsTemporaryMark(uint64_t frame) const;
bool HasTemporaryMark(void) const;
uint64_t GetLastFrame(uint64_t total) const;
Expand All @@ -79,6 +82,7 @@ class MTV_PUBLIC DeleteMap
void Push(QString undoMessage);

bool m_editing;
bool m_nextCutStartIsValid;
uint64_t m_nextCutStart;
frm_dir_map_t m_deleteMap;
QString m_seekText;
Expand Down

0 comments on commit 94d27c6

Please sign in to comment.