Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qpipewire_audiocontextmanager_p.h
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
4
#
ifndef
QPIPEWIRE_AUDIOCONTEXTMANAGER_P_H
5
#
define
QPIPEWIRE_AUDIOCONTEXTMANAGER_P_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
<
QtMultimedia
/
private
/
qpipewire_audiodevicemonitor_p
.
h
>
19
#
include
<
QtMultimedia
/
private
/
qpipewire_registry_support_p
.
h
>
20
#
include
<
QtMultimedia
/
private
/
qpipewire_support_p
.
h
>
21
#
include
<
QtMultimedia
/
private
/
qpipewire_instance_p
.
h
>
22
#
include
<
QtCore
/
qglobal
.
h
>
23
24
#
include
<
pipewire
/
pipewire
.
h
>
25
26
#
include
<
optional
>
27
28
QT_BEGIN_NAMESPACE
29
30
namespace
QtPipeWire
{
31
32
// returns the value of the "name" member of a JSON object, as found in the values of the
33
// "default" metadata object, e.g. {"name": "alsa_output.pci-0000_00_1f.3.analog-stereo"}
34
Q_MULTIMEDIA_EXPORT
std
::
optional
<
QByteArray
>
jsonParseObjectName
(
const
char
*
json
);
35
36
struct
QPipewireAudioStream
;
37
38
class
QAudioContextManager
39
{
40
public
:
41
QAudioContextManager
();
42
~
QAudioContextManager
();
43
44
static
bool
minimumRequirementMet
();
45
46
static
QAudioContextManager
*
instance
();
47
bool
isConnected
()
const
;
48
49
template
<
typename
Closure>
50
static
auto
withEventLoopLock
(Closure &&c)
51
{
52
QAudioContextManager
*self =
instance
(
)
;
53
return
self->m_pwInstance->runWithEventLoopLock(
std
::forward<Closure>(c));
54
}
55
56
static
QAudioDeviceMonitor
&
deviceMonitor
();
57
58
static
bool
isInPwThreadLoop
();
59
static
pw_loop *
getEventLoop
();
60
61
PwNodeHandle
bindNode
(
ObjectId
);
62
PwMetadataHandle
bindMetadata
(
ObjectId
);
63
64
void
syncRegistry
();
65
66
void
registerStreamReference
(
std
::
shared_ptr
<
QPipewireAudioStream
>);
67
void
unregisterStreamReference
(
const
std::shared_ptr<QPipewireAudioStream> &);
68
69
const
PwCoreConnectionHandle
&
coreConnection
()
const
;
70
71
private
:
72
const
std::shared_ptr<QPipeWireInstance> m_pwInstance;
73
74
// pw_core connection
75
PwCoreConnectionHandle m_coreConnection;
76
77
// device monitor
78
PwRegistryHandle m_registry;
79
spa_hook m_registryListener{};
80
std::unique_ptr<QAudioDeviceMonitor> m_deviceMonitor;
81
82
void
startDeviceMonitor();
83
void
stopDeviceMonitor();
84
static
void
objectAddedCb(
void
*data, uint32_t id, uint32_t permissions,
const
char
*type,
85
uint32_t version,
const
struct
spa_dict *props);
86
static
void
objectRemovedCb(
void
*data, uint32_t id);
87
void
objectAdded(ObjectId id, uint32_t permissions, PipewireRegistryType, uint32_t version,
88
const
spa_dict &props);
89
void
objectRemoved(ObjectId id);
90
91
// default metadata object
92
void
startListenDefaultMetadataObject(ObjectId, uint32_t version);
93
void
stopListenDefaultMetadataObject();
94
struct
MetadataRecord
95
{
96
const
char
*key;
97
const
char
*type;
98
const
char
*value;
99
};
100
101
int
handleDefaultMetadataObjectEvent(ObjectId subject,
const
MetadataRecord &);
102
103
PwMetadataHandle m_defaultMetadataObject;
104
spa_hook m_defaultMetadataObjectListener{};
105
106
QMutex m_activeStreamMutex;
107
std
::
set
<
std
::
shared_ptr
<
QPipewireAudioStream
>>
m_activeStreams
;
108
void
stopActiveStreams();
109
};
110
111
}
// namespace QtPipeWire
112
113
QT_END_NAMESPACE
114
115
#
endif
// QPIPEWIRE_AUDIOCONTEXTMANAGER_P_H
QtPipeWire::QAudioContextManager
Definition
qpipewire_audiocontextmanager_p.h:39
QtPipeWire::QAudioContextManager::minimumRequirementMet
static bool minimumRequirementMet()
Definition
qpipewire_audiocontextmanager.cpp:72
QtPipeWire::QAudioContextManager::bindNode
PwNodeHandle bindNode(ObjectId)
Definition
qpipewire_audiocontextmanager.cpp:102
QtPipeWire::QAudioContextManager::syncRegistry
void syncRegistry()
Definition
qpipewire_audiocontextmanager.cpp:120
QtPipeWire::QAudioContextManager::~QAudioContextManager
~QAudioContextManager()
Definition
qpipewire_audiocontextmanager.cpp:57
QtPipeWire::QAudioContextManager::deviceMonitor
static QAudioDeviceMonitor & deviceMonitor()
Definition
qpipewire_audiocontextmanager.cpp:87
QtPipeWire::QAudioContextManager::instance
static QAudioContextManager * instance()
Definition
qpipewire_audiocontextmanager.cpp:77
QtPipeWire::QAudioContextManager::isConnected
bool isConnected() const
Definition
qpipewire_audiocontextmanager.cpp:82
QtPipeWire::QAudioContextManager::registerStreamReference
void registerStreamReference(std::shared_ptr< QPipewireAudioStream >)
Definition
qpipewire_audiocontextmanager.cpp:136
QtPipeWire::QAudioContextManager::unregisterStreamReference
void unregisterStreamReference(const std::shared_ptr< QPipewireAudioStream > &)
Definition
qpipewire_audiocontextmanager.cpp:142
QtPipeWire::QAudioContextManager::bindMetadata
PwMetadataHandle bindMetadata(ObjectId)
Definition
qpipewire_audiocontextmanager.cpp:111
QtPipeWire::QAudioContextManager::withEventLoopLock
static auto withEventLoopLock(Closure &&c)
Definition
qpipewire_audiocontextmanager_p.h:50
QtPipeWire::QAudioContextManager::QAudioContextManager
QAudioContextManager()
Definition
qpipewire_audiocontextmanager.cpp:37
QtPipeWire::QAudioContextManager::isInPwThreadLoop
static bool isInPwThreadLoop()
Definition
qpipewire_audiocontextmanager.cpp:92
QtPipeWire::QAudioContextManager::getEventLoop
static pw_loop * getEventLoop()
Definition
qpipewire_audiocontextmanager.cpp:97
QtPipeWire::QAudioContextManager::coreConnection
const PwCoreConnectionHandle & coreConnection() const
Definition
qpipewire_audiocontextmanager.cpp:149
QtPipeWire
Definition
qpipewire_async_support.cpp:10
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
__has_include
#define __has_include(x)
Definition
qcompilerdetection.h:459
pw_check_library_version
bool pw_check_library_version(int major, int minor, int micro)
QtPipeWire::QPipewireAudioStream
Definition
qpipewire_audiostream_p.h:33
qtmultimedia
src
multimedia
pipewire
qpipewire_audiocontextmanager_p.h
Generated on
for Qt by
1.18.0