Skip to content

Commit

Permalink
merge stagger and osc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benkuper committed Jan 7, 2025
2 parents f35dca4 + 0100628 commit b511a51
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
30 changes: 24 additions & 6 deletions Source/Common/Processor/Action/Consequence/ConsequenceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void ConsequenceManager::triggerAll(int multiplexIndex)
}
else
{
if (ConsequenceStaggerLauncher::getInstanceWithoutCreating() != nullptr) ConsequenceStaggerLauncher::getInstance()->addLaunch(this, multiplexIndex);
if (!isClearing && !Engine::mainEngine->isClearing) ConsequenceStaggerLauncher::getInstance()->addLaunch(this, multiplexIndex);
}
}
}
Expand Down Expand Up @@ -186,11 +186,29 @@ void ConsequenceStaggerLauncher::run()

while (!threadShouldExit())
{
MessageManager::callAsync([this] {
stopThread(100);
});
{
GenericScopedLock lock(launches.getLock());

for (auto& l : toRemove) launches.removeObject(l);
toRemove.clear();

for (auto& l : toAdd) launches.add(l);
toAdd.clear();

for (auto& l : launches)
{
processLaunch(l);
if (l->isFinished()) toRemove.addIfNotAlreadyThere(l);
}
}

if (launches.isEmpty()) break;

wait(10);
}


for (auto& l : toAdd) delete l; //clean up unprocessed launches
}

void ConsequenceStaggerLauncher::processLaunch(Launch* l)
Expand Down Expand Up @@ -238,14 +256,14 @@ void ConsequenceStaggerLauncher::addLaunch(ConsequenceManager* csm, int multiple
{
if (Engine::mainEngine->isClearing) return;

launches.add(new Launch(csm, multiplexIndex));
toAdd.add(new Launch(csm, multiplexIndex));
if (!isThreadRunning()) startThread();
else notify();
}

void ConsequenceStaggerLauncher::removeLaunchesFor(ConsequenceManager* manager, int multiplexIndex)
{
GenericScopedLock lock(toRemove.getLock());
GenericScopedLock lock(launches.getLock());
for (auto& l : launches)
{
if (l->manager == manager && (multiplexIndex == -1 || l->multiplexIndex == multiplexIndex)) toRemove.add(l);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ConsequenceStaggerLauncher :
};

OwnedArray<Launch, juce::CriticalSection> launches;
Array<Launch*, juce::CriticalSection> toAdd;
Array<Launch*, juce::CriticalSection> toRemove;

void run() override;
Expand Down
7 changes: 6 additions & 1 deletion Source/Module/modules/osc/OSCModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ void OSCModule::itemAdded(OSCOutput* output)

void OSCModule::itemsAdded(Array<OSCOutput*> outputs)
{
for (auto& o : outputs) o->warningResolveInspectable = this;
for (auto& o : outputs)
{
o->setModule(this);
o->warningResolveInspectable = this;
}
}

void OSCModule::setupSenders()
Expand Down Expand Up @@ -716,6 +720,7 @@ InspectableEditor* OSCOutput::getEditorInternal(bool isRoot, Array<Inspectable*>
void OSCOutput::setupSender()
{
if (isCurrentlyLoadingData) return;
if (oscModule == nullptr) return;

if (isThreadRunning())
{
Expand Down

0 comments on commit b511a51

Please sign in to comment.