From 86bd19cd80102aca2ff28a94cc78ecc20d7b5209 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 25 Apr 2021 21:52:41 +0200 Subject: [PATCH] Fix loading plugins expecting COM to be available The `LoadLibrary()` call for PSPaudioware InfiniStrip would fail because the plugin would always expect COM to be initialized. Now if loading a VST2 or VST3 module fails, we'll initialize COM and try again before throwing an error. This may fix #94. --- CHANGELOG.md | 3 +++ src/wine-host/bridges/vst2.cpp | 10 +++++++++- src/wine-host/bridges/vst3.cpp | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89befce4..53bc77ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed +- _PSPaudioware InifniStrip_ would fail to initialize because the plugin expects + the host to always be using Microsoft COM and it won't initialize it by + itself. InfiniStrip loads as expected now. - Prevent _Native Instruments' FM7_ from crashing when processing MIDI. As a fix, MIDI events are now deallocated later then when they normally would have to be. diff --git a/src/wine-host/bridges/vst2.cpp b/src/wine-host/bridges/vst2.cpp index 6376ee38..eb18770a 100644 --- a/src/wine-host/bridges/vst2.cpp +++ b/src/wine-host/bridges/vst2.cpp @@ -73,7 +73,15 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context, main_context(main_context), plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary), sockets(main_context.context, endpoint_base_dir, false) { - // Got to love these C APIs + // HACK: If the plugin library was unable to load, then there's a tiny + // chance that the plugin expected the COM library to already be + // initialized. I've only seen PSPaudioware's InfiniStrip do this. In + // that case, we'll initialize the COM library for them and try again. + if (!plugin_handle) { + OleInitialize(nullptr); + plugin_handle.reset(LoadLibrary(plugin_dll_path.c_str())); + } + if (!plugin_handle) { throw std::runtime_error("Could not load the Windows .dll file at '" + plugin_dll_path + "'"); diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index 06657152..58dc333d 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -99,6 +99,16 @@ Vst3Bridge::Vst3Bridge(MainContext& main_context, sockets(main_context.context, endpoint_base_dir, false) { std::string error; module = VST3::Hosting::Win32Module::create(plugin_dll_path, error); + + // HACK: If the plugin library was unable to load, then there's a tiny + // chance that the plugin expected the COM library to already be + // initialized. I've only seen PSPaudioware's InfiniStrip do this. In + // that case, we'll initialize the COM library for them and try again. + if (!module) { + OleInitialize(nullptr); + module = VST3::Hosting::Win32Module::create(plugin_dll_path, error); + } + if (!module) { throw std::runtime_error("Could not load the VST3 module for '" + plugin_dll_path + "': " + error);