Fix callback
This commit is contained in:
parent
ab10f335e9
commit
bcf996e291
src
@ -68,6 +68,7 @@
|
|||||||
#include "utils/vs.hpp"
|
#include "utils/vs.hpp"
|
||||||
|
|
||||||
#include <irrlicht.h>
|
#include <irrlicht.h>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
/* Build-time check that the Irrlicht we're building against works for us.
|
/* Build-time check that the Irrlicht we're building against works for us.
|
||||||
* Should help prevent distros building against an incompatible library.
|
* Should help prevent distros building against an incompatible library.
|
||||||
@ -647,9 +648,22 @@ void IrrDriver::initDevice()
|
|||||||
[] (const char* s, void* user_data) { MessageQueue::add
|
[] (const char* s, void* user_data) { MessageQueue::add
|
||||||
(MessageQueue::MT_GENERIC, _("Video saved in \"%s\".", s));
|
(MessageQueue::MT_GENERIC, _("Video saved in \"%s\".", s));
|
||||||
}, NULL);
|
}, NULL);
|
||||||
|
static std::chrono::high_resolution_clock::time_point tp;
|
||||||
ogrRegIntCallback(OGR_CBT_PROGRESS_RECORDING,
|
ogrRegIntCallback(OGR_CBT_PROGRESS_RECORDING,
|
||||||
[] (const int i, void* user_data)
|
[] (const int i, void* user_data)
|
||||||
{ Log::info("Recorder", "%d%% of video encoding finished", i);}, NULL);
|
{
|
||||||
|
std::chrono::high_resolution_clock::time_point* timer =
|
||||||
|
(std::chrono::high_resolution_clock::time_point*)user_data;
|
||||||
|
auto rate = std::chrono::high_resolution_clock::now() -
|
||||||
|
*timer;
|
||||||
|
float t = std::chrono::duration_cast<std::chrono::
|
||||||
|
duration<float> >(rate).count();
|
||||||
|
if (t > 3.0f)
|
||||||
|
{
|
||||||
|
*timer = std::chrono::high_resolution_clock::now();
|
||||||
|
Log::info("Recorder", "%d%% of video encoding finished", i);
|
||||||
|
}
|
||||||
|
}, &tp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -221,10 +221,10 @@ void CaptureLibrary::captureConversion(CaptureLibrary* cl)
|
|||||||
{
|
{
|
||||||
runCallback(OGR_CBT_WAIT_RECORDING, NULL);
|
runCallback(OGR_CBT_WAIT_RECORDING, NULL);
|
||||||
}
|
}
|
||||||
cl->m_display_progress.store(true);
|
|
||||||
cl->m_jpg_list.emplace_back((uint8_t*)NULL, 0, 0);
|
cl->m_jpg_list.emplace_back((uint8_t*)NULL, 0, 0);
|
||||||
cl->m_jpg_list_ready.notify_one();
|
cl->m_jpg_list_ready.notify_one();
|
||||||
ulj.unlock();
|
ulj.unlock();
|
||||||
|
cl->m_display_progress.store(!cl->m_destroy.load());
|
||||||
cl->m_video_enc_thread.join();
|
cl->m_video_enc_thread.join();
|
||||||
cl->m_display_progress.store(false);
|
cl->m_display_progress.store(false);
|
||||||
std::string f = Recorder::writeMKV(getSavedName() + ".video",
|
std::string f = Recorder::writeMKV(getSavedName() + ".video",
|
||||||
@ -253,7 +253,8 @@ void CaptureLibrary::captureConversion(CaptureLibrary* cl)
|
|||||||
const bool too_slow = cl->m_fbi_list.size() > 50;
|
const bool too_slow = cl->m_fbi_list.size() > 50;
|
||||||
if (too_slow)
|
if (too_slow)
|
||||||
{
|
{
|
||||||
runCallback(OGR_CBT_SLOW_RECORDING, NULL);
|
if (!cl->m_destroy.load())
|
||||||
|
runCallback(OGR_CBT_SLOW_RECORDING, NULL);
|
||||||
delete [] fbi;
|
delete [] fbi;
|
||||||
cl->m_fbi_list.pop_front();
|
cl->m_fbi_list.pop_front();
|
||||||
for (auto& p : cl->m_fbi_list)
|
for (auto& p : cl->m_fbi_list)
|
||||||
|
@ -117,16 +117,22 @@ namespace Recorder
|
|||||||
{
|
{
|
||||||
cl->getJPGList()->clear();
|
cl->getJPGList()->clear();
|
||||||
ul.unlock();
|
ul.unlock();
|
||||||
|
if (cl->displayingProgress())
|
||||||
|
{
|
||||||
|
int rate = 100;
|
||||||
|
runCallback(OGR_CBT_PROGRESS_RECORDING, &rate);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cl->getJPGList()->pop_front();
|
cl->getJPGList()->pop_front();
|
||||||
ul.unlock();
|
ul.unlock();
|
||||||
if (!cl->getDestroy() && cl->displayingProgress())
|
if (cl->displayingProgress())
|
||||||
{
|
{
|
||||||
if (last_size == -1.0f)
|
if (last_size == -1.0f)
|
||||||
last_size = (float)(cl->getJPGList()->size());
|
last_size = (float)(cl->getJPGList()->size());
|
||||||
cur_finished_count += frame_count;
|
cur_finished_count += frame_count;
|
||||||
int rate = (int)(cur_finished_count / last_size * 100.0f);
|
int rate = (int)(cur_finished_count / last_size * 100.0f);
|
||||||
|
rate = rate > 100 ? 100 : rate;
|
||||||
runCallback(OGR_CBT_PROGRESS_RECORDING, &rate);
|
runCallback(OGR_CBT_PROGRESS_RECORDING, &rate);
|
||||||
}
|
}
|
||||||
uint8_t* yuv = NULL;
|
uint8_t* yuv = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user