set params on workers when a backend's params change

Previous iteration had params attached to the backend and the params couldn't
change without being destroyed and re-instantiated. This is not necessary in
this iteration so doing so only wastes resources.
This commit is contained in:
itsmattkc
2019-11-23 22:28:06 +09:00
parent 44d649903c
commit 6a27161e96
2 changed files with 16 additions and 8 deletions
+8 -4
View File
@@ -3,6 +3,7 @@
#include <QDir>
#include <QtMath>
#include "audiorenderworker.h"
#include "common/filefunctions.h"
AudioRenderBackend::AudioRenderBackend(QObject *parent) :
@@ -12,13 +13,16 @@ AudioRenderBackend::AudioRenderBackend(QObject *parent) :
void AudioRenderBackend::SetParameters(const AudioRenderingParams &params)
{
// Since we're changing parameters, all the existing threads are invalid and must be removed. They will start again
// next time this Node has to process anything.
Close();
// Set new parameters
params_ = params;
// Set params on all processors
// FIXME: Undefined behavior if the processors are currently working, this may need to be delayed like the
// recompile signal
foreach (RenderWorker* worker, processors_) {
static_cast<AudioRenderWorker*>(worker)->SetParameters(params_);
}
// Regenerate the cache ID
RegenerateCacheID();
}
+8 -4
View File
@@ -28,6 +28,7 @@
#include <QtMath>
#include "render/pixelservice.h"
#include "videorenderworker.h"
VideoRenderBackend::VideoRenderBackend(QObject *parent) :
RenderBackend(parent)
@@ -137,13 +138,16 @@ const VideoRenderingParams &VideoRenderBackend::params() const
void VideoRenderBackend::SetParameters(const VideoRenderingParams& params)
{
// Since we're changing parameters, all the existing threads are invalid and must be removed. They will start again
// next time this Node has to process anything.
Close();
// Set new parameters
params_ = params;
// Set params on all processors
// FIXME: Undefined behavior if the processors are currently working, this may need to be delayed like the
// recompile signal
foreach (RenderWorker* worker, processors_) {
static_cast<VideoRenderWorker*>(worker)->SetParameters(params_);
}
// Regenerate the cache ID
RegenerateCacheID();
}