| 57 | } |
| 58 | |
| 59 | int EffectEngine::runEffectScript(const QString& name, int priority, int timeout, const QString& origin) |
| 60 | { |
| 61 | // find the effect's definition |
| 62 | std::string findName = name.toStdString(); |
| 63 | std::list<EffectDefinition>::iterator it = std::find_if( |
| 64 | _availableEffects.begin(), |
| 65 | _availableEffects.end(), |
| 66 | [&findName](const EffectDefinition& s) { |
| 67 | return s.name == findName; |
| 68 | }); |
| 69 | |
| 70 | if (it == _availableEffects.end()) |
| 71 | { |
| 72 | Debug(_log, "Could not find the effect named: %s", QSTRING_CSTR(name)); |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | // clear current effect on the channel |
| 77 | channelCleared(priority); |
| 78 | |
| 79 | // create the effect |
| 80 | auto effect = std::unique_ptr<Effect, void(*)(Effect*)>( |
| 81 | new Effect(_hyperInstance, _hyperInstance->getCurrentPriority(), priority, timeout, *it), |
| 82 | [](Effect* oldEffect) { |
| 83 | oldEffect->requestInterruption(); |
| 84 | hyperhdr::THREAD_REMOVER(oldEffect->getDescription(), oldEffect->thread(), oldEffect); |
| 85 | } |
| 86 | ); |
| 87 | connect(effect.get(), &Effect::SignalSetLeds, this, &EffectEngine::handlerSetLeds); |
| 88 | connect(effect.get(), &Effect::SignalSetImage, _hyperInstance, &HyperHdrInstance::setInputImage); |
| 89 | connect(effect.get(), &Effect::SignalEffectFinished, this, &EffectEngine::handlerEffectFinished); |
| 90 | |
| 91 | // start the effect |
| 92 | Debug(_log, "Start the effect: name [%s]", QSTRING_CSTR(name)); |
| 93 | _hyperInstance->registerInput(priority, hyperhdr::COMP_EFFECT, origin, name, (*it).smoothingConfig); |
| 94 | |
| 95 | // start the effect |
| 96 | QThread* newThread = new QThread(); |
| 97 | effect->moveToThread(newThread); |
| 98 | newThread->start(); |
| 99 | QUEUE_CALL_0(effect.get(), start); |
| 100 | |
| 101 | // enlist & move control |
| 102 | _activeEffects.push_back(std::move(effect)); |
| 103 | |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | void EffectEngine::handlerEffectFinished(int priority, QString name, bool forced) |
| 108 | { |
nothing calls this directly
no test coverage detected