reset starttime when changing events. Fixes super fast playback after switch to next event. Also, skip some unneeded calculations and logging.

This commit is contained in:
Isaac Connor 2021-10-28 13:00:41 -04:00
parent dedd755e5c
commit e063f0715f
1 changed files with 8 additions and 5 deletions

View File

@ -663,6 +663,7 @@ bool EventStream::checkEventLoaded() {
else else
curr_frame_id = 1; curr_frame_id = 1;
Debug(2, "New frame id = %ld", curr_frame_id); Debug(2, "New frame id = %ld", curr_frame_id);
start = std::chrono::system_clock::now();
return true; return true;
} else { } else {
Debug(2, "No next event loaded using %s. Pausing", sql.c_str()); Debug(2, "No next event loaded using %s. Pausing", sql.c_str());
@ -957,18 +958,20 @@ void EventStream::runStream() {
static_cast<int64>(std::chrono::duration_cast<Microseconds>(delta).count())); static_cast<int64>(std::chrono::duration_cast<Microseconds>(delta).count()));
// if effective > base we should speed up frame delivery // if effective > base we should speed up frame delivery
delta = std::chrono::duration_cast<Microseconds>((delta * base_fps) / effective_fps); if (base_fps < effective_fps) {
Debug(3, "delta %" PRIi64 " us = base_fps (%f) / effective_fps (%f)", delta = std::chrono::duration_cast<Microseconds>((delta * base_fps) / effective_fps);
Debug(3, "delta %" PRIi64 " us = base_fps (%f) / effective_fps (%f)",
static_cast<int64>(std::chrono::duration_cast<Microseconds>(delta).count()), static_cast<int64>(std::chrono::duration_cast<Microseconds>(delta).count()),
base_fps, base_fps,
effective_fps); effective_fps);
// but must not exceed maxfps // but must not exceed maxfps
delta = std::max(delta, Microseconds(lround(Microseconds::period::den / maxfps))); delta = std::max(delta, Microseconds(lround(Microseconds::period::den / maxfps)));
Debug(3, "delta %" PRIi64 " us = base_fps (%f) /effective_fps (%f) from 30fps", Debug(3, "delta %" PRIi64 " us = base_fps (%f) / effective_fps (%f) from 30fps",
static_cast<int64>(std::chrono::duration_cast<Microseconds>(delta).count()), static_cast<int64>(std::chrono::duration_cast<Microseconds>(delta).count()),
base_fps, base_fps,
effective_fps); effective_fps);
}
// +/- 1? What if we are skipping frames? // +/- 1? What if we are skipping frames?
curr_frame_id += (replay_rate>0) ? frame_mod : -1*frame_mod; curr_frame_id += (replay_rate>0) ? frame_mod : -1*frame_mod;