mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-16 13:40:05 +02:00
Always initialize Microsoft COM unconditionally
This commit is contained in:
@@ -15,6 +15,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed _Shattered Glass Audio Code Red (Free)_ crashing when opening the plugin
|
||||||
|
editor because the plugin doesn't initialize Microsoft COM before using it. We
|
||||||
|
now always initialize Microsoft COM unconditionally, instead of only doing it
|
||||||
|
when a plugin fails to initialize the first time without it.
|
||||||
- Fixed mouse clicks in VST2 editors in **Tracktion Waveform** being offset
|
- Fixed mouse clicks in VST2 editors in **Tracktion Waveform** being offset
|
||||||
vertically because of the way Waveform embeds VST2 editors.
|
vertically because of the way Waveform embeds VST2 editors.
|
||||||
|
|
||||||
|
|||||||
@@ -137,21 +137,6 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context,
|
|||||||
logger(generic_logger),
|
logger(generic_logger),
|
||||||
plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary),
|
plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary),
|
||||||
sockets(main_context.context, endpoint_base_dir, false) {
|
sockets(main_context.context, endpoint_base_dir, false) {
|
||||||
// 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) {
|
|
||||||
std::cerr << "WARNING: '" << plugin_dll_path << "'" << std::endl;
|
|
||||||
std::cerr << " could only load after we manually"
|
|
||||||
<< std::endl;
|
|
||||||
std::cerr << " initialized the COM library." << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin_handle) {
|
if (!plugin_handle) {
|
||||||
throw std::runtime_error("Could not load the Windows .dll file at '" +
|
throw std::runtime_error("Could not load the Windows .dll file at '" +
|
||||||
plugin_dll_path + "'");
|
plugin_dll_path + "'");
|
||||||
|
|||||||
@@ -87,22 +87,6 @@ Vst3Bridge::Vst3Bridge(MainContext& main_context,
|
|||||||
sockets(main_context.context, endpoint_base_dir, false) {
|
sockets(main_context.context, endpoint_base_dir, false) {
|
||||||
std::string error;
|
std::string error;
|
||||||
module = VST3::Hosting::Win32Module::create(plugin_dll_path, 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) {
|
|
||||||
std::cerr << "WARNING: '" << plugin_dll_path << "'" << std::endl;
|
|
||||||
std::cerr << " could only load after we manually"
|
|
||||||
<< std::endl;
|
|
||||||
std::cerr << " initialized the COM library." << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!module) {
|
if (!module) {
|
||||||
throw std::runtime_error("Could not load the VST3 module for '" +
|
throw std::runtime_error("Could not load the VST3 module for '" +
|
||||||
plugin_dll_path + "': " + error);
|
plugin_dll_path + "': " + error);
|
||||||
@@ -1187,7 +1171,8 @@ size_t Vst3Bridge::register_object_instance(
|
|||||||
// thread names from different plugins will clash. Not a huge
|
// thread names from different plugins will clash. Not a huge
|
||||||
// deal probably, since duplicate thread names are still more
|
// deal probably, since duplicate thread names are still more
|
||||||
// useful than no thread names.
|
// useful than no thread names.
|
||||||
const std::string thread_name = "audio-" + std::to_string(instance_id);
|
const std::string thread_name =
|
||||||
|
"audio-" + std::to_string(instance_id);
|
||||||
pthread_setname_np(pthread_self(), thread_name.c_str());
|
pthread_setname_np(pthread_self(), thread_name.c_str());
|
||||||
|
|
||||||
sockets.add_audio_processor_and_listen(
|
sockets.add_audio_processor_and_listen(
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ __cdecl
|
|||||||
#endif
|
#endif
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
|
// NOTE: Some plugins use Microsoft COM, but don't initialize it first and
|
||||||
|
// just pray the host does it for them. Examples of this are
|
||||||
|
// PSPaudioware's InfiniStrip and Shattered Glass Audio Code Red Free.
|
||||||
|
OleInitialize(nullptr);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
GroupBridge bridge(group_socket_endpoint_path);
|
GroupBridge bridge(group_socket_endpoint_path);
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,11 @@ __cdecl
|
|||||||
std::cerr << "Preparing to load " << plugin_type_to_string(plugin_type)
|
std::cerr << "Preparing to load " << plugin_type_to_string(plugin_type)
|
||||||
<< " plugin at '" << plugin_location << "'" << std::endl;
|
<< " plugin at '" << plugin_location << "'" << std::endl;
|
||||||
|
|
||||||
|
// NOTE: Some plugins use Microsoft COM, but don't initialize it first and
|
||||||
|
// just pray the host does it for them. Examples of this are
|
||||||
|
// PSPaudioware's InfiniStrip and Shattered Glass Audio Code Red Free.
|
||||||
|
OleInitialize(nullptr);
|
||||||
|
|
||||||
// As explained in `Vst2Bridge`, the plugin has to be initialized in the
|
// As explained in `Vst2Bridge`, the plugin has to be initialized in the
|
||||||
// same thread as the one that calls `io_context.run()`. This setup is
|
// same thread as the one that calls `io_context.run()`. This setup is
|
||||||
// slightly more convoluted than it has to be, but doing it this way we
|
// slightly more convoluted than it has to be, but doing it this way we
|
||||||
|
|||||||
Reference in New Issue
Block a user