Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qpipewire_instance.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 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 <QtMultimedia/private/qtmultimediaglobal_p.h>
7
9#if QT_CONFIG(pipewire_symbolloader)
10# include "qpipewire_symbolloader_p.h"
11#endif
12
13#include <QtCore/qmutex.h>
14#include <mutex>
15
16QT_BEGIN_NAMESPACE
17
18namespace QtPipeWire {
19
20Q_LOGGING_CATEGORY(lcPipewire, "qt.multimedia.pipewire");
21
22namespace {
23
24struct InstanceHolder
25{
26 QMutex mutex;
27 std::weak_ptr<QPipeWireInstance> instance;
28};
29
30Q_GLOBAL_STATIC(InstanceHolder, s_pipeWireInstance);
31
32} // namespace
33
34std::shared_ptr<QPipeWireInstance> QPipeWireInstance::instance()
35{
36 std::lock_guard guard{ s_pipeWireInstance->mutex };
37 std::shared_ptr<QPipeWireInstance> ret = s_pipeWireInstance->instance.lock();
38 if (!ret) {
39 ret = std::make_shared<QPipeWireInstance>();
40 s_pipeWireInstance->instance = ret;
41 }
42 return ret;
43}
44
46{
47#if QT_CONFIG(pipewire_symbolloader)
48 return qPipewireIsLoaded();
49#else
50 return 1;
51#endif
52}
53
55{
56 pw_init(nullptr, nullptr);
57
58 qCDebug(lcPipewire) << "PipeWire initialized: compiled against" << pw_get_headers_version()
59 << " running " << pw_get_library_version();
60}
61
63{
65 pw_deinit();
66}
67
68} // namespace QtPipeWire
69
70QT_END_NAMESPACE
Q_LOGGING_CATEGORY(lcPipewire, "qt.multimedia.pipewire")
Q_DECLARE_LOGGING_CATEGORY(lcPipewire)
bool pw_check_library_version(int major, int minor, int micro)