Revert "Fix crashes when unloading mac VST2 plugins"

This reverts commit b01fe8b0e4.
This commit is contained in:
Robin Gareus 2021-06-30 01:05:09 +02:00
parent 72242353f3
commit fff2d2c5ad
2 changed files with 15 additions and 20 deletions

View file

@ -25,10 +25,6 @@
#include "ardour/libardour_visibility.h"
#include "ardour/vestige/vestige.h"
#ifdef MACVST_SUPPORT
#include <Carbon/Carbon.h>
#endif
struct LIBARDOUR_API _VSTKey
{
/** virtual-key code, or 0 if this _VSTFXKey is a `character' key */
@ -66,17 +62,16 @@ typedef AEffect * (* main_entry_t) (audioMasterCallback);
struct LIBARDOUR_API _VSTHandle
{
#ifdef MACVST_SUPPORT
CFBundleRef bundleRef;
CFBundleRefNum res_file_id;
#else
void* dll;
#endif
void* dll;
char* name;
char* path;
main_entry_t main_entry;
int plugincnt;
#ifdef MACVST_SUPPORT
int32_t res_file_id;
#endif
};
typedef struct _VSTHandle VSTHandle;

View file

@ -97,33 +97,33 @@ mac_vst_load (const char *path)
fhandle = mac_vst_handle_new ();
fhandle->dll = NULL;
fhandle->bundleRef = 0;
CFURLRef url;
if (!(url = CFURLCreateFromFileSystemRepresentation (0, (const UInt8*)path, (CFIndex) strlen (path), true))) {
return 0;
}
fhandle->bundleRef = CFBundleCreate (kCFAllocatorDefault, url);
CFBundleRef bundleRef = CFBundleCreate (kCFAllocatorDefault, url);
CFRelease (url);
if (fhandle->bundleRef == 0) {
if (bundleRef == 0) {
return 0;
}
if (!CFBundleLoadExecutable (fhandle->bundleRef)) {
CFRelease (fhandle->bundleRef);
if (!CFBundleLoadExecutable (bundleRef)) {
CFRelease (bundleRef);
return 0;
}
fhandle->name = strdup (path);
fhandle->dll = (void*) &bundleRef;
fhandle->main_entry = (main_entry_t)
CFBundleGetFunctionPointerForName (fhandle->bundleRef, CFSTR("main_macho"));
CFBundleGetFunctionPointerForName (bundleRef, CFSTR("main_macho"));
if (!fhandle->main_entry) {
fhandle->main_entry = (main_entry_t)
CFBundleGetFunctionPointerForName (fhandle->bundleRef, CFSTR("VSTPluginMain"));
CFBundleGetFunctionPointerForName (bundleRef, CFSTR("VSTPluginMain"));
}
if (fhandle->main_entry == 0) {
@ -131,7 +131,7 @@ mac_vst_load (const char *path)
return 0;
}
fhandle->res_file_id = CFBundleOpenBundleResourceMap (fhandle->bundleRef);
fhandle->res_file_id = CFBundleOpenBundleResourceMap (bundleRef);
/*return the handle of the plugin*/
return fhandle;
@ -152,7 +152,7 @@ mac_vst_unload (VSTHandle* fhandle)
/*Valid plugin loaded?*/
if (fhandle->bundleRef)
if (fhandle->dll)
{
CFBundleRef* bundleRefPtr = (CFBundleRef*) fhandle->dll;
CFBundleCloseBundleResourceMap (*bundleRefPtr, (CFBundleRefNum)fhandle->res_file_id);