Files
libopenshot/src/Qt/VideoPlaybackThread.cpp

62 lines
1.3 KiB
C++
Raw Normal View History

2014-01-27 19:03:46 +08:00
/**
* @file
* @brief Source file for VideoPlaybackThread class
* @author Duzy Chan <code@duzy.info>
* @author Jonathan Thomas <jonathan@openshot.org>
2014-01-27 19:03:46 +08:00
*
* @ref License
*/
// Copyright (c) 2008-2019 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#include "VideoPlaybackThread.h"
2014-01-27 19:03:46 +08:00
namespace openshot
{
// Constructor
2014-01-27 19:03:46 +08:00
VideoPlaybackThread::VideoPlaybackThread(RendererBase *rb)
: Thread("video-playback"), renderer(rb)
, render(), reset(false)
{
}
// Destructor
2014-01-27 19:03:46 +08:00
VideoPlaybackThread::~VideoPlaybackThread()
{
}
// Get the currently playing frame number (if any)
int64_t VideoPlaybackThread::getCurrentFramePosition()
{
if (frame)
return frame->number;
else
return 0;
}
// Start the thread
2014-01-27 19:03:46 +08:00
void VideoPlaybackThread::run()
{
while (!threadShouldExit()) {
// Make other threads wait on the render event
bool need_render = render.wait(500);
if (need_render && frame)
{
// Debug
ZmqLogger::Instance()->AppendDebugMethod("VideoPlaybackThread::run (before render)", "frame->number", frame->number, "need_render", need_render);
// Render the frame to the screen
renderer->paint(frame);
}
// Signal to other threads that the rendered event has completed
rendered.signal();
2014-01-27 19:03:46 +08:00
}
return;
2014-01-27 19:03:46 +08:00
}
}