Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qffmpegthread.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
4#include "qffmpegthread_p.h"
5
6#include <qloggingcategory.h>
7
9
10using namespace QFFmpeg;
11
12void Thread::kill()
13{
14 {
15 QMutexLocker locker(&mutex);
16 exit.storeRelease(true);
17 killHelper();
18 }
19 wake();
20 wait();
21 delete this;
22}
23
24void Thread::maybePause()
25{
26 while (timeOut > 0 || shouldWait()) {
27 if (exit.loadAcquire())
28 break;
29
31 timer.start();
33 if (timeOut >= 0) {
34 timeOut -= timer.elapsed();
35 if (timeOut < 0)
36 timeOut = -1;
37 }
38 } else {
39 timeOut = -1;
40 }
41 }
42}
43
45{
46 init();
47 QMutexLocker locker(&mutex);
48 while (1) {
49 maybePause();
50 if (exit.loadAcquire())
51 break;
52 loop();
53 }
54 cleanup();
55}
56
T loadAcquire() const noexcept
void storeRelease(T newValue) noexcept
\inmodule QtCore
\inmodule QtCore
virtual void cleanup()
virtual void init()
void run() override
virtual void loop()=0
virtual void killHelper()
virtual bool shouldWait() const
QAtomicInteger< bool > exit
\inmodule QtCore
Definition qmutex.h:317
bool wait(QDeadlineTimer deadline=QDeadlineTimer(QDeadlineTimer::Forever))
Definition qthread.cpp:950
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition qtimer.cpp:208
Combined button and popup list for selecting options.
@ PreciseTimer
GLenum condition
QTimer * timer
[3]