Changeset View
Changeset View
Standalone View
Standalone View
plugins/systemvolume/stream.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright 2014-2015 Harald Sitter <sitter@kde.org> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Lesser General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | later version accepted by the membership of KDE e.V. (or its | ||||
9 | successor approved by the membership of KDE e.V.), which shall | ||||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | | ||||
12 | This library is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | Lesser General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU Lesser General Public | ||||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #ifndef STREAM_H | ||||
22 | #define STREAM_H | ||||
23 | | ||||
24 | #include <QString> | ||||
25 | | ||||
26 | #include <pulse/volume.h> | ||||
27 | | ||||
28 | #include "volumeobject.h" | ||||
29 | #include "pulseobject.h" | ||||
30 | | ||||
31 | #include "context.h" | ||||
32 | // Properties need fully qualified classes even with pointers. | ||||
33 | #include "client.h" | ||||
34 | | ||||
35 | namespace QPulseAudio | ||||
36 | { | ||||
37 | | ||||
38 | class Stream : public VolumeObject | ||||
39 | { | ||||
40 | Q_OBJECT | ||||
41 | Q_PROPERTY(QString name READ name NOTIFY nameChanged) | ||||
42 | Q_PROPERTY(QPulseAudio::Client *client READ client NOTIFY clientChanged) | ||||
43 | Q_PROPERTY(bool virtualStream READ isVirtualStream NOTIFY virtualStreamChanged) | ||||
44 | Q_PROPERTY(quint32 deviceIndex READ deviceIndex WRITE setDeviceIndex NOTIFY deviceIndexChanged) | ||||
45 | Q_PROPERTY(bool corked READ isCorked NOTIFY corkedChanged) | ||||
46 | public: | ||||
47 | template <typename PAInfo> | ||||
48 | void updateStream(const PAInfo *info) | ||||
49 | { | ||||
50 | updateVolumeObject(info); | ||||
51 | | ||||
52 | if (m_name != QString::fromUtf8(info->name)) { | ||||
53 | m_name = QString::fromUtf8(info->name); | ||||
54 | emit nameChanged(); | ||||
55 | } | ||||
56 | if (m_hasVolume != info->has_volume) { | ||||
57 | m_hasVolume = info->has_volume; | ||||
58 | emit hasVolumeChanged(); | ||||
59 | } | ||||
60 | if (m_volumeWritable != info->volume_writable) { | ||||
61 | m_volumeWritable = info->volume_writable; | ||||
62 | emit isVolumeWritableChanged(); | ||||
63 | } | ||||
64 | if (m_clientIndex != info->client) { | ||||
65 | m_clientIndex = info->client; | ||||
66 | emit clientChanged(); | ||||
67 | } | ||||
68 | if (m_virtualStream != (info->client == PA_INVALID_INDEX)) { | ||||
69 | m_virtualStream = info->client == PA_INVALID_INDEX; | ||||
70 | emit virtualStreamChanged(); | ||||
71 | } | ||||
72 | if (m_corked != info->corked) { | ||||
73 | m_corked = info->corked; | ||||
74 | emit corkedChanged(); | ||||
75 | } | ||||
76 | } | ||||
77 | | ||||
78 | QString name() const; | ||||
79 | Client *client() const; | ||||
80 | bool isVirtualStream() const; | ||||
81 | quint32 deviceIndex() const; | ||||
82 | bool isCorked() const; | ||||
83 | | ||||
84 | virtual void setDeviceIndex(quint32 deviceIndex) = 0; | ||||
85 | | ||||
86 | signals: | ||||
87 | void nameChanged(); | ||||
88 | void clientChanged(); | ||||
89 | void virtualStreamChanged(); | ||||
90 | void deviceIndexChanged(); | ||||
91 | void corkedChanged(); | ||||
92 | | ||||
93 | protected: | ||||
94 | Stream(QObject *parent); | ||||
95 | virtual ~Stream(); | ||||
96 | | ||||
97 | quint32 m_deviceIndex; | ||||
98 | | ||||
99 | private: | ||||
100 | QString m_name; | ||||
101 | quint32 m_clientIndex; | ||||
102 | bool m_virtualStream; | ||||
103 | bool m_corked; | ||||
104 | }; | ||||
105 | | ||||
106 | } // QPulseAudio | ||||
107 | | ||||
108 | #endif // STREAM_H |