Tracktion / tracktion_engine

Tracktion Engine module
Other
1.2k stars 152 forks source link

Added support for asynchronous instantiation of ExternalPlugins. #144

Closed mathieugarcia closed 2 months ago

mathieugarcia commented 1 year ago

Support for asynchronous plugin instantiation in ExternalPlugin. This allow proper hosting of AUv3 plugins on iOS and possibly other platforms and/or plugin formats that require asynchronous instantiation.

What changed:

For more information and discussion about this pull request see https://github.com/Tracktion/tracktion_engine/issues/105

drowaudio commented 1 year ago

FYI here's that Selectable helper class I mentioned: https://github.com/Tracktion/tracktion_engine/commit/c9b328c89f807dfa356778442a98bd6d8ce354c0

github-actions[bot] commented 1 year ago

Unit Test Results

       3 files  ±0         3 suites  ±0   0s :stopwatch: ±0s    158 tests +1     158 :heavy_check_mark: +1  0 :zzz: ±0  0 :x: ±0  6 153 runs  +3  6 153 :heavy_check_mark: +3  0 :zzz: ±0  0 :x: ±0 

Results for commit c9b328c8. ± Comparison against base commit c679bc74.

github-actions[bot] commented 1 year ago

Performance Test Results

0 files  ±0  0 suites  ±0   0s :stopwatch: ±0s 0 tests ±0  0 :heavy_check_mark: ±0  0 :zzz: ±0  0 :x: ±0 

Results for commit c9b328c8. ± Comparison against base commit c679bc74.

mathieugarcia commented 1 year ago

Unfortunatelly calling edit.restartPlayback() instead of baseClassInitialise() and initialise() resulted in various asserts being triggered:

In ExternalPlugin.cpp :

jassert (isInstancePrepared); 

In AudioUnitPluginFormat.mm :

// If these are hit, we might allocate in the process block!
jassert (buffer.getNumChannels() <= preparedChannels);
jassert (buffer.getNumSamples()  <= preparedSamples);
mathieugarcia commented 1 year ago

Any update on this ? Thank you !

drowaudio commented 1 year ago

Sorry, it's been a while since I looked at this and have forgotten most of the details. Plugin hosting with all the external formats is precarious at best which is why I'm hesitant to make changes without fully understanding all the ramifications.

I think the main outstanding issue was that you had to call:

    safeThis->baseClassInitialise (info);
    safeThis->initialise (info);

I couldn't understand why the audio graph isn't rebuilt automatically and then the PluginNode handle calling baseClassInitialise? Any update on that front?