Move canvas async work into app runtime
This commit is contained in:
25
src/app.cpp
25
src/app.cpp
@@ -689,22 +689,31 @@ namespace
|
||||
if (plan.update_frame_label)
|
||||
app.update_rec_frames();
|
||||
}
|
||||
|
||||
template <typename CanvasDocument>
|
||||
bool process_recording_worker_iteration(App& app)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(app.rec_mutex);
|
||||
app.rec_cv.wait(lock);
|
||||
|
||||
const auto iteration = make_recording_worker_iteration_context<CanvasDocument>(app);
|
||||
if (!iteration.plan.continue_running)
|
||||
return false;
|
||||
|
||||
if (iteration.plan.encode_frame && iteration.legacy_canvas && iteration.canvas_document && iteration.encoder)
|
||||
encode_recording_frame(app, iteration.plan, iteration.legacy_canvas, iteration.canvas_document, iteration.encoder);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void App::rec_loop()
|
||||
{
|
||||
BT_SetTerminate();
|
||||
rec_running = true;
|
||||
while(rec_running)
|
||||
while (rec_running)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(rec_mutex);
|
||||
rec_cv.wait(lock/*, [this] { return !(rec_frames.empty() && rec_running); }*/);
|
||||
const auto iteration = make_recording_worker_iteration_context<CanvasDocument>(*this);
|
||||
if (!iteration.plan.continue_running)
|
||||
if (!process_recording_worker_iteration<CanvasDocument>(*this))
|
||||
break;
|
||||
|
||||
if (iteration.plan.encode_frame && iteration.legacy_canvas && iteration.canvas_document && iteration.encoder)
|
||||
encode_recording_frame(*this, iteration.plan, iteration.legacy_canvas, iteration.canvas_document, iteration.encoder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user