renderer: share render backend for auto-cache tasks

Since auto-cache events start and stop fairly frequently (and are somewhat
heavy to create/destroy), we can save a lot of cycles over time by sharing
the same backend between them all.
This commit is contained in:
itsmattkc
2020-07-06 14:22:17 +10:00
parent 936d077077
commit a45f514f68
8 changed files with 128 additions and 58 deletions
+18 -6
View File
@@ -27,16 +27,18 @@
OLIVE_NAMESPACE_ENTER
CacheTask::CacheTask(RenderBackend *backend, bool in_out_only) :
RenderTask(backend),
in_out_only_(in_out_only)
{
Init();
}
CacheTask::CacheTask(ViewerOutput* viewer, const VideoParams& vparams, const AudioParams &aparams, bool in_out_only) :
RenderTask(viewer, vparams, aparams),
in_out_only_(in_out_only)
{
SetTitle(tr("Caching \"%1\"").arg(viewer->media_name()));
backend()->EnablePreviewGeneration(job_time());
// Render fastest quality
backend()->SetRenderMode(RenderMode::kOffline);
Init();
}
bool CacheTask::Run()
@@ -83,4 +85,14 @@ void CacheTask::AudioDownloaded(const TimeRange &range, SampleBufferPtr samples)
}
}
void CacheTask::Init()
{
SetTitle(tr("Caching \"%1\"").arg(viewer()->media_name()));
backend()->EnablePreviewGeneration(job_time());
// Render fastest quality
backend()->SetRenderMode(RenderMode::kOffline);
}
OLIVE_NAMESPACE_EXIT
+3
View File
@@ -31,6 +31,7 @@ class CacheTask : public RenderTask
{
Q_OBJECT
public:
CacheTask(RenderBackend* backend, bool in_out_only);
CacheTask(ViewerOutput* viewer,
const VideoParams &vparams,
const AudioParams &aparams,
@@ -46,6 +47,8 @@ protected:
virtual void AudioDownloaded(const TimeRange& range, SampleBufferPtr samples) override;
private:
void Init();
bool in_out_only_;
QThreadPool download_threads_;