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