From a22ba3e19f7e7e8052b38954ebffafc46b2fe871 Mon Sep 17 00:00:00 2001 From: fwcd Date: Fri, 15 Nov 2024 04:33:22 +0100 Subject: [PATCH] AudioUnitEffectProcessor: Fall back to generic AU view if needed --- CMakeLists.txt | 1 + .../audiounit/audiouniteffectprocessor.mm | 33 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94ecb9ce26b7..29261889de64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1603,6 +1603,7 @@ if(APPLE) target_link_libraries(mixxx-lib PRIVATE "-weak_framework AudioToolbox" "-weak_framework AVFAudio" + "-weak_framework CoreAudioKit" ) target_compile_definitions(mixxx-lib PUBLIC __AU_EFFECTS__) endif() diff --git a/src/effects/backends/audiounit/audiouniteffectprocessor.mm b/src/effects/backends/audiounit/audiouniteffectprocessor.mm index 94900c475751..5bf93056659c 100644 --- a/src/effects/backends/audiounit/audiouniteffectprocessor.mm +++ b/src/effects/backends/audiounit/audiouniteffectprocessor.mm @@ -2,8 +2,9 @@ #import #import #import +#import #import -#include +#import #include #include @@ -263,24 +264,28 @@ std::unique_ptr dialog = std::make_unique(); dialog->setWindowTitle(name); - QString error = "Could not load UI of Audio Unit"; - NSView* view = createNativeUI(dialog->size().toCGSize(), error); + // See + // https://lists.qt-project.org/pipermail/interest/2014-January/010655.html + // for why we need this slightly convoluted cast + NSView* dialogView = + (__bridge NSView*)reinterpret_cast(dialog->winId()); - if (view != nil) { - // See - // https://lists.qt-project.org/pipermail/interest/2014-January/010655.html - // for why we need this slightly convoluted cast - NSView* dialogView = - (__bridge NSView*)reinterpret_cast(dialog->winId()); + QString error = "Could not load UI of Audio Unit"; + NSView* audioUnitView = createNativeUI(dialog->size().toCGSize(), error); - [dialogView addSubview:view]; + if (audioUnitView != nil) { + [dialogView addSubview:audioUnitView]; } else { qWarning() << error; - QVBoxLayout* layout = new QVBoxLayout(); - layout->addWidget(new QLabel( - error.isNull() ? "Could not load UI of Audio Unit" : error)); - dialog->setLayout(layout); + // Fall back to a generic UI if possible + AudioUnit _Nullable audioUnit = m_manager.getAudioUnit(); + if (audioUnit != nil) { + AUGenericView* genericView = + [[AUGenericView alloc] initWithAudioUnit:audioUnit]; + genericView.showsExpertParameters = YES; + [dialogView addSubview:genericView]; + } } return dialog;