diff --git a/include/hyperion/PriorityMuxer.h b/include/hyperion/PriorityMuxer.h index c1feedf5..7e74a5dd 100644 --- a/include/hyperion/PriorityMuxer.h +++ b/include/hyperion/PriorityMuxer.h @@ -212,19 +212,6 @@ signals: /// void visibleComponentChanged(hyperion::Components comp); - /// - /// @brief Emits whenever a priority changes active state - /// @param priority The priority who changed the active state - /// @param state The new state, state true = active else false - /// - void activeStateChanged(quint8 priority, bool state); - - /// - /// @brief Emits whenever the auto selection state has been changed - /// @param state The new state of auto selection; True enabled else false - /// - void autoSelectChanged(bool state); - /// /// @brief Emits whenever something changes which influences the priorities listing /// Emits also in 1s interval when a COLOR or EFFECT is running with a timeout > -1 diff --git a/libsrc/api/JsonCB.cpp b/libsrc/api/JsonCB.cpp index 9c48debb..5863d1cc 100644 --- a/libsrc/api/JsonCB.cpp +++ b/libsrc/api/JsonCB.cpp @@ -72,12 +72,10 @@ bool JsonCB::subscribeFor(const QString& type, bool unsubscribe) if(type == "priorities-update") { - if(unsubscribe){ + if (unsubscribe) disconnect(_prioMuxer,0 ,0 ,0); - } else { + else connect(_prioMuxer, &PriorityMuxer::prioritiesChanged, this, &JsonCB::handlePriorityUpdate, Qt::UniqueConnection); - connect(_prioMuxer, &PriorityMuxer::autoSelectChanged, this, &JsonCB::handlePriorityUpdate, Qt::UniqueConnection); - } } if(type == "imageToLedMapping-update") diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 2b5182f0..4734cac0 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -391,10 +391,8 @@ end: // register color registerInput(priority, hyperion::COMP_COLOR, origin); - // write color to muxer & queuePush + // write color to muxer setInput(priority, newLedColors, timeout_ms); - if (timeout_ms <= 0) - _muxer.queuePush(); } QStringList Hyperion::getAdjustmentIds() const diff --git a/libsrc/hyperion/PriorityMuxer.cpp b/libsrc/hyperion/PriorityMuxer.cpp index 17cfe319..86773200 100644 --- a/libsrc/hyperion/PriorityMuxer.cpp +++ b/libsrc/hyperion/PriorityMuxer.cpp @@ -5,6 +5,7 @@ // qt incl #include #include +#include // Hyperion includes #include @@ -44,7 +45,6 @@ PriorityMuxer::PriorityMuxer(int ledCount, QObject * parent) // forward timeRunner signal to prioritiesChanged signal & threading workaround connect(this, &PriorityMuxer::timeRunner, this, &PriorityMuxer::prioritiesChanged); connect(this, &PriorityMuxer::signalTimeTrigger, this, &PriorityMuxer::timeTrigger); - connect(this, &PriorityMuxer::activeStateChanged, this, &PriorityMuxer::prioritiesChanged); // start muxer timer connect(_updateTimer, &QTimer::timeout, this, &PriorityMuxer::setCurrentTime); @@ -79,7 +79,6 @@ bool PriorityMuxer::setSourceAutoSelectEnabled(bool enable, bool update) if(update) setCurrentTime(); - emit autoSelectChanged(enable); return true; } return false; @@ -142,10 +141,10 @@ hyperion::Components PriorityMuxer::getComponentOfPriority(int priority) const void PriorityMuxer::registerInput(int priority, hyperion::Components component, const QString& origin, const QString& owner, unsigned smooth_cfg) { // detect new registers - bool newInput, reusedInput = false; + bool newInput = false, reusedInput = false; if (!_activeInputs.contains(priority)) newInput = true; - else + else if(_prevVisComp == component || _activeInputs[priority].componentId == component) reusedInput = true; InputInfo& input = _activeInputs[priority]; @@ -159,12 +158,14 @@ void PriorityMuxer::registerInput(int priority, hyperion::Components component, if (newInput) { Debug(_log,"Register new input '%s/%s' with priority %d as inactive", QSTRING_CSTR(origin), hyperion::componentToIdString(component), priority); - if (!_sourceAutoSelectEnabled) // emit 'prioritiesChanged' only on when _sourceAutoSelectEnabled is false + // emit 'prioritiesChanged' only if _sourceAutoSelectEnabled is false + if (!_sourceAutoSelectEnabled) emit prioritiesChanged(); return; } - if (reusedInput) emit prioritiesChanged(); + if (reusedInput) + emit timeRunner(); } bool PriorityMuxer::setInput(int priority, const std::vector& ledColors, int64_t timeout_ms) @@ -201,9 +202,11 @@ bool PriorityMuxer::setInput(int priority, const std::vector& ledColor if(activeChange) { Debug(_log, "Priority %d is now %s", priority, active ? "active" : "inactive"); - emit activeStateChanged(priority, active); + if (_currentPriority < priority) + emit prioritiesChanged(); setCurrentTime(); } + return true; } @@ -241,9 +244,11 @@ bool PriorityMuxer::setInputImage(int priority, const Image& image, in if(activeChange) { Debug(_log, "Priority %d is now %s", priority, active ? "active" : "inactive"); - emit activeStateChanged(priority, active); + if (_currentPriority < priority) + emit prioritiesChanged(); setCurrentTime(); } + return true; } @@ -260,7 +265,9 @@ bool PriorityMuxer::clearInput(uint8_t priority) Debug(_log,"Removed source priority %d",priority); // on clear success update _currentPriority setCurrentTime(); - emit prioritiesChanged(); + // emit 'prioritiesChanged' only if _sourceAutoSelectEnabled is false + if (!_sourceAutoSelectEnabled || _currentPriority < priority) + emit prioritiesChanged(); return true; } return false; @@ -281,9 +288,7 @@ void PriorityMuxer::clearAll(bool forceClearAll) { const InputInfo info = getInputInfo(key); if ((info.componentId == hyperion::COMP_COLOR || info.componentId == hyperion::COMP_EFFECT || info.componentId == hyperion::COMP_IMAGE) && key < PriorityMuxer::LOWEST_PRIORITY-1) - { clearInput(key); - } } } } @@ -331,19 +336,20 @@ void PriorityMuxer::setCurrentTime() } } // apply & emit on change (after apply!) - if (_currentPriority != newPriority) + hyperion::Components comp = getComponentOfPriority(newPriority); + if (_currentPriority != newPriority || comp != _prevVisComp) { _previousPriority = _currentPriority; _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(); } }