renderer/viewer: fixed playback and live updates from value changes
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "audioplaybackcache.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
#include "common/filefunctions.h"
|
||||
@@ -42,6 +43,14 @@ void AudioPlaybackCache::SetParameters(const AudioRenderingParams ¶ms)
|
||||
return;
|
||||
}
|
||||
|
||||
params_ = params;
|
||||
|
||||
// Restart empty file so there's always "something" to play
|
||||
QFile f(filename_);
|
||||
if (f.open(QFile::WriteOnly)) {
|
||||
f.close();
|
||||
}
|
||||
|
||||
// Our current audio cache is unusable, so we truncate it automatically
|
||||
InvalidateAll();
|
||||
|
||||
|
||||
@@ -101,10 +101,8 @@ void RenderBackend::CancelQueue()
|
||||
|
||||
QFuture<QByteArray> RenderBackend::Hash(const rational &time)
|
||||
{
|
||||
RenderWorker* instance = GetInstanceFromPool();
|
||||
|
||||
return QtConcurrent::run(&thread_pool_,
|
||||
instance,
|
||||
GetInstanceFromPool(),
|
||||
&RenderWorker::Hash,
|
||||
time);
|
||||
}
|
||||
@@ -115,10 +113,8 @@ QFuture<FramePtr> RenderBackend::RenderFrame(const rational &time, bool clear_qu
|
||||
thread_pool_.clear();
|
||||
}
|
||||
|
||||
RenderWorker* instance = GetInstanceFromPool();
|
||||
|
||||
return QtConcurrent::run(&thread_pool_,
|
||||
instance,
|
||||
GetInstanceFromPool(),
|
||||
&RenderWorker::RenderFrame,
|
||||
time);
|
||||
}
|
||||
@@ -195,6 +191,12 @@ RenderWorker *RenderBackend::GetInstanceFromPool()
|
||||
if (viewer_node_) {
|
||||
instance->Init(viewer_node_);
|
||||
}
|
||||
|
||||
connect(instance,
|
||||
&RenderWorker::FinishedJob,
|
||||
this,
|
||||
&RenderBackend::WorkerFinished,
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
instance->SetAvailable(false);
|
||||
@@ -225,6 +227,11 @@ void RenderBackend::AudioCallback()
|
||||
*/
|
||||
}
|
||||
|
||||
void RenderBackend::WorkerFinished()
|
||||
{
|
||||
static_cast<RenderWorker*>(sender())->SetAvailable(true);
|
||||
}
|
||||
|
||||
bool RenderBackend::ConformWaitInfo::operator==(const RenderBackend::ConformWaitInfo &rhs) const
|
||||
{
|
||||
return rhs.stream == stream
|
||||
|
||||
@@ -109,6 +109,8 @@ private:
|
||||
private slots:
|
||||
void AudioCallback();
|
||||
|
||||
void WorkerFinished();
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -39,7 +39,7 @@ RenderWorker::~RenderWorker()
|
||||
Close();
|
||||
}
|
||||
|
||||
QByteArray RenderWorker::Hash(const rational &time) const
|
||||
QByteArray RenderWorker::Hash(const rational &time)
|
||||
{
|
||||
if (!viewer_) {
|
||||
return QByteArray();
|
||||
@@ -55,6 +55,8 @@ QByteArray RenderWorker::Hash(const rational &time) const
|
||||
|
||||
viewer_->Hash(hasher, time);
|
||||
|
||||
emit FinishedJob();
|
||||
|
||||
return hasher.result();
|
||||
}
|
||||
|
||||
@@ -69,10 +71,6 @@ FramePtr RenderWorker::RenderFrame(const rational &time)
|
||||
|
||||
QVariant texture = table.Get(NodeParam::kTexture);
|
||||
|
||||
if (texture.isNull()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FramePtr frame = Frame::Create();
|
||||
frame->set_video_params(video_params_);
|
||||
frame->set_timestamp(time);
|
||||
@@ -86,6 +84,8 @@ FramePtr RenderWorker::RenderFrame(const rational &time)
|
||||
TextureToFrame(texture, frame, video_download_matrix_);
|
||||
}
|
||||
|
||||
emit FinishedJob();
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
*
|
||||
* SHA-1 hash or empty QByteArray if no viewer node is set.
|
||||
*/
|
||||
QByteArray Hash(const rational &time) const;
|
||||
QByteArray Hash(const rational &time);
|
||||
|
||||
/**
|
||||
* @brief Render the frame at this time
|
||||
@@ -127,6 +127,8 @@ protected:
|
||||
signals:
|
||||
void AudioConformUnavailable();
|
||||
|
||||
void FinishedJob();
|
||||
|
||||
private:
|
||||
NodeValue GetDataFromStream(StreamPtr stream, const TimeRange& input_time);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user