4#include "playbackengine/qffmpegplaybackengineobject_p.h"
6#include "QtCore/qchronotimer.h"
7#include "QtCore/qdebug.h"
8#include "QtCore/qscopedvaluerollback.h"
18 if (!thread()->isCurrentThread())
19 qWarning() <<
"The playback engine object is being removed in an unexpected thread";
29 if (m_atEnd.testAndSetRelease(!isAtEnd, isAtEnd) && isAtEnd)
40 if (m_paused.testAndSetRelease(!isPaused, isPaused))
46 m_invalidateCounter.fetch_add(1, std::memory_order_relaxed);
60 m_timer = std::make_unique<QChronoTimer>();
61 m_timer->setTimerType(Qt::PreciseTimer);
62 m_timer->setSingleShot(
true);
63 connect(m_timer.get(), &QChronoTimer::timeout,
this, &PlaybackEngineObject::onTimeout);
71 Q_ASSERT(m_timePoint && !m_nextTimePoint && m_stepType == StepType::None);
75 doNextStep(StepType::Timeout);
80 return TimePoint::min();
90 using std::chrono::milliseconds;
91 using namespace std::chrono_literals;
93 if (isValid() && canDoNextStep())
94 m_nextTimePoint = nextTimePoint();
96 m_nextTimePoint.reset();
98 if (m_stepType == StepType::Immediate)
103 if (m_stepType == StepType::None && m_nextTimePoint) {
104 if (now = SteadyClock::now(); *m_nextTimePoint <= *now) {
105 m_nextTimePoint.reset();
106 doNextStep(StepType::Immediate);
111 if (m_nextTimePoint) {
113 now = SteadyClock::now();
114 *m_nextTimePoint = std::max(*m_nextTimePoint, *now);
115 if (!m_timePoint || *m_nextTimePoint != std::max(*m_timePoint, *now)) {
116 timer().setInterval(*m_nextTimePoint - *now);
119 }
else if (m_timePoint) {
123 m_timePoint = std::exchange(m_nextTimePoint, std::nullopt);
128 Q_ASSERT(m_stepType == StepType::None && type != StepType::None);
129 QScopedValueRollback rollback(m_stepType, type);
135 if (e->type() == FuncEventType) {
137 static_cast<FuncEvent *>(e)->invoke();
141 return QObject::event(e);
148#include "moc_qffmpegplaybackengineobject_p.cpp"
~PlaybackEngineObject() override
virtual bool canDoNextStep() const
PlaybackEngineObject(const PlaybackEngineObjectID &id)
virtual TimePoint nextTimePoint() const
bool event(QEvent *e) override
This virtual function receives events to an object and should return true if the event e was recogniz...
virtual void doNextStep()
virtual void onPauseChanged()
void setAtEnd(bool isAtEnd)
std::chrono::steady_clock::time_point TimePoint
void setPaused(bool isPaused)
std::conditional_t< QT_FFMPEG_AVIO_WRITE_CONST, const uint8_t *, uint8_t * > AvioWriteBufferType
Combined button and popup list for selecting options.