PulseAudio Qt Bindings

device.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 PA_DEVICE_H
8#define PA_DEVICE_H
9
10#include <QString>
11#include <QVariantMap>
12
13#include "port.h"
14#include "volumeobject.h"
15
16namespace PulseAudioQt
17{
18class Port;
19class DevicePrivate;
20
21/**
22 * A PulseAudio device. Can be either a Sink or Source.
23 */
24class PULSEAUDIOQT_EXPORT Device : public VolumeObject
25{
26 Q_OBJECT
27 Q_PROPERTY(State state READ state NOTIFY stateChanged)
28 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
29 Q_PROPERTY(QString formFactor READ formFactor NOTIFY formFactorChanged)
30 Q_PROPERTY(quint32 cardIndex READ cardIndex NOTIFY cardIndexChanged)
31 Q_PROPERTY(QList<Port *> ports READ ports NOTIFY portsChanged)
32 Q_PROPERTY(quint32 activePortIndex READ activePortIndex WRITE setActivePortIndex NOTIFY activePortIndexChanged)
33 Q_PROPERTY(bool default READ isDefault WRITE setDefault NOTIFY defaultChanged)
34 Q_PROPERTY(qint64 baseVolume READ baseVolume NOTIFY baseVolumeChanged)
35 Q_PROPERTY(QVariantMap pulseProperties READ pulseProperties NOTIFY pulsePropertiesChanged)
36 Q_PROPERTY(bool virtualDevice READ isVirtualDevice NOTIFY virtualDeviceChanged)
37
38public:
39 enum State {
40 /** This state is used when the server does not support sink/source state introspection. */
41 InvalidState = 0,
42 /** Running, sink/source is playing/recording and used by at least one non-corked sink-input/source-output. */
44 /** When idle, the sink/source is playing/recording but there is no non-corked sink-input/source-output attached to it. */
46 /** When suspended, actual sink/source access can be closed, for instance. */
48 UnknownState,
49 };
50 Q_ENUM(State);
51
52 ~Device();
53
54 /**
55 * The state of this device.
56 */
57 State state() const;
58
59 /**
60 * A human readable description of this device.
61 */
62 QString description() const;
63
64 /**
65 * The device's form factor.
66 * One of "internal", "speaker", "handset", "tv", "webcam", "microphone", "headset", "headphone", "hands-free", "car", "hifi", "computer", "portable".
67 * This is based on PA_PROP_DEVICE_FORM_FACTOR.
68 */
69 QString formFactor() const;
70
71 /**
72 * Index of the card that owns this device.
73 */
74 quint32 cardIndex() const;
75
76 /**
77 * The ports associated with this device.
78 */
79 QList<Port *> ports() const;
80
81 /**
82 * The currently active port, by index.
83 */
84 quint32 activePortIndex() const;
85
86 /**
87 * Set the currently active port, by index.
88 */
89 virtual void setActivePortIndex(quint32 port_index) = 0;
90
91 /**
92 * Whether this is the default device.
93 */
94 virtual bool isDefault() const = 0;
95
96 /**
97 * Set whether this is the default device.
98 */
99 virtual void setDefault(bool enable) = 0;
100
101 /**
102 * The base volume of this device, generally useful as a good default volume.
103 */
104 qint64 baseVolume() const;
105
106 /**
107 * @return QVariantMap the pulseaudio properties of this device (e.g. media.class, device.api, ...)
108 */
109 [[nodiscard]] QVariantMap pulseProperties() const;
110
111 /**
112 * @brief Switch all streams onto this Device
113 * Iterates through all relevant streams for the Device type and assigns them to this Device.
114 * For example for a Sink device all SinkInputs known to the daemon will be explicitly switched
115 * onto this Sink. Useful for mass-rerouting of streams from different devices onto a specific target device.
116 */
117 virtual Q_INVOKABLE void switchStreams() = 0;
118
119 /**
120 * @returns true when the device is a virtual device (e.g. a software-only sink)
121 */
122 bool isVirtualDevice() const;
123
124Q_SIGNALS:
125 void stateChanged();
126 void descriptionChanged();
127 void formFactorChanged();
128 void cardIndexChanged();
129 void portsChanged();
130 void activePortIndexChanged();
131 void defaultChanged();
132 void baseVolumeChanged();
133 void pulsePropertiesChanged();
134 void virtualDeviceChanged();
135
136protected:
137 /** @private */
138 explicit Device(QObject *parent);
139 /** @private */
140 DevicePrivate *d;
141
142private:
143 friend class SinkPrivate;
144 friend class SourcePrivate;
145};
146
147} // PulseAudioQt
148
149#endif // DEVICE_H
A PulseAudio device.
Definition device.h:25
virtual bool isDefault() const =0
Whether this is the default device.
@ SuspendedState
When suspended, actual sink/source access can be closed, for instance.
Definition device.h:47
@ IdleState
When idle, the sink/source is playing/recording but there is no non-corked sink-input/source-output a...
Definition device.h:45
@ RunningState
Running, sink/source is playing/recording and used by at least one non-corked sink-input/source-outpu...
Definition device.h:43
virtual void setDefault(bool enable)=0
Set whether this is the default device.
virtual void setActivePortIndex(quint32 port_index)=0
Set the currently active port, by index.
virtual Q_INVOKABLE void switchStreams()=0
Switch all streams onto this Device Iterates through all relevant streams for the Device type and ass...
An PulseObject that has a volume.
The primary namespace of PulseAudioQt.
Definition card.cpp:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.