Skip to content

Commit

Permalink
AudioUnitEffectProcessor: Fall back to generic AU view if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Nov 15, 2024
1 parent 58872ec commit a22ba3e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
33 changes: 19 additions & 14 deletions src/effects/backends/audiounit/audiouniteffectprocessor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#import <AppKit/AppKit.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AudioUnit/AUCocoaUIView.h>
#import <CoreAudioKit/CoreAudioKit.h>
#import <CoreAudioTypes/CoreAudioBaseTypes.h>
#include <CoreAudioTypes/CoreAudioTypes.h>
#import <CoreAudioTypes/CoreAudioTypes.h>

#include <QLabel>
#include <QMutex>
Expand Down Expand Up @@ -263,24 +264,28 @@
std::unique_ptr<QDialog> dialog = std::make_unique<QDialog>();
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<void*>(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<void*>(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;
Expand Down

0 comments on commit a22ba3e

Please sign in to comment.