Skip to content

Commit

Permalink
Better erase in the lag handler. Oops (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul authored Feb 20, 2025
1 parent 9f4cfc8 commit 6c8e7dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 10 additions & 4 deletions include/sst/basic-blocks/dsp/LagCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,17 @@ template <int N> struct LagCollection

void processAll()
{
for (auto &lag : activeSet)
for (auto it = activeSet.begin(); it != activeSet.end();)
{
lag.process();
if (!lag.lag.isActive())
activeSet.removeFromActive(lag);
it->process();
if (!it->lag.isActive())
{
it = activeSet.erase(it);
}
else
{
++it;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion tests/dsp_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,9 @@ TEST_CASE("Lag Collection", "[dsp]")
lags.setTarget(3, 0.7 + lv * 0.72, &vals[3]);
}
lags.processAll();
if (i < 14)
if (i == 0)
REQUIRE(lags.activeSet.activeCount == 0);
else if (i < 14 && i >= 1)
REQUIRE(lags.activeSet.activeCount == 1);
else
REQUIRE(lags.activeSet.activeCount == 2);
Expand Down

0 comments on commit 6c8e7dd

Please sign in to comment.