cache: use render job times to synchronize cache

Ensure old inaccurate jobs are never prioritized over current jobs.
This commit is contained in:
itsmattkc
2020-06-04 16:48:23 +10:00
parent cc34f0e251
commit 9ff9817b95
13 changed files with 106 additions and 40 deletions
+2 -2
View File
@@ -65,14 +65,14 @@ QFuture<void> CacheTask::DownloadFrame(FramePtr frame, const QByteArray &hash)
void CacheTask::FrameDownloaded(const QByteArray &hash, const std::list<rational> &times)
{
foreach (const rational& t, times) {
viewer()->video_frame_cache()->SetHash(t, hash);
viewer()->video_frame_cache()->SetHash(t, hash, job_time());
}
}
void CacheTask::AudioDownloaded(const TimeRange &range, SampleBufferPtr samples)
{
if (samples) {
viewer()->audio_playback_cache()->WritePCM(range, samples);
viewer()->audio_playback_cache()->WritePCM(range, samples, job_time());
} else {
viewer()->audio_playback_cache()->WriteSilence(range);
}
+1 -1
View File
@@ -177,7 +177,7 @@ void ExportTask::AudioDownloaded(const TimeRange &range, SampleBufferPtr samples
adjusted_range -= params_.custom_range().in();
}
audio_data_.WritePCM(adjusted_range, samples);
audio_data_.WritePCM(adjusted_range, samples, job_time());
}
OLIVE_NAMESPACE_EXIT
+2
View File
@@ -29,6 +29,8 @@ RenderTask::RenderTask(ViewerOutput* viewer, const VideoRenderingParams &vparams
video_params_(vparams),
audio_params_(aparams)
{
job_time_ = QDateTime::currentMSecsSinceEpoch();
// FIXME: This makes a full copy of the node graph every time it starts, there must be a better
// way.
backend_.SetViewerNode(viewer_);
+7
View File
@@ -63,6 +63,11 @@ protected:
void SetAnchorPoint(const rational& r);
const qint64& job_time() const
{
return job_time_;
}
private:
ViewerOutput* viewer_;
@@ -74,6 +79,8 @@ private:
OpenGLBackend backend_;
qint64 job_time_;
};
OLIVE_NAMESPACE_EXIT