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
7QT_BEGIN_NAMESPACE
8
9using namespace QFFmpeg;
10
11void ConsumerThread::stopAndDelete()
12{
13 {
14 QMutexLocker locker(&m_loopDataMutex);
15 m_exit = true;
16 }
17 dataReady();
18 wait();
19 delete this;
20}
21
22void ConsumerThread::dataReady()
23{
24 m_condition.wakeAll();
25}
26
27void ConsumerThread::run()
28{
29 if (!init())
30 return;
31
32 while (true) {
33
34 {
35 QMutexLocker locker(&m_loopDataMutex);
36 while (!hasData() && !m_exit)
37 m_condition.wait(lockedMutex: &m_loopDataMutex);
38
39 if (m_exit)
40 break;
41 }
42
43 processOne();
44 }
45
46 cleanup();
47}
48
49QMutexLocker<QMutex> ConsumerThread::lockLoopData() const
50{
51 return QMutexLocker(&m_loopDataMutex);
52}
53
54QT_END_NAMESPACE
55

source code of qtmultimedia/src/plugins/multimedia/ffmpeg/qffmpegthread.cpp