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
8
9#include <QtCore/qmutex.h>
10#include <mutex>
11
12QT_BEGIN_NAMESPACE
13
14namespace QtPipeWire {
15
16Q_LOGGING_CATEGORY(lcPipewire, "qt.multimedia.pipewire");
17
18namespace {
19
20struct InstanceHolder
21{
22 QMutex mutex;
23 std::weak_ptr<QPipeWireInstance> instance;
24};
25
26Q_GLOBAL_STATIC(InstanceHolder, s_pipeWireInstance);
27
28} // namespace
29
30std::shared_ptr<QPipeWireInstance> QPipeWireInstance::instance()
31{
32 std::lock_guard guard{ s_pipeWireInstance->mutex };
33 std::shared_ptr<QPipeWireInstance> ret = s_pipeWireInstance->instance.lock();
34 if (!ret) {
35 ret = std::make_shared<QPipeWireInstance>();
36 s_pipeWireInstance->instance = ret;
37 }
38 return ret;
39}
40
42{
43 return qPipewireIsLoaded();
44}
45
47{
48 pw_init(nullptr, nullptr);
49
50 qCDebug(lcPipewire) << "PipeWire initialized: compiled against" << pw_get_headers_version()
51 << " running " << pw_get_library_version();
52}
53
55{
57 pw_deinit();
58}
59
60} // namespace QtPipeWire
61
62QT_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)