Skip to content

Commit

Permalink
VST: Remove 32-bit macOS code
Browse files Browse the repository at this point in the history
I guess this effectively removes support for 32-bit plugins on macOS,
but macOS has been 64-bit for a long time now...

Either way, try to remove some usage of Carbon code that probably hasn't
been used in a long while. It will never get used in the future because
we don't support 32-bit macOS.

Signed-off-by: Avery King <avery98@pm.me>
  • Loading branch information
generic-pers0n committed Sep 14, 2024
1 parent eff70f5 commit 9c936e3
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 171 deletions.
14 changes: 0 additions & 14 deletions src/effects/VST/VSTControlOSX.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#ifndef AUDACITY_VSTCONTROLOSX_H
#define AUDACITY_VSTCONTROLOSX_H

#if !defined(_LP64)
#include <Carbon/Carbon.h>
#endif

#include <wx/osx/core/private.h>
#include <wx/osx/cocoa/private.h>

Expand All @@ -39,19 +35,9 @@ class VSTControl : public VSTControlBase
private:
void CreateCocoa();

#if !defined(_LP64)
void CreateCarbon();
void OnSize(wxSizeEvent & evt);
#endif

private:
NSView *mVSTView;
NSView *mView;

#if !defined(_LP64)
WindowRef mWindowRef;
HIViewRef mHIView;
#endif
};

#endif
152 changes: 0 additions & 152 deletions src/effects/VST/VSTControlOSX.mm
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ + (void)initialize
{
mVSTView = nil;
mView = nil;

#if !defined(_LP64)
mHIView = NULL;
mWindowRef = NULL;
#endif
}

VSTControl::~VSTControl()
Expand All @@ -72,13 +67,6 @@ + (void)initialize

void VSTControl::Close()
{
#if !defined(_LP64)
if (mWindowRef)
{
mLink->callDispatcher(effEditClose, 0, 0, mWindowRef, 0.0);
mWindowRef = 0;
}
#endif
}

bool VSTControl::Create(wxWindow *parent, VSTEffectLink *link)
Expand All @@ -103,18 +91,7 @@ + (void)initialize

CreateCocoa();

#if !defined(_LP64)
if (!mView)
{
CreateCarbon();
}
#endif

if (!mView
#if !defined(_LP64)
&& !mHIView
#endif
)
{
return false;
}
Expand Down Expand Up @@ -169,132 +146,3 @@ + (void)initialize

return;
}

#if !defined(_LP64)

void VSTControl::CreateCarbon()
{
OSStatus result;

Bind(wxEVT_SIZE, &VSTControl::OnSize, this);

VstRect *rect;

// Some effects like to have us get their rect before opening them.
mLink->callDispatcher(effEditGetRect, 0, 0, &rect, 0.0);

// Suggest a dummy size
Rect bounds = { 0, 0, 0, 0 };

// And create the window
result = CreateNewWindow(kOverlayWindowClass,
kWindowStandardHandlerAttribute |
kWindowCompositingAttribute |
kWindowOpaqueForEventsAttribute,
&bounds,
&mWindowRef);
if (result != noErr)
{
return;
}

// Get the root control
ControlRef root = HIViewGetRoot(mWindowRef);

// Find the content view within our window
HIViewRef content;
result = HIViewFindByID(root, kHIViewWindowContentID, &content);
if (result != noErr)
{
DisposeWindow(mWindowRef);
mWindowRef = NULL;

return;
}

// Some effects (iZotope Vinyl) seem to need an existing subview
// of the content view. So just use a "dummy" scrollview.
result = HIScrollViewCreate(kHIScrollViewOptionsVertScroll, &mHIView);

// Don't want to see the scroll bars
HIScrollViewSetScrollBarAutoHide(mHIView, true);

// Add it as a subview of the content view
HIViewAddSubview(content, mHIView);

// Ask the effect to add its GUI
mLink->callDispatcher(effEditOpen, 0, 0, mWindowRef, 0.0);

// Get the subview it created
HIViewRef subview = HIViewGetFirstSubview(content);
if (subview)
{
// The scrollview was used, so leave it.
if (subview == mHIView)
{
subview = HIViewGetFirstSubview(mHIView);
}
// The effect didn't use our scrollview, so dispose of it.
else
{
HIViewRemoveFromSuperview(mHIView);
CFRelease(mHIView);
mHIView = subview;
}
}

// Doesn't seem the effect created a subview. This can
// happen when an effect uses the content view directly.
// As of this time, we will not try to support those and
// just fall back to the textual interface.
if (subview == NULL)
{
mLink->callDispatcher(effEditClose, 0, 0, mWindowRef, 0.0);
DisposeWindow(mWindowRef);
mWindowRef = NULL;
mHIView = NULL;

return;
}

// Get the final bounds of the effect GUI
mLink->callDispatcher(effEditGetRect, 0, 0, &rect, 0.0);

// Set the size of the scrollview to match
HIRect r = {
{ 0, 0 },
{ (CGFloat) rect->right - rect->left, (CGFloat) rect->bottom - rect->top }
};

// One effect, mutagene lipredemuco, doesn't return a valid rect so
// try to detect it and use the created view dimensions instead.
if (rect->left < 0 || rect->top < 0 || rect->right <= 0 || rect->bottom <= 0)
{
HIViewGetFrame(subview, &r);
}

// Make sure container is the same size as the effect GUI
HIViewSetFrame(mHIView, &r);
HIViewPlaceInSuperviewAt(mHIView, 0, 0);

// Establish the minimum size
SetMinSize(wxSize(r.size.width, r.size.height));

NSWindow *parent = [mVSTView window];
NSWindow *host = [[[NSWindow alloc] initWithWindowRef:mWindowRef] autorelease];
[parent addChildWindow:host ordered:NSWindowAbove];

ShowWindow(mWindowRef);
}

void VSTControl::OnSize(wxSizeEvent & evt)
{
evt.Skip();

wxRect rect = GetScreenRect();

MoveWindow(mWindowRef, rect.x, rect.y, true);
SizeWindow(mWindowRef, rect.width, rect.height, true);
}

#endif
5 changes: 0 additions & 5 deletions src/effects/VST/VSTEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@ class wxDynamicLibrary;
#if defined(__WXMAC__)
struct __CFBundle;
typedef struct __CFBundle *CFBundleRef;
#if __LP64__
typedef int CFBundleRefNum;
#else
typedef signed short SInt16;
typedef SInt16 CFBundleRefNum;
#endif
#endif

///////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 9c936e3

Please sign in to comment.