move time-lapse frame grab from tick to rec_loop

This commit is contained in:
2019-11-09 14:14:59 +01:00
parent faff1dd979
commit a00f78de80
4 changed files with 18 additions and 43 deletions

View File

@@ -792,30 +792,24 @@ void App::rec_loop()
rec_running = true;
while(rec_running)
{
std::unique_ptr<PBO> frame;
std::unique_lock<std::mutex> lock(rec_mutex);
rec_cv.wait(lock, [this] { return !(rec_frames.empty() && rec_running); });
if (!rec_running)
break;
if (!rec_frames.empty())
{
if (rec_frames.front())
{
rec_count++;
frame = std::move(rec_frames.front());
}
rec_frames.pop_front();
}
lock.unlock();
if (frame && Canvas::I->m_encoder)
auto t_now = std::chrono::high_resolution_clock::now();
float dt = std::chrono::duration<float>(t_now - canvas->m_canvas->m_disrty_stroke_time).count();
if (Canvas::I->m_encoder && dt > 0.75f && canvas->m_canvas->m_dirty_stroke)
{
canvas->m_canvas->m_dirty_stroke = false;
PBO equirect = Canvas::I->m_layers_merge.gen_equirect_pbo(
Canvas::I->m_encoder->frame_size() / 4);
std::this_thread::yield();
ImageRef img;
img.create(frame->width, frame->height, frame->map());
img.create(equirect.width, equirect.height, equirect.map());
Canvas::I->m_encoder->encode(img);
frame->unmap();
equirect.unmap();
LOG("frame encoded");
update_rec_frames();
}
update_rec_frames();
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
}