File: audiodevice.h

package info (click to toggle)
lxqt-panel 2.1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 15,748 kB
  • sloc: cpp: 27,548; xml: 798; makefile: 19
file content (90 lines) | stat: -rw-r--r-- 2,674 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* BEGIN_COMMON_COPYRIGHT_HEADER
 * (c)LGPL2+
 *
 * LXQt - a lightweight, Qt based, desktop toolset
 * https://lxqt.org
 *
 * Copyright: 2012 Razor team
 * Authors:
 *   Johannes Zellner <webmaster@nebulon.de>
 *
 * This program or library is free software; you can redistribute it
 * and/or modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General
 * Public License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * END_COMMON_COPYRIGHT_HEADER */

#ifndef AUDIODEVICE_H
#define AUDIODEVICE_H

#include <QObject>

class AudioEngine;

typedef enum AudioDeviceType {
    Sink = 0,
    Source = 1,
    PulseAudioDeviceTypeLength
} AudioDeviceType;

class AudioDevice : public QObject
{
    Q_OBJECT
    Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged)
    Q_PROPERTY(AudioDeviceType type READ type CONSTANT)

public:
    AudioDevice(AudioDeviceType t, AudioEngine *engine, QObject *parent = nullptr);
    ~AudioDevice();

    // the volume can range from 0 to 100.
    int volume() const { return m_volume; }
    bool mute() const { return m_mute; }
    AudioDeviceType type() const { return m_type; }
    const QString &name() const { return m_name; }
    const QString &description() const { return m_description; }
    uint index() const { return m_index; }

    void setName(const QString &name);
    void setDescription(const QString &description);
    void setIndex(uint index);

    AudioEngine* engine() { return m_engine; }

public slots:
    // the volume can range from 0 to 100.
    void setVolume(int volume);
    void setVolumeNoCommit(int volume);
    void toggleMute();
    void setMute(bool state);
    void setMuteNoCommit(bool state);

signals:
    void volumeChanged(int volume);
    void muteChanged(bool state);
    void nameChanged(const QString &name);
    void descriptionChanged(const QString &description);
    void indexChanged(uint index);

private:
    AudioEngine *m_engine;
    int m_volume; // the volume can range from 0 to 100.
    bool m_mute;
    AudioDeviceType m_type;
    QString m_name;
    uint m_index;
    QString m_description;
};

#endif // AUDIODEVICE_H