| 305 | } |
| 306 | |
| 307 | bool VSTWrapper::Load() |
| 308 | { |
| 309 | vstPluginMain pluginMain; |
| 310 | bool success = false; |
| 311 | |
| 312 | long effectID = 0; |
| 313 | wxString realPath = mPath.BeforeFirst(wxT(';')); |
| 314 | mPath.AfterFirst(wxT(';')).ToLong(&effectID); |
| 315 | mCurrentEffectID = (intptr_t) effectID; |
| 316 | |
| 317 | mModule = NULL; |
| 318 | mAEffect = NULL; |
| 319 | |
| 320 | #if defined(__WXMAC__) |
| 321 | // Start clean |
| 322 | mBundleRef.reset(); |
| 323 | |
| 324 | mResource = ResourceHandle{}; |
| 325 | |
| 326 | // Convert the path to a CFSTring |
| 327 | wxCFStringRef path(realPath); |
| 328 | |
| 329 | // Create the bundle using the URL |
| 330 | BundleHandle bundleRef{ CFBundleCreate(kCFAllocatorDefault, |
| 331 | // Convert the path to a URL |
| 332 | CF_ptr<CFURLRef>{ |
| 333 | CFURLCreateWithFileSystemPath(kCFAllocatorDefault, |
| 334 | path, kCFURLPOSIXPathStyle, true) |
| 335 | }.get() |
| 336 | )}; |
| 337 | |
| 338 | // Bail if the bundle wasn't created |
| 339 | if (!bundleRef) |
| 340 | return false; |
| 341 | |
| 342 | |
| 343 | // Convert back to path |
| 344 | UInt8 exePath[PLATFORM_MAX_PATH]; |
| 345 | Boolean good = CFURLGetFileSystemRepresentation( |
| 346 | // Retrieve a reference to the executable |
| 347 | CF_ptr<CFURLRef>{ CFBundleCopyExecutableURL(bundleRef.get()) }.get(), |
| 348 | true, exePath, sizeof(exePath) |
| 349 | ); |
| 350 | |
| 351 | // Bail if we couldn't resolve the executable path |
| 352 | if (good == FALSE) |
| 353 | return false; |
| 354 | |
| 355 | // Attempt to open it |
| 356 | mModule.reset((char*)dlopen((char *) exePath, RTLD_NOW | RTLD_LOCAL)); |
| 357 | if (!mModule) |
| 358 | return false; |
| 359 | |
| 360 | // Try to locate the NEW plugin entry point |
| 361 | pluginMain = (vstPluginMain) dlsym(mModule.get(), "VSTPluginMain"); |
| 362 | |
| 363 | // If not found, try finding the old entry point |
| 364 | if (pluginMain == NULL) |
no test coverage detected