From 549149d6573cfcce2a4ccfae9221e18dd99aae4c Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 12 Jan 2022 10:52:44 -0500 Subject: [PATCH] src/Qt/*: Reformat logging calls, fix indents --- src/Qt/PlayerPrivate.cpp | 9 ++++- src/Qt/VideoCacheThread.cpp | 60 ++++++++++++++++++---------------- src/Qt/VideoPlaybackThread.cpp | 5 ++- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/Qt/PlayerPrivate.cpp b/src/Qt/PlayerPrivate.cpp index 2cd8c6db..932508f2 100644 --- a/src/Qt/PlayerPrivate.cpp +++ b/src/Qt/PlayerPrivate.cpp @@ -107,7 +107,14 @@ namespace openshot auto sleep_time = duration_cast(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) { diff --git a/src/Qt/VideoCacheThread.cpp b/src/Qt/VideoCacheThread.cpp index 60d94d1d..b798e84c 100644 --- a/src/Qt/VideoCacheThread.cpp +++ b/src/Qt/VideoCacheThread.cpp @@ -77,46 +77,48 @@ namespace openshot using ms = std::chrono::milliseconds; using double_ms = std::chrono::duration; - 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; } } diff --git a/src/Qt/VideoPlaybackThread.cpp b/src/Qt/VideoPlaybackThread.cpp index f8df00cc..b8c53e58 100644 --- a/src/Qt/VideoPlaybackThread.cpp +++ b/src/Qt/VideoPlaybackThread.cpp @@ -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);