Add master volume control slider
[apps/homescreen.git] / homescreen / src / paclient.h
1 /*
2  * Copyright (C) 2016,2017 Konsulko Group
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <pulse/pulseaudio.h>
18
19 #include <QtCore/QHash>
20 #include <QtCore/QObject>
21
22 class PaClient : public QObject
23 {
24         Q_OBJECT
25         public:
26                 PaClient();
27                 ~PaClient();
28
29                 void init();
30                 void close();
31
32                 inline pa_context *context() const
33                 {
34                         return m_ctx;
35                 }
36
37                 inline void lock()
38                 {
39                         pa_threaded_mainloop_lock(m_ml);
40                 }
41
42                 inline void unlock()
43                 {
44                         pa_threaded_mainloop_unlock(m_ml);
45                 }
46
47                 pa_sink_info * getDefaultSinkInfo(void);
48                 void setDefaultSinkInfo(const pa_sink_info *i);
49                 void setMasterVolume(const pa_cvolume *);
50
51         public slots:
52                 void incDecVolume(const int volume_delta);
53
54         signals:
55                 void volumeExternallyChanged(int volume);
56
57         private:
58                 bool m_init;
59                 pa_threaded_mainloop *m_ml;
60                 pa_mainloop_api *m_mlapi;
61                 pa_context *m_ctx;
62                 pa_cvolume m_master_cvolume;
63                 pa_sink_info m_default_sink_info;
64 };