Changeset View
Changeset View
Standalone View
Standalone View
src/context.h
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
42 | { | 42 | { | ||
43 | Q_OBJECT | 43 | Q_OBJECT | ||
44 | public: | 44 | public: | ||
45 | Context(QObject *parent = nullptr); | 45 | Context(QObject *parent = nullptr); | ||
46 | ~Context(); | 46 | ~Context(); | ||
47 | 47 | | |||
48 | static Context *instance(); | 48 | static Context *instance(); | ||
49 | 49 | | |||
50 | static const qint64 NormalVolume = PA_VOLUME_NORM; | ||||
51 | static const qint64 MinimalVolume = 0; | ||||
52 | static const qint64 MaximalVolume = (PA_VOLUME_NORM / 100.0) * 150; | ||||
53 | | ||||
50 | void ref(); | 54 | void ref(); | ||
51 | void unref(); | 55 | void unref(); | ||
52 | 56 | | |||
53 | bool isValid() { return m_context && m_mainloop; } | 57 | bool isValid() { return m_context && m_mainloop; } | ||
54 | 58 | | |||
55 | const SinkMap &sinks() const { return m_sinks; } | 59 | const SinkMap &sinks() const { return m_sinks; } | ||
56 | const SinkInputMap &sinkInputs() const { return m_sinkInputs; } | 60 | const SinkInputMap &sinkInputs() const { return m_sinkInputs; } | ||
57 | const SourceMap &sources() const { return m_sources; } | 61 | const SourceMap &sources() const { return m_sources; } | ||
Show All 16 Lines | |||||
74 | void setCardProfile(quint32 index, const QString &profile); | 78 | void setCardProfile(quint32 index, const QString &profile); | ||
75 | void setDefaultSink(const QString &name); | 79 | void setDefaultSink(const QString &name); | ||
76 | void setDefaultSource(const QString &name); | 80 | void setDefaultSource(const QString &name); | ||
77 | 81 | | |||
78 | template <typename PAFunction> | 82 | template <typename PAFunction> | ||
79 | void setGenericVolume(quint32 index, int channel, qint64 newVolume, | 83 | void setGenericVolume(quint32 index, int channel, qint64 newVolume, | ||
80 | pa_cvolume cVolume, PAFunction pa_set_volume) | 84 | pa_cvolume cVolume, PAFunction pa_set_volume) | ||
81 | { | 85 | { | ||
82 | // TODO: overdrive | 86 | newVolume = qBound<qint64>(0, newVolume, PA_VOLUME_MAX); | ||
83 | newVolume = qBound<qint64>(0, newVolume, 65536); | | |||
84 | pa_cvolume newCVolume = cVolume; | 87 | pa_cvolume newCVolume = cVolume; | ||
85 | if (channel == -1) { // -1 all channels | 88 | if (channel == -1) { // -1 all channels | ||
86 | for (int i = 0; i < newCVolume.channels; ++i) { | 89 | for (int i = 0; i < newCVolume.channels; ++i) { | ||
87 | newCVolume.values[i] = newVolume; | 90 | newCVolume.values[i] = newVolume; | ||
88 | } | 91 | } | ||
89 | } else { | 92 | } else { | ||
90 | Q_ASSERT(newCVolume.channels > channel); | 93 | Q_ASSERT(newCVolume.channels > channel); | ||
91 | newCVolume.values[channel] = newVolume; | 94 | newCVolume.values[channel] = newVolume; | ||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |