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
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
8
9using namespace QFFmpeg;
10
12{
13 {
14 QMutexLocker locker(&m_loopDataMutex);
15 m_exit = true;
16 }
17 dataReady();
18 wait();
19 delete this;
20}
21
23{
24 m_condition.wakeAll();
25}
26
28{
29 init();
30
31 while (true) {
32
33 {
34 QMutexLocker locker(&m_loopDataMutex);
35 while (!hasData() && !m_exit)
36 m_condition.wait(&m_loopDataMutex);
37
38 if (m_exit)
39 break;
40 }
41
42 processOne();
43 }
44
45 cleanup();
46}
47
48QMutexLocker<QMutex> ConsumerThread::lockLoopData() const
49{
50 return QMutexLocker(&m_loopDataMutex);
51}
52
virtual bool hasData() const =0
Must return true when data is available for processing.
virtual void init()=0
Called on this thread when thread starts.
void stopAndDelete()
Stops the thread and deletes this object.
QMutexLocker< QMutex > lockLoopData() const
Locks the loop data mutex.
void dataReady()
Wake thread from sleep and process data until hasData() returns false.
virtual void cleanup()=0
Called on this thread before thread exits.
virtual void processOne()=0
Process one work item.
\inmodule QtCore
Definition qmutex.h:313
bool wait(QDeadlineTimer deadline=QDeadlineTimer(QDeadlineTimer::Forever))
Definition qthread.cpp:1023
bool wait(QMutex *, QDeadlineTimer=QDeadlineTimer(QDeadlineTimer::Forever))
Combined button and popup list for selecting options.