Skip to content

Commit

Permalink
Merge pull request xbmc#18671 from ksooo/pvr-fix-recordings-sync
Browse files Browse the repository at this point in the history
[PVR] Fix updating recordings from clients.
  • Loading branch information
ksooo authored Oct 30, 2020
2 parents 291c853 + bba8600 commit 6699e55
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
17 changes: 15 additions & 2 deletions xbmc/pvr/recordings/PVRRecording.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,21 @@ namespace PVR
*/
int64_t GetSizeInBytes() const;

/*!
* @brief Mark a recording as dirty/clean.
* @param bDirty true to mark as dirty, false to mark as clean.
*/
void SetDirty(bool bDirty) { m_bDirty = bDirty; }

/*!
* @brief Return whether the recording is marked dirty.
* @return true if dirty, false otherwise.
*/
bool IsDirty() const { return m_bDirty; }

private:
void UpdatePath();

CDateTime m_recordingTime; /*!< start time of the recording */
bool m_bGotMetaData;
bool m_bIsDeleted; /*!< set if entry is a deleted recording which can be undelete */
Expand All @@ -394,8 +408,7 @@ namespace PVR
unsigned int m_iFlags = 0; /*!< the flags applicable to this recording */
mutable XbmcThreads::EndTime m_recordingSizeRefetchTimeout;
int64_t m_sizeInBytes = 0; /*!< the size of the recording in bytes */

void UpdatePath();
bool m_bDirty = false;

mutable CCriticalSection m_critSection;
};
Expand Down
15 changes: 14 additions & 1 deletion xbmc/pvr/recordings/PVRRecordings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,21 @@ CPVRRecordings::~CPVRRecordings()
void CPVRRecordings::UpdateFromClients()
{
CSingleLock lock(m_critSection);
Unload();

for (const auto& recording : m_recordings)
recording.second->SetDirty(true);

CServiceBroker::GetPVRManager().Clients()->GetRecordings(this, false);
CServiceBroker::GetPVRManager().Clients()->GetRecordings(this, true);

// remove recordings that were deleted at the backend
for (auto it = m_recordings.begin(); it != m_recordings.end();)
{
if ((*it).second->IsDirty())
it = m_recordings.erase(it);
else
++it;
}
}

int CPVRRecordings::Load()
Expand Down Expand Up @@ -201,6 +213,7 @@ void CPVRRecordings::UpdateFromClient(const std::shared_ptr<CPVRRecording>& tag)
if (existingTag)
{
existingTag->Update(*tag);
existingTag->SetDirty(false);
}
else
{
Expand Down

0 comments on commit 6699e55

Please sign in to comment.