From 966cf91a230450ffcd6a80c015b5386356ee04f9 Mon Sep 17 00:00:00 2001 From: Hane Date: Tue, 15 Aug 2023 18:06:55 +0200 Subject: [PATCH] more code cleanup; changed define for channel enum --- src/back/backlasses.cpp | 4 ++-- src/cont/contclasses.cpp | 7 ++++--- src/qt/qtclasses.cpp | 33 ++++++++++++++------------------- src/qt/qtclasses.h | 4 ++-- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/back/backlasses.cpp b/src/back/backlasses.cpp index ef827dd..5269c29 100644 --- a/src/back/backlasses.cpp +++ b/src/back/backlasses.cpp @@ -141,10 +141,10 @@ bool Endpoint::getMute(){ void Endpoint::setVolume(NGuid* guid, int channel, float volume) { GUID tempMsGuid = NGuidToGUID(guid); - if (channel == ENDPOINT_MASTER_VOLUME) { + if (channel == AudioChannel::CHANNEL_MAIN) { if(FAILED(endpointVolume->SetMasterVolumeLevelScalar(volume, &tempMsGuid))) { log_debugcpp("MASTER VOLUME FAILED"); }; } else { - log_debugcpp("Channel being updated: " << channel); + log_debugcpp("Windows: Channel being updated: " << channel); if(FAILED(endpointVolume->SetChannelVolumeLevelScalar(channel, volume, &tempMsGuid))) { log_debugcpp("CHANNEL "<< channel <<" VOLUME FAILED"); }; } } diff --git a/src/cont/contclasses.cpp b/src/cont/contclasses.cpp index 679f921..381550b 100644 --- a/src/cont/contclasses.cpp +++ b/src/cont/contclasses.cpp @@ -119,19 +119,20 @@ void OverseerHandler::updateMuteCallback(uint64_t idx, bool muted){ */ void OverseerHandler::updateVolumeCallback(uint64_t idx, uint32_t channel, float newVal){ - if (channel == AudioChannel::CHANNEL_MAIN) { + if (channel == (uint32_t)AudioChannel::CHANNEL_MAIN) { log_debugcpp("mainvolcallback float: " << newVal); updateFrontVolumeCallback(idx, AudioChannel::CHANNEL_MAIN, newVal); return; } - log_debugcpp("channel: " << channel << " volcallback float: " << newVal); - + // convert channel to bitmask uint32_t i = 0; while (i < channel) i++; uint32_t mask = (1 << i); + + log_debugcpp("Back->Cont Channel: " << mask << " volcallback float: " << newVal); updateFrontVolumeCallback(idx, mask, newVal); } diff --git a/src/qt/qtclasses.cpp b/src/qt/qtclasses.cpp index 9a446ee..155cd90 100644 --- a/src/qt/qtclasses.cpp +++ b/src/qt/qtclasses.cpp @@ -76,6 +76,7 @@ void EndpointWidget::updateMute(bool muted){ //TIP: Blocksignals here to diagnose slider visuals locking when playing DJ with external volume bar. Functionality is restored when mute checkbox is clicked. //this->blockSignals(true); //this->muteButton->blockSignals(true); + //this->eph->setMute(osh->getGuid(), muted); this->muteButton->setChecked(muted); this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE); @@ -97,26 +98,20 @@ void EndpointWidget::updateMainVolume(int newValue){ this->eph->setVolume(osh->getGuid(), ENDPOINT_MASTER_VOLUME, newValue); } -void EndpointWidget::updateMainVolume(float newValue){ - //this->blockSignals(true); - int newVal = newValue * 100; - log_debugcpp("mainvolcallback int: " << newVal); - //this->mainSlider->blockSignals(true); - - if(this->mainSlider->value() != newVal) { - this->mainSlider->setValue(newVal); - } - //this->mainSlider->blockSignals(false); - //this->blockSignals(false); -} - -void EndpointWidget::updateChannelVolume(uint32_t channel, float newValue){ +void EndpointWidget::updateVolume(uint32_t channel, float newValue){ //this->blockSignals(true); - if (channel == (uint32_t)AudioChannel::CHANNEL_MAIN) - updateMainVolume(newValue); - int newVal = newValue * 100; - log_debugcpp("chanel: " << channel << " volcallback int: " << newVal); + if (channel == (uint32_t)AudioChannel::CHANNEL_MAIN) { + log_debugcpp("mainvolcallback int: " << newVal); + //this->mainSlider->blockSignals(true); + + if(this->mainSlider->value() != newVal) { + this->mainSlider->setValue(newVal); + } + return; + } + + log_debugcpp("Cont->Front Channel:: " << channel << " volcallback int: " << newVal); for (size_t i = 0; i < sizeof(uint32_t) * 8 && i < channelSliders.size(); ++i) { if (((channel >> i) & 1) && this->channelSliders.at(i)->value() != newVal) { @@ -179,7 +174,7 @@ void MainWindow::reloadEndpointWidgets() { osh->setFrontVolumeCallback([this](uint64_t device, uint32_t channel, float value) { if (device < ews.size()) - ews[device]->updateChannelVolume(channel, value); + ews[device]->updateVolume(channel, value); }); osh->setFrontMuteCallback([this](uint64_t device, bool muted) { if (device < ews.size()) diff --git a/src/qt/qtclasses.h b/src/qt/qtclasses.h index 4482d23..c5eee14 100644 --- a/src/qt/qtclasses.h +++ b/src/qt/qtclasses.h @@ -68,8 +68,8 @@ public: std::vector channelLabels; QGridLayout *layout = nullptr; QGridLayout *mainMuteLayout = nullptr; - void updateMainVolume(float newValue); - void updateChannelVolume(uint32_t channel, float newValue); + //void updateMainVolume(float newValue); + void updateVolume(uint32_t channel, float newValue); void updateMute(bool muted); //void toggleFrontEvents(bool active);