File indexing completed on 2024-10-06 08:04:21
0001 /* 0002 SPDX-FileCopyrightText: 2016 David Rosca <nowrep@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef STREAMRESTORE_H 0008 #define STREAMRESTORE_H 0009 0010 #include "pulseobject.h" 0011 0012 #include <pulse/ext-stream-restore.h> 0013 0014 namespace QPulseAudio 0015 { 0016 class StreamRestore : public PulseObject 0017 { 0018 Q_OBJECT 0019 Q_PROPERTY(QString name READ name NOTIFY nameChanged) 0020 Q_PROPERTY(QString device READ device WRITE setDevice NOTIFY deviceChanged) 0021 Q_PROPERTY(qint64 volume READ volume WRITE setVolume NOTIFY volumeChanged) 0022 Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) 0023 Q_PROPERTY(bool hasVolume READ hasVolume CONSTANT) 0024 Q_PROPERTY(bool volumeWritable READ isVolumeWritable CONSTANT) 0025 Q_PROPERTY(QStringList channels READ channels NOTIFY channelsChanged) 0026 Q_PROPERTY(QList<qreal> channelVolumes READ channelVolumes NOTIFY channelVolumesChanged) 0027 Q_PROPERTY(quint32 deviceIndex READ deviceIndex WRITE setDeviceIndex NOTIFY deviceIndexChanged) 0028 public: 0029 StreamRestore(quint32 index, const QVariantMap &properties, QObject *parent); 0030 0031 void update(const pa_ext_stream_restore_info *info); 0032 0033 QString name() const; 0034 0035 QString device() const; 0036 void setDevice(const QString &device); 0037 0038 qint64 volume() const; 0039 void setVolume(qint64 volume); 0040 0041 bool isMuted() const; 0042 void setMuted(bool muted); 0043 0044 bool hasVolume() const; 0045 bool isVolumeWritable() const; 0046 0047 QStringList channels() const; 0048 0049 QList<qreal> channelVolumes() const; 0050 0051 quint32 deviceIndex() const; 0052 void setDeviceIndex(quint32 deviceIndex); 0053 0054 Q_INVOKABLE void setChannelVolume(int channel, qint64 volume); 0055 0056 Q_SIGNALS: 0057 void nameChanged(); 0058 void deviceChanged(); 0059 void volumeChanged(); 0060 void mutedChanged(); 0061 void channelsChanged(); 0062 void channelVolumesChanged(); 0063 void deviceIndexChanged(); 0064 0065 private: 0066 void writeChanges(const pa_cvolume &volume, bool muted, const QString &device); 0067 0068 QString m_name; 0069 QString m_device; 0070 pa_cvolume m_volume; 0071 pa_channel_map m_channelMap; 0072 QStringList m_channels; 0073 bool m_muted = false; 0074 0075 struct { 0076 bool valid = false; 0077 pa_cvolume volume; 0078 bool muted; 0079 QString device; 0080 } m_cache; 0081 }; 0082 0083 } // QPulseAudio 0084 0085 #endif // STREAMRESTORE_H