Skip to content

Commit

Permalink
AudioUnitManager: Move nil check into initializeWith
Browse files Browse the repository at this point in the history
This is slightly more defensive against issues during instantiation and
also catches issues during sync instantiation.
  • Loading branch information
fwcd committed Nov 26, 2024
1 parent 9fa2254 commit bff6174
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/effects/backends/audiounit/audiounitmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ class AudioUnitManager {
void instantiateAudioUnitAsync(AVAudioUnitComponent* _Nonnull component, bool inProcess);
void instantiateAudioUnitSync(AVAudioUnitComponent* _Nonnull component);

void initializeWith(AudioUnit _Nonnull audioUnit);
void initializeWith(AudioUnit _Nullable audioUnit);
};
14 changes: 8 additions & 6 deletions src/effects/backends/audiounit/audiounitmanager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@
return;
}

VERIFY_OR_DEBUG_ASSERT(audioUnit != nil) {
qWarning() << "Could not instantiate Audio Unit" << m_name << "...but the error is noErr, what's going on?";
return;
}

initializeWith(audioUnit);
});
// clang-format on
Expand All @@ -116,7 +111,14 @@
initializeWith(audioUnit);
}

void AudioUnitManager::initializeWith(AudioUnit _Nonnull audioUnit) {
void AudioUnitManager::initializeWith(AudioUnit _Nullable audioUnit) {
VERIFY_OR_DEBUG_ASSERT(audioUnit != nil) {
qWarning() << "Instantiated Audio Unit" << m_name
<< " is null, despite not erroring on initialization, "
"something's wrong";
return;
}

VERIFY_OR_DEBUG_ASSERT(!m_isInstantiated.load()) {
qWarning() << "Audio Unit" << m_name
<< "cannot be initialized after already having been "
Expand Down

0 comments on commit bff6174

Please sign in to comment.