PulseAudio Qt Bindings

context.h
1/*
2 SPDX-FileCopyrightText: 2014-2015 Harald Sitter <sitter@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef CONTEXT_H
8#define CONTEXT_H
9
10#include "pulseaudioqt_export.h"
11#include <QObject>
12
13struct pa_context;
14
15/**
16 * The primary namespace of PulseAudioQt.
17 */
18namespace PulseAudioQt
19{
20class Card;
21class Client;
22class Sink;
23class SinkInput;
24class Source;
25class SourceOutput;
26class StreamRestore;
27class Module;
28class Server;
29
30/**
31 * The normal volume (100%, 0 dB). Equivalent to PA_VOLUME_NORM.
32 */
33PULSEAUDIOQT_EXPORT qint64 normalVolume();
34/**
35 * The minimum volume (0%). Equivalent to PA_VOLUME_MUTED.
36 */
37PULSEAUDIOQT_EXPORT qint64 minimumVolume();
38/**
39 * The maximum volume PulseAudio can store. Equivalent to PA_VOLUME_MAX.
40 * \warning For UI elements like volume sliders use maximumUIVolume instead.
41 */
42PULSEAUDIOQT_EXPORT qint64 maximumVolume();
43
44/**
45 * The maximum volume suitable to display in a UI. Equivalent to PA_VOLUME_UI_MAX.
46 */
47PULSEAUDIOQT_EXPORT qint64 maximumUIVolume();
48
49class PULSEAUDIOQT_EXPORT Context : public QObject
50{
51 Q_OBJECT
52
53public:
54 ~Context() override;
55
56 static Context *instance();
57
58 /**
59 * Set the application id that is reported to PulseAudio.
60 * This needs to be called before accessing the context singleton the first time.
61 * If not set QGuiApplication::desktopFileName() is used.
62 */
63 static void setApplicationId(const QString &applicationId);
64
65 bool isValid();
66
67 /**
68 * Returns a list of all sinks.
69 *
70 * @return list of sinks
71 */
72 QList<Sink *> sinks() const;
73
74 /**
75 * Returns a list of all sink inputs.
76 *
77 * @return list of sink inputs
78 */
79 QList<SinkInput *> sinkInputs() const;
80
81 /**
82 * Returns a list of all sources.
83 *
84 * @return list of sources
85 */
86 QList<Source *> sources() const;
87
88 /**
89 * Returns a list of all source outputs.
90 *
91 * @return list of source outputs
92 */
93 QList<SourceOutput *> sourceOutputs() const;
94
95 /**
96 * Returns a list of all clients.
97 *
98 * @return list of clients
99 */
100 QList<Client *> clients() const;
101
102 /**
103 * Returns a list of all cards.
104 *
105 * @return list of cards
106 */
107 QList<Card *> cards() const;
108
109 /**
110 * Returns a list of all modules.
111 *
112 * @return list of modules
113 */
114 QList<Module *> modules() const;
115
116 /**
117 * Returns a list of all stream restores.
118 *
119 * @return list of stream restores
120 */
121 QList<StreamRestore *> streamRestores() const;
122
123 Server *server() const;
124
125 /**
126 * Returns a pointer to the raw PulseAudio context.
127 */
128 pa_context *context() const;
129
130 void setCardProfile(quint32 index, const QString &profile);
131 void setDefaultSink(const QString &name);
132 void setDefaultSource(const QString &name);
133
134Q_SIGNALS:
135 /**
136 * Indicates that sink was added.
137 */
138 void sinkAdded(PulseAudioQt::Sink *sink);
139
140 /**
141 * Indicates that sink was removed.
142 */
143 void sinkRemoved(PulseAudioQt::Sink *sink);
144
145 /**
146 * Indicates that sink input was added.
147 */
148 void sinkInputAdded(PulseAudioQt::SinkInput *sinkInput);
149
150 /**
151 * Indicates that sink input was removed.
152 */
153 void sinkInputRemoved(PulseAudioQt::SinkInput *sinkInput);
154
155 /**
156 * Indicates that source was added.
157 */
158 void sourceAdded(PulseAudioQt::Source *source);
159
160 /**
161 * Indicates that source was removed.
162 */
163 void sourceRemoved(PulseAudioQt::Source *source);
164
165 /**
166 * Indicates that source output was added.
167 */
168 void sourceOutputAdded(PulseAudioQt::SourceOutput *sourceOutput);
169
170 /**
171 * Indicates that source output was removed.
172 */
173 void sourceOutputRemoved(PulseAudioQt::SourceOutput *sourceOutput);
174
175 /**
176 * Indicates that client was added.
177 */
178 void clientAdded(PulseAudioQt::Client *client);
179
180 /**
181 * Indicates that client was removed.
182 */
183 void clientRemoved(PulseAudioQt::Client *client);
184
185 /**
186 * Indicates that card was added.
187 */
188 void cardAdded(PulseAudioQt::Card *card);
189
190 /**
191 * Indicates that card was removed.
192 */
193 void cardRemoved(PulseAudioQt::Card *card);
194
195 /**
196 * Indicates that module was added.
197 */
198 void moduleAdded(PulseAudioQt::Module *module);
199
200 /**
201 * Indicates that module was removed.
202 */
203 void moduleRemoved(PulseAudioQt::Module *module);
204
205 /**
206 * Indicates that stream restore was added.
207 */
208 void streamRestoreAdded(PulseAudioQt::StreamRestore *streamRestore);
209
210 /**
211 * Indicates that streamRestore was removed.
212 */
213 void streamRestoreRemoved(PulseAudioQt::StreamRestore *streamRestore);
214
215private:
216 explicit Context(QObject *parent = nullptr);
217
218 class ContextPrivate *const d;
219
220 friend class Sink;
221 friend class SinkInput;
222 friend class Source;
223 friend class SourceOutput;
224 friend class Stream;
225 friend class StreamRestorePrivate;
226 friend class Server;
227 friend class SinkModel;
228 friend class SinkInputModel;
229 friend class SourceModel;
230 friend class SourceOutputModel;
231 friend class StreamRestoreModel;
232 friend class CardModel;
233 friend class ModuleModel;
234};
235
236} // PulseAudioQt
237
238#endif // CONTEXT_H
A SinkInput stream.
Definition sinkinput.h:20
A PulseAudio sink.
Definition sink.h:20
A SourceOutput Stream.
A PulseAudio source.
Definition source.h:20
bool isValid(QStringView ifopt)
The primary namespace of PulseAudioQt.
Definition card.cpp:17
qint64 normalVolume()
The normal volume (100%, 0 dB).
Definition context.cpp:35
qint64 maximumUIVolume()
The maximum volume suitable to display in a UI.
Definition context.cpp:50
qint64 minimumVolume()
The minimum volume (0%).
Definition context.cpp:40
qint64 maximumVolume()
The maximum volume PulseAudio can store.
Definition context.cpp:45
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:54:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.