From c4b1c4b7966f0e0a8ef2d9bd9573211575b41fa3 Mon Sep 17 00:00:00 2001 From: Phireh Date: Mon, 14 Aug 2023 22:18:24 +0200 Subject: [PATCH] Correctly update channel sliders --- src/cont/contclasses.cpp | 3 ++- src/qt/qtclasses.cpp | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/cont/contclasses.cpp b/src/cont/contclasses.cpp index 36b913d..3727fd4 100644 --- a/src/cont/contclasses.cpp +++ b/src/cont/contclasses.cpp @@ -128,7 +128,8 @@ void OverseerHandler::updateChannelVolumeCallback(uint64_t idx, uint32_t channel // convert channel to bitmask int i = 0; - while (i++); + while (i < channel) + i++; uint32_t mask = (1 << i); updateFrontVolumeCallback(idx, mask, newVal); diff --git a/src/qt/qtclasses.cpp b/src/qt/qtclasses.cpp index 24287e9..bebddf2 100644 --- a/src/qt/qtclasses.cpp +++ b/src/qt/qtclasses.cpp @@ -108,23 +108,24 @@ void EndpointWidget::updateMainVolume(float newValue){ void EndpointWidget::updateChannelVolume(uint32_t channel, float newValue){ this->blockSignals(true); - if (channel == (uint32_t)AudioChannel::CHANNEL_MAIN) { + if (channel == (uint32_t)AudioChannel::CHANNEL_MAIN) updateMainVolume(newValue); - } else { - int newVal = newValue * 100; - log_debugcpp("chanel: " << channel << " volcallback int: " << newVal); - //TODO: Above - //this->channelSliders.at(channel)->blockSignals(true); + + int newVal = newValue * 100; + log_debugcpp("chanel: " << channel << " volcallback int: " << newVal); - for (size_t i = 0; i < sizeof(uint32_t) * 8; ++i) { - if ((channel << i & 1) && this->channelSliders.at(channel)->value() != newVal) { - this->channelSliders.at(channel)->setValue(newVal); - this->channelLabels.at(channel)->setText(QString::number((int)(newValue * 100))); - } + for (size_t i = 0; i < sizeof(uint32_t) * 8 && i < channelSliders.size(); ++i) { + if (((channel >> i) & 1) && this->channelSliders.at(i)->value() != newVal) { + this->channelSliders.at(i)->blockSignals(true); + + this->channelSliders.at(i)->setValue(newVal); + this->channelLabels.at(i)->setText(QString::number((int)(newValue * 100))); + + this->channelSliders.at(i)->blockSignals(false); } } + this->blockSignals(false); - //this->channelSliders.at(channel)->blockSignals(false); } void EndpointWidget::toggleFrontEvents(bool active){