Changeset View
Changeset View
Standalone View
Standalone View
src/context.h
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | 90 | void setGenericVolume(quint32 index, int channel, qint64 newVolume, | |||
---|---|---|---|---|---|
91 | pa_cvolume cVolume, PAFunction pa_set_volume) | 91 | pa_cvolume cVolume, PAFunction pa_set_volume) | ||
92 | { | 92 | { | ||
93 | if (!m_context) { | 93 | if (!m_context) { | ||
94 | return; | 94 | return; | ||
95 | } | 95 | } | ||
96 | newVolume = qBound<qint64>(0, newVolume, PA_VOLUME_MAX); | 96 | newVolume = qBound<qint64>(0, newVolume, PA_VOLUME_MAX); | ||
97 | pa_cvolume newCVolume = cVolume; | 97 | pa_cvolume newCVolume = cVolume; | ||
98 | if (channel == -1) { // -1 all channels | 98 | if (channel == -1) { // -1 all channels | ||
99 | const qint64 diff = newVolume - pa_cvolume_avg(&cVolume); | ||||
sebas: const | |||||
99 | for (int i = 0; i < newCVolume.channels; ++i) { | 100 | for (int i = 0; i < newCVolume.channels; ++i) { | ||
100 | newCVolume.values[i] = newVolume; | 101 | newCVolume.values[i] = qBound<qint64>(0, newCVolume.values[i] + diff, PA_VOLUME_MAX); | ||
101 | } | 102 | } | ||
102 | } else { | 103 | } else { | ||
103 | Q_ASSERT(newCVolume.channels > channel); | 104 | Q_ASSERT(newCVolume.channels > channel); | ||
104 | newCVolume.values[channel] = newVolume; | 105 | newCVolume.values[channel] = newVolume; | ||
105 | } | 106 | } | ||
106 | if (!PAOperation(pa_set_volume(m_context, index, &newCVolume, nullptr, nullptr))) { | 107 | if (!PAOperation(pa_set_volume(m_context, index, &newCVolume, nullptr, nullptr))) { | ||
107 | qCWarning(PLASMAPA) << "pa_set_volume failed"; | 108 | qCWarning(PLASMAPA) << "pa_set_volume failed"; | ||
108 | return; | 109 | return; | ||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |
const