Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashing when adding multiple effects #70

Open
macramole opened this issue Jul 23, 2021 · 2 comments
Open

Crashing when adding multiple effects #70

macramole opened this issue Jul 23, 2021 · 2 comments

Comments

@macramole
Copy link
Contributor

Hi, long time since my last message. I hope everything is ok.

I have an array of Patchable called effects where each one is actually an effect (BasiVerb, VAFilter, etc). So it represents a "daisy chain" of effects.

I'm adding and removing effects on the fly and when adding I experiment random crashes. My guess is some method I'm using is not thread safe.

The code is pretty simple:

void AudioEffects::addEffect(EffectUI *newEffect)
{
    effects.push_back(newEffect);

    if ( effects.size() == 1 ) {
        nodeIn0.disconnectOut();
        nodeIn1.disconnectOut();
        nodeOut0.disconnectIn();
        nodeOut1.disconnectIn();

        nodeIn0 >> effects[0]->channelOut(0) >> nodeOut0;
        nodeIn1 >> effects[0]->channelOut(1) >> nodeOut1;
    } else {
        int last = effects.size() - 1;
        effects[ last - 1 ]->disconnectOut();
        nodeOut0.disconnectIn();
        nodeOut1.disconnectIn();

        effects[ last - 1 ]->channelOut(0) >> effects[ last ]->channelIn(0);
        effects[ last - 1 ]->channelOut(1) >> effects[ last ]->channelIn(1);

        effects[ last ]->channelOut(0) >> nodeOut0;
        effects[ last ]->channelOut(1) >> nodeOut1;
    }
}

nodeIn0 and nodeIn1 are just PatchNodes.
AudioEffects is also a Patchable and is part of a larger pipeline that includes two Samplers and multiple Amps

I've tried:

  • unpatching everything and then patching again
  • stopping audio engine and restarting. This prevent crashes but has two issues: a short hiccup and JACK being disconnected and connected causing manually set "virtual cables" to not reconnect.

I hope you can point me in the right direction, thanks

@npisanti
Copy link
Owner

I'm sorry but there is no solution for this, as the patch operator >> is not thread-safe, just a few ofxPDSP methods are (only for metering and control).

Making patching thread-safe would require pretty much a big rewrite of ofxPDSP that is not currently planned.

@macramole
Copy link
Contributor Author

macramole commented Aug 16, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants