ensure cache modified time is accurate

This commit is contained in:
itsmattkc
2021-02-22 00:23:34 +11:00
parent 05cb3b86b8
commit cfbf563b2e
17 changed files with 92 additions and 65 deletions
-3
View File
@@ -52,9 +52,6 @@ void AudioPlaybackCache::SetParameters(const AudioParams &params)
// Restart empty file so there's always "something" to play
ClearPlaylist();
// Our current audio cache is unusable, so we truncate it automatically
InvalidateAll();
emit ParametersChanged();
}
-1
View File
@@ -21,7 +21,6 @@
#include "diskmanager.h"
#include <QDataStream>
#include <QDateTime>
#include <QDir>
#include <QFile>
#include <QFileInfo>
+9 -3
View File
@@ -104,6 +104,7 @@ QList<rational> FrameHashCache::GetFramesWithHash(const QByteArray &hash)
QList<rational> FrameHashCache::TakeFramesWithHash(const QByteArray &hash)
{
TimeRangeList range_to_invalidate;
QList<rational> times;
auto iterator = time_hash_map_.begin();
@@ -111,6 +112,7 @@ QList<rational> FrameHashCache::TakeFramesWithHash(const QByteArray &hash)
while (iterator != time_hash_map_.end()) {
if (iterator.value() == hash) {
times.append(iterator.key());
range_to_invalidate.insert(TimeRange(iterator.key(), iterator.key() + timebase_));
iterator = time_hash_map_.erase(iterator);
} else {
@@ -118,8 +120,10 @@ QList<rational> FrameHashCache::TakeFramesWithHash(const QByteArray &hash)
}
}
foreach (const rational& r, times) {
Invalidate(TimeRange(r, r + timebase_));
foreach (const TimeRange& r, range_to_invalidate) {
// We apply a 0 job time because the graph hasn't changed to get here, so any renderer should
// be up to date already
Invalidate(r, 0);
}
return times;
@@ -351,7 +355,9 @@ void FrameHashCache::HashDeleted(const QString& s, const QByteArray &hash)
}
foreach (const TimeRange& range, ranges_to_invalidate) {
Invalidate(range);
// We set job time to 0 because the nodes haven't changed and any render job should be up
// to date
Invalidate(range, 0);
}
}
+6 -9
View File
@@ -20,8 +20,6 @@
#include "playbackcache.h"
#include <QDateTime>
#include "node/output/viewer/viewer.h"
#include "project/item/sequence/sequence.h"
#include "project/project.h"
@@ -29,7 +27,7 @@
namespace olive {
void PlaybackCache::Invalidate(const TimeRange &r)
void PlaybackCache::Invalidate(const TimeRange &r, qint64 job_time)
{
if (r.in() == r.out()) {
qWarning() << "Tried to invalidate zero-length range";
@@ -39,7 +37,6 @@ void PlaybackCache::Invalidate(const TimeRange &r)
invalidated_.insert(r);
RemoveRangeFromJobs(r);
qint64 job_time = QDateTime::currentMSecsSinceEpoch();
jobs_.append({r, job_time});
InvalidateEvent(r);
@@ -53,7 +50,7 @@ void PlaybackCache::InvalidateAll()
return;
}
Invalidate(TimeRange(0, length_));
Invalidate(TimeRange(0, length_), 0);
}
void PlaybackCache::SetLength(const rational &r)
@@ -73,7 +70,7 @@ void PlaybackCache::SetLength(const rational &r)
} else if (r > length_) {
// If new length is greater, simply extend the invalidated range for now
invalidated_.insert(range_diff);
jobs_.append({range_diff, QDateTime::currentMSecsSinceEpoch()});
jobs_.append({range_diff, 0});
} else {
// If new length is smaller, removed hashes
invalidated_.remove(range_diff);
@@ -108,16 +105,16 @@ void PlaybackCache::Shift(const rational &from, const rational &to)
// (`diff` is POSITIVE when moving forward -> and NEGATIVE when moving backward <-)
rational diff = to - from;
foreach (const TimeRange& r, ranges_to_shift) {
Invalidate(r + diff);
Invalidate(r + diff, 0);
}
ShiftEvent(from, to);
length_ += diff;
if (diff > rational()) {
if (diff > 0) {
// If shifting forward, add this section to the invalidated region
Invalidate(TimeRange(from, to));
Invalidate(TimeRange(from, to), 0);
}
// Emit signals
+1 -1
View File
@@ -62,7 +62,7 @@ public:
QString GetCacheDirectory() const;
public slots:
void Invalidate(const TimeRange& r);
void Invalidate(const TimeRange& r, qint64 job_time);
void InvalidateAll();
+7 -2
View File
@@ -274,7 +274,7 @@ void PreviewAutoCacher::ProcessUpdateQueue()
}
graph_update_queue_.clear();
last_update_time_ = QDateTime::currentMSecsSinceEpoch();
UpdateLastSyncedValue();
}
bool PreviewAutoCacher::HasActiveJobs() const
@@ -342,6 +342,11 @@ void PreviewAutoCacher::InsertIntoCopyMap(Node *node, Node *copy)
Node::CopyInputs(node, copy, false);
}
void PreviewAutoCacher::UpdateLastSyncedValue()
{
last_update_time_ = QDateTime::currentMSecsSinceEpoch();
}
void PreviewAutoCacher::SetPlayhead(const rational &playhead)
{
cache_range_ = TimeRange(playhead - Config::Current()[QStringLiteral("DiskCacheBehind")].value<rational>(),
@@ -662,7 +667,7 @@ void PreviewAutoCacher::SetViewerNode(Sequence *viewer_node)
}
}
last_update_time_ = QDateTime::currentMSecsSinceEpoch();
UpdateLastSyncedValue();
// Connect signals for future node additions/deletions
connect(graph, &NodeGraph::NodeAdded, this, &PreviewAutoCacher::NodeAdded);
+2
View File
@@ -116,6 +116,8 @@ private:
void InsertIntoCopyMap(Node* node, Node* copy);
void UpdateLastSyncedValue();
class QueuedJob {
public:
enum Type {
-1
View File
@@ -21,7 +21,6 @@
#include "rendermanager.h"
#include <QApplication>
#include <QDateTime>
#include <QMatrix4x4>
#include <QThread>