move time-lapse frame grab from tick to rec_loop
This commit is contained in:
32
src/app.cpp
32
src/app.cpp
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user