File indexing completed on 2023-10-01 08:27:23

0001 /*
0002     SPDX-FileCopyrightText: 2014-2015 Harald Sitter <sitter@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef PA_DEVICE_H
0008 #define PA_DEVICE_H
0009 
0010 #include <QString>
0011 
0012 #include "port.h"
0013 #include "volumeobject.h"
0014 
0015 namespace PulseAudioQt
0016 {
0017 class Port;
0018 class DevicePrivate;
0019 
0020 /**
0021  * A PulseAudio device. Can be either a Sink or Source.
0022  */
0023 class PULSEAUDIOQT_EXPORT Device : public VolumeObject
0024 {
0025     Q_OBJECT
0026     Q_PROPERTY(State state READ state NOTIFY stateChanged)
0027     Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
0028     Q_PROPERTY(QString formFactor READ formFactor NOTIFY formFactorChanged)
0029     Q_PROPERTY(quint32 cardIndex READ cardIndex NOTIFY cardIndexChanged)
0030     Q_PROPERTY(QList<Port *> ports READ ports NOTIFY portsChanged)
0031     Q_PROPERTY(quint32 activePortIndex READ activePortIndex WRITE setActivePortIndex NOTIFY activePortIndexChanged)
0032     Q_PROPERTY(bool default READ isDefault WRITE setDefault NOTIFY defaultChanged)
0033 
0034 public:
0035     enum State {
0036         /** This state is used when the server does not support sink/source state introspection. */
0037         InvalidState = 0,
0038         /** Running, sink/source is playing/recording and used by at least one non-corked sink-input/source-output.  */
0039         RunningState,
0040         /** When idle, the sink/source is playing/recording but there is no non-corked sink-input/source-output attached to it. */
0041         IdleState,
0042         /** When suspended, actual sink/source access can be closed, for instance. */
0043         SuspendedState,
0044         UnknownState,
0045     };
0046     Q_ENUM(State);
0047 
0048     ~Device();
0049 
0050     /**
0051      * The state of this device.
0052      */
0053     State state() const;
0054 
0055     /**
0056      * A human readable description of this device.
0057      */
0058     QString description() const;
0059 
0060     /**
0061      * The device's form factor.
0062      * One of "internal", "speaker", "handset", "tv", "webcam", "microphone", "headset", "headphone", "hands-free", "car", "hifi", "computer", "portable".
0063      * This is based on PA_PROP_DEVICE_FORM_FACTOR.
0064      */
0065     QString formFactor() const;
0066 
0067     /**
0068      * Index of the card that owns this device.
0069      */
0070     quint32 cardIndex() const;
0071 
0072     /**
0073      * The ports associated with this device.
0074      */
0075     QList<Port *> ports() const;
0076 
0077     /**
0078      * The currently active port, by index.
0079      */
0080     quint32 activePortIndex() const;
0081 
0082     /**
0083      * Set the currently active port, by index.
0084      */
0085     virtual void setActivePortIndex(quint32 port_index) = 0;
0086 
0087     /**
0088      * Whether this is the default device.
0089      */
0090     virtual bool isDefault() const = 0;
0091 
0092     /**
0093      * Set whether this is the default device.
0094      */
0095     virtual void setDefault(bool enable) = 0;
0096 
0097 Q_SIGNALS:
0098     void stateChanged();
0099     void descriptionChanged();
0100     void formFactorChanged();
0101     void cardIndexChanged();
0102     void portsChanged();
0103     void activePortIndexChanged();
0104     void defaultChanged();
0105 
0106 protected:
0107     /** @private */
0108     explicit Device(QObject *parent);
0109     /** @private */
0110     DevicePrivate *d;
0111 
0112 private:
0113     friend class SinkPrivate;
0114     friend class SourcePrivate;
0115 };
0116 
0117 } // PulseAudioQt
0118 
0119 #endif // DEVICE_H