MCPcopy Create free account
hub / github.com/awawa-dev/HyperHDR / runEffectScript

Method runEffectScript

sources/effects/EffectEngine.cpp:59–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59int 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
107void EffectEngine::handlerEffectFinished(int priority, QString name, bool forced)
108{

Callers

nothing calls this directly

Calls 7

beginMethod · 0.80
getCurrentPriorityMethod · 0.80
requestInterruptionMethod · 0.80
getDescriptionMethod · 0.80
getMethod · 0.45
registerInputMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected