Skip to content

Commit

Permalink
AudioUnitManifest: Instantiate audio units out-of-process
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Nov 15, 2024
1 parent 5d20ec3 commit 7e01cce
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/effects/backends/audiounit/audiounitmanifest.mm
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#import <AudioToolbox/AudioToolbox.h>
#include "effects/backends/effectmanifestparameter.h"

#include <QElapsedTimer>
#include <QThread>
#include <memory>

#include "effects/backends/audiounit/audiounitmanager.h"
Expand All @@ -18,9 +20,25 @@
setDescription(QString::fromNSString([component typeName]));
setAuthor(QString::fromNSString([component manufacturerName]));

// Try instantiating the unit in-process to fetch its properties quickly
// Instantiate audio unit (out-of-process) to load parameters
AudioUnitManager manager{component};

const int TIMEOUT_MS = 5000;

QElapsedTimer timer;
timer.start();

while (manager.getAudioUnit() == nil) {
if (timer.elapsed() > TIMEOUT_MS) {
qWarning() << name() << "took more than" << TIMEOUT_MS
<< "ms to initialize, skipping manifest initialization "
"for this effect. This means this effect will not "
"display any parameters and likely not be useful!";
return;
}
QThread::msleep(10);
}

AudioUnitManager manager{component, AudioUnitInstantiationType::Sync};
AudioUnit audioUnit = manager.getAudioUnit();

if (audioUnit) {
Expand Down

0 comments on commit 7e01cce

Please sign in to comment.