src/Qt/*: Reformat logging calls, fix indents

This commit is contained in:
FeRD (Frank Dana)
2022-01-12 10:52:44 -05:00
parent 806052f9c8
commit 549149d657
3 changed files with 43 additions and 31 deletions

View File

@@ -107,7 +107,14 @@ namespace openshot
auto sleep_time = duration_cast<micro_sec>(frame_duration - render_time);
// Debug
ZmqLogger::Instance()->AppendDebugMethod("PlayerPrivate::run (determine sleep)", "video_frame_diff", video_frame_diff, "video_position", video_position, "audio_position", audio_position, "speed", speed, "render_time(ms)", render_time.count(), "sleep_time(ms)", sleep_time.count());
ZmqLogger::Instance()->AppendDebugMethod(
"PlayerPrivate::run (determine sleep)",
"video_frame_diff", video_frame_diff,
"video_position", video_position,
"audio_position", audio_position,
"speed", speed,
"render_time(ms)", render_time.count(),
"sleep_time(ms)", sleep_time.count());
// Adjust drift (if more than a few frames off between audio and video)
if (video_frame_diff > 6 && reader->info.has_audio && reader->info.has_video) {

View File

@@ -77,46 +77,48 @@ namespace openshot
using ms = std::chrono::milliseconds;
using double_ms = std::chrono::duration<double, ms::period>;
while (!threadShouldExit() && is_playing) {
while (!threadShouldExit() && is_playing) {
// Calculate on-screen time for a single frame in milliseconds
const auto frame_duration = double_ms(1000.0 / reader->info.fps.ToDouble());
// Cache frames before the other threads need them
// Cache frames up to the max frames. Reset to current position
// if cache gets too far away from display frame. Cache frames
// even when player is paused (i.e. speed 0).
while (((position - current_display_frame) < max_concurrent_frames) && is_playing)
{
// Only cache up till the max_concurrent_frames amount... then sleep
try
{
if (reader) {
ZmqLogger::Instance()->AppendDebugMethod("VideoCacheThread::run (cache frame)", "position", position, "current_display_frame", current_display_frame, "max_concurrent_frames", max_concurrent_frames, "needed_frames", (position - current_display_frame));
// Cache frames before the other threads need them
// Cache frames up to the max frames. Reset to current position
// if cache gets too far away from display frame. Cache frames
// even when player is paused (i.e. speed 0).
while (((position - current_display_frame) < max_concurrent_frames) && is_playing)
{
// Only cache up till the max_concurrent_frames amount... then sleep
try
{
if (reader) {
ZmqLogger::Instance()->AppendDebugMethod(
"VideoCacheThread::run (cache frame)",
"position", position,
"current_display_frame", current_display_frame,
"max_concurrent_frames", max_concurrent_frames,
"needed_frames", (position - current_display_frame));
// Force the frame to be generated
// Force the frame to be generated
smallest_frame = reader->GetCache()->GetSmallestFrame();
if (smallest_frame && smallest_frame->number > current_display_frame) {
// Cache position has gotten too far away from current display frame.
// Reset the position to the current display frame.
position = current_display_frame;
}
reader->GetFrame(position);
}
}
reader->GetFrame(position);
}
}
// Ignore out of bounds frame exceptions
catch (const OutOfBoundsFrame & e) { }
}
catch (const OutOfBoundsFrame & e)
{
// Ignore out of bounds frame exceptions
}
// Increment frame number
position++;
}
// Increment frame number
position++;
}
// Sleep for 1 frame length
std::this_thread::sleep_for(frame_duration);
}
// Sleep for 1 frame length
std::this_thread::sleep_for(frame_duration);
}
return;
return;
}
}

View File

@@ -51,7 +51,10 @@ namespace openshot
if (need_render && frame)
{
// Debug
ZmqLogger::Instance()->AppendDebugMethod("VideoPlaybackThread::run (before render)", "frame->number", frame->number, "need_render", need_render);
ZmqLogger::Instance()->AppendDebugMethod(
"VideoPlaybackThread::run (before render)",
"frame->number", frame->number,
"need_render", need_render);
// Render the frame to the screen
renderer->paint(frame);