Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qffmpegplaybackengineobject.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include "qtimer.h"
7#include "qdebug.h"
8
10
11namespace QFFmpeg {
12
13static QAtomicInteger<PlaybackEngineObject::Id> PersistentId = 0;
14
16
18{
20 qWarning() << "The playback engine object is being removed in an unexpected thread";
21}
22
24{
25 return m_paused;
26}
27
29{
30 if (m_atEnd.testAndSetRelease(!isAtEnd, isAtEnd) && isAtEnd)
31 emit atEnd();
32}
33
35{
36 return m_atEnd;
37}
38
40{
41 return m_id;
42}
43
49
51{
52 m_deleting.storeRelease(true);
53
54 disconnect();
56}
57
59{
60 return !m_paused;
61}
62
64{
65 if (!m_timer) {
66 m_timer = std::make_unique<QTimer>();
67 m_timer->setTimerType(Qt::PreciseTimer);
68 m_timer->setSingleShot(true);
69 connect(m_timer.get(), &QTimer::timeout, this, &PlaybackEngineObject::onTimeout);
70 }
71
72 return *m_timer;
73}
74
75void PlaybackEngineObject::onTimeout()
76{
77 if (!m_deleting && canDoNextStep())
78 doNextStep();
79}
80
82{
83 return 0;
84}
85
90
91void PlaybackEngineObject::scheduleNextStep(bool allowDoImmediatelly)
92{
93 if (!m_deleting && canDoNextStep()) {
94 const auto interval = timerInterval();
95 if (interval == 0 && allowDoImmediatelly) {
96 timer().stop();
97 doNextStep();
98 } else {
99 timer().start(interval);
100 }
101 } else {
102 timer().stop();
103 }
104}
105} // namespace QFFmpeg
106
108
109#include "moc_qffmpegplaybackengineobject_p.cpp"
bool testAndSetRelease(T expectedValue, T newValue) noexcept
void storeRelease(T newValue) noexcept
void scheduleNextStep(bool allowDoImmediatelly=true)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
QThread * thread() const
Returns the thread in which the object lives.
Definition qobject.cpp:1598
void deleteLater()
\threadsafe
Definition qobject.cpp:2435
static QThread * currentThread()
Definition qthread.cpp:1039
\inmodule QtCore
Definition qtimer.h:20
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition qtimer.cpp:241
void stop()
Stops the timer.
Definition qtimer.cpp:267
void timeout(QPrivateSignal)
This signal is emitted when the timer times out.
static QAtomicInteger< PlaybackEngineObject::Id > PersistentId
Combined button and popup list for selecting options.
@ PreciseTimer
#define qWarning
Definition qlogging.h:166
#define emit
myObject disconnect()
[26]
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(nullptr), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
\threadsafe This is an overloaded member function, provided for convenience. It differs from the abov...