renderer: improve thread safety
Since we share render backends between the viewer and cache tasks now, we should ensure the render backend is thread safe.
This commit is contained in:
@@ -139,7 +139,7 @@ RenderTicketPtr RenderBackend::RenderFrame(const rational &time)
|
||||
|
||||
render_queue_.push_back(ticket);
|
||||
|
||||
RunNextJob();
|
||||
QMetaObject::invokeMethod(this, "RunNextJob", Qt::QueuedConnection);
|
||||
|
||||
return ticket;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ RenderTicketPtr RenderBackend::RenderAudio(const TimeRange &r)
|
||||
|
||||
render_queue_.push_back(ticket);
|
||||
|
||||
RunNextJob();
|
||||
QMetaObject::invokeMethod(this, "RunNextJob", Qt::QueuedConnection);
|
||||
|
||||
return ticket;
|
||||
}
|
||||
|
||||
@@ -115,8 +115,6 @@ private:
|
||||
Node *CopyNodeConnections(Node *src_node);
|
||||
void CopyNodeMakeConnection(NodeInput *src_input, NodeInput *dst_input);
|
||||
|
||||
void RunNextJob();
|
||||
|
||||
ViewerOutput* viewer_node_;
|
||||
|
||||
// VIDEO MEMBERS
|
||||
@@ -150,6 +148,8 @@ private:
|
||||
private slots:
|
||||
void WorkerFinished();
|
||||
|
||||
void RunNextJob();
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
Vendored
+1
-1
@@ -57,7 +57,7 @@ bool CacheTask::Run()
|
||||
}
|
||||
}
|
||||
|
||||
Render(video_range, audio_range, QMatrix4x4(), true);
|
||||
Render(video_range, audio_range, true);
|
||||
|
||||
download_threads_.waitForDone();
|
||||
|
||||
|
||||
@@ -64,17 +64,17 @@ bool ExportTask::Run()
|
||||
|
||||
frame_time_ = Timecode::time_to_timestamp(range.in(), viewer()->video_params().time_base());
|
||||
|
||||
QMatrix4x4 mat;
|
||||
|
||||
if (params_.video_enabled()) {
|
||||
|
||||
// If a transformation matrix is applied to this video, create it here
|
||||
if (params_.video_scaling_method() != ExportParams::kStretch) {
|
||||
mat = ExportParams::GenerateMatrix(params_.video_scaling_method(),
|
||||
viewer()->video_params().width(),
|
||||
viewer()->video_params().height(),
|
||||
params_.video_params().width(),
|
||||
params_.video_params().height());
|
||||
QMatrix4x4 mat = ExportParams::GenerateMatrix(params_.video_scaling_method(),
|
||||
viewer()->video_params().width(),
|
||||
viewer()->video_params().height(),
|
||||
params_.video_params().width(),
|
||||
params_.video_params().height());
|
||||
|
||||
backend()->SetVideoDownloadMatrix(mat);
|
||||
}
|
||||
|
||||
// Create color processor
|
||||
@@ -99,7 +99,7 @@ bool ExportTask::Run()
|
||||
audio_data_.SetLength(range.length());
|
||||
}
|
||||
|
||||
Render(video_range, audio_range, mat, false);
|
||||
Render(video_range, audio_range, false);
|
||||
|
||||
bool success = true;
|
||||
|
||||
|
||||
@@ -78,11 +78,8 @@ struct HashDownloadFuturePair {
|
||||
|
||||
void RenderTask::Render(const TimeRangeList& video_range,
|
||||
const TimeRangeList &audio_range,
|
||||
const QMatrix4x4& mat,
|
||||
bool use_disk_cache)
|
||||
{
|
||||
backend_->SetVideoDownloadMatrix(mat);
|
||||
|
||||
double progress_counter = 0;
|
||||
double total_length = 0;
|
||||
double video_frame_sz = video_params().time_base().toDouble();
|
||||
@@ -245,8 +242,10 @@ void RenderTask::Render(const TimeRangeList& video_range,
|
||||
}
|
||||
}
|
||||
|
||||
// `Close` will block until all jobs are done making a safe deletion
|
||||
backend_->Close();
|
||||
if (backend_is_ours_) {
|
||||
// `Close` will block until all jobs are done making a safe deletion
|
||||
backend_->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderTask::SetAnchorPoint(const rational &r)
|
||||
|
||||
@@ -40,7 +40,6 @@ public:
|
||||
protected:
|
||||
void Render(const TimeRangeList &video_range,
|
||||
const TimeRangeList &audio_range,
|
||||
const QMatrix4x4 &mat,
|
||||
bool use_disk_cache);
|
||||
|
||||
virtual QFuture<void> DownloadFrame(FramePtr frame, const QByteArray &hash) = 0;
|
||||
|
||||
Reference in New Issue
Block a user