From 70f93c71712dbca445e91c581b54b2691091377a Mon Sep 17 00:00:00 2001 From: brindosch Date: Sat, 15 Feb 2020 22:47:27 +0100 Subject: [PATCH] fix: Backlight/BBDetector during effects (#682) --- include/hyperion/Hyperion.h | 10 +++------- include/hyperion/PriorityMuxer.h | 15 +++++++++++++++ libsrc/hyperion/Hyperion.cpp | 19 ++++++------------- libsrc/hyperion/PriorityMuxer.cpp | 21 ++++++++++++++------- 4 files changed, 38 insertions(+), 27 deletions(-) diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index d83bcd54..f4f25166 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -458,11 +458,10 @@ public slots: private slots: /// - /// @brief Apply ComponentRegister emits for COMP_ALL. Enables/Disables core timers - /// @param comp The component - /// @param state The new state of the component + /// @brief Handle whenever the visible component changed + /// @param comp The new component /// - void updatedComponentState(const hyperion::Components comp, const bool state); + void handleVisibleComponentChanged(const hyperion::Components& comp); /// /// @brief Apply settings updates for LEDS and COLOR @@ -529,9 +528,6 @@ private: QSize _ledGridSize; - /// Store the previous compID for smarter update() - hyperion::Components _prevCompId; - /// Background effect instance, kept active to react on setting changes BGEffectHandler* _BGEffectHandler; /// Capture control for Daemon native capture diff --git a/include/hyperion/PriorityMuxer.h b/include/hyperion/PriorityMuxer.h index 1ecadd2d..63ee0af7 100644 --- a/include/hyperion/PriorityMuxer.h +++ b/include/hyperion/PriorityMuxer.h @@ -206,6 +206,12 @@ signals: /// void visiblePriorityChanged(const quint8& priority); + /// + /// @brief Emits whenever the current visible component changed + /// @param comp The new component + /// + void visibleComponentChanged(const hyperion::Components& comp); + /// /// @brief Emits whenever a priority changes active state /// @param priority The priority who changed the active state @@ -243,6 +249,12 @@ private slots: void setCurrentTime(void); private: + /// + /// @brief Get the component of the given priority + /// @return The component + /// + hyperion::Components getComponentOfPriority(const int& priority); + /// Logger instance Logger* _log; @@ -252,6 +264,9 @@ private: /// The manual select priority set with setPriority int _manualSelectedPriority; + // The last visible component + hyperion::Components _prevVisComp = hyperion::COMP_INVALID; + /// The mapping from priority channel to led-information QMap _activeInputs; diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index adb48414..1997a98e 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -54,7 +54,6 @@ Hyperion::Hyperion(const quint8& instance) , _log(Logger::getInstance("HYPERION")) , _hwLedCount() , _ledGridSize(hyperion::getLedLayoutGridSize(getSetting(settings::LEDS).array())) - , _prevCompId(hyperion::COMP_INVALID) , _ledBuffer(_ledString.leds().size(), ColorRgb::BLACK) { @@ -89,9 +88,10 @@ void Hyperion::start() // connect Hyperion::update with Muxer visible priority changes as muxer updates independent connect(&_muxer, &PriorityMuxer::visiblePriorityChanged, this, &Hyperion::update); + connect(&_muxer, &PriorityMuxer::visibleComponentChanged, this, &Hyperion::handleVisibleComponentChanged); // listens for ComponentRegister changes of COMP_ALL to perform core enable/disable actions - connect(&_componentRegister, &ComponentRegister::updatedComponentState, this, &Hyperion::updatedComponentState); + // connect(&_componentRegister, &ComponentRegister::updatedComponentState, this, &Hyperion::updatedComponentState); // listen for settings updates of this instance (LEDS & COLOR) connect(_settingsManager, &SettingsManager::settingsChanged, this, &Hyperion::handleSettingsUpdate); @@ -518,18 +518,11 @@ const QString & Hyperion::getActiveDeviceType() return _ledDeviceWrapper->getActiveDeviceType(); } -void Hyperion::updatedComponentState(const hyperion::Components comp, const bool state) +void Hyperion::handleVisibleComponentChanged(const hyperion::Components &comp) { - QMutexLocker lock(&_changes); - - // evaluate comp change - if (comp != _prevCompId) - { - _imageProcessor->setBlackbarDetectDisable((_prevCompId == hyperion::COMP_EFFECT)); - _imageProcessor->setHardLedMappingType((_prevCompId == hyperion::COMP_EFFECT) ? 0 : -1); - _prevCompId = comp; - _raw2ledAdjustment->setBacklightEnabled((_prevCompId != hyperion::COMP_COLOR && _prevCompId != hyperion::COMP_EFFECT)); - } + _imageProcessor->setBlackbarDetectDisable((comp == hyperion::COMP_EFFECT)); + _imageProcessor->setHardLedMappingType((comp == hyperion::COMP_EFFECT) ? 0 : -1); + _raw2ledAdjustment->setBacklightEnabled((comp != hyperion::COMP_COLOR && comp != hyperion::COMP_EFFECT)); } void Hyperion::update() diff --git a/libsrc/hyperion/PriorityMuxer.cpp b/libsrc/hyperion/PriorityMuxer.cpp index d9a112b4..b04187ac 100644 --- a/libsrc/hyperion/PriorityMuxer.cpp +++ b/libsrc/hyperion/PriorityMuxer.cpp @@ -133,6 +133,11 @@ const PriorityMuxer::InputInfo PriorityMuxer::getInputInfo(const int priority) c return elemIt.value(); } +hyperion::Components PriorityMuxer::getComponentOfPriority(const int &priority) +{ + return _activeInputs[priority].componentId; +} + void PriorityMuxer::registerInput(const int priority, const hyperion::Components& component, const QString& origin, const QString& owner, unsigned smooth_cfg) { // detect new registers @@ -322,16 +327,18 @@ void PriorityMuxer::setCurrentTime(void) } } // apply & emit on change (after apply!) - bool changed = false; - if(_currentPriority != newPriority) - changed = true; - - _currentPriority = newPriority; - - if(changed) + if (_currentPriority != newPriority) { + _currentPriority = newPriority; Debug(_log, "Set visible priority to %d", newPriority); emit visiblePriorityChanged(newPriority); + // check for visible comp change + hyperion::Components comp = getComponentOfPriority(newPriority); + if (comp != _prevVisComp) + { + _prevVisComp = comp; + emit visibleComponentChanged(comp); + } emit prioritiesChanged(); } }