From f298a8ae2bd892113f0d8f5fc3151b69968e7c5e Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 27 Feb 2022 00:59:50 +0100 Subject: [PATCH] Delay VST2 editor window sizing To work around a buggy plugin. --- CHANGELOG.md | 2 ++ src/wine-host/bridges/vst2.cpp | 23 ++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ade23b74..b182475d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). If you try to process audio from the...audio thread, then they will produce silence and hang afterwards (which a fix in yabridge 3.7.0 previously addressed). +- Worked around a bug in the _RandARP_ VST2 plugin where the plugin would report + that its editor window is 0 by 0 pixels. - Fixed building under (the currently upcoming) Wine 7.2 because of definition changes to Wine's numeric types. diff --git a/src/wine-host/bridges/vst2.cpp b/src/wine-host/bridges/vst2.cpp index 0424c838..bd338cc2 100644 --- a/src/wine-host/bridges/vst2.cpp +++ b/src/wine-host/bridges/vst2.cpp @@ -730,19 +730,24 @@ intptr_t Vst2Bridge::dispatch_wrapper(AEffect* plugin, plugin->dispatcher(plugin, effEditIdle, 0, 0, nullptr, 0.0); }); - // Make sure the wrapper window has the correct initial size. The - // plugin can later change this size using `audioMasterSizeWindow`. - VstRect* editor_rect = nullptr; - plugin->dispatcher(plugin, effEditGetRect, 0, 0, &editor_rect, 0.0); - if (editor_rect) { - editor_->resize(editor_rect->right - editor_rect->left, - editor_rect->bottom - editor_rect->top); - } - const intptr_t result = plugin->dispatcher(plugin, opcode, index, value, editor_instance.get_win32_handle(), option); + // Make sure the wrapper window has the correct initial size. The + // plugin can later change this size using `audioMasterSizeWindow`. + // NOTE: Every single plugin handles `effEditGetRect` before + // `effEditOpen` fine. Except for this one single plugin: + // https://codefn42.com/randarp/index.html + VstRect* editor_rect = nullptr; + plugin->dispatcher(plugin, effEditGetRect, 0, 0, &editor_rect, 0.0); + if (editor_rect) { + std::cerr << editor_rect->right << std::endl; + std::cerr << editor_rect->bottom << std::endl; + editor_->resize(editor_rect->right - editor_rect->left, + editor_rect->bottom - editor_rect->top); + } + // NOTE: There's zero reason why the window couldn't already be // visible from the start, but Waves V13 VST3 plugins think it // would be a splendid idea to randomly dereference null