From f26a2a268968028c8c86d385c23f60323a206643 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 21 Sep 2021 14:11:15 +0200 Subject: [PATCH] Set VST2 SR and block sizes from main thread This apparently fixes New Sonic Arts' Vice plugin freezing while loading. Hopefully this doesn't cause issues with other plugins. Spotted in https://www.kvraudio.com/forum/viewtopic.php?p=8217647#p8217647. --- CHANGELOG.md | 5 +++++ src/wine-host/bridges/vst2.cpp | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a61269e6..75d7b23d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,11 @@ Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed +- Fixed _New Sonic Arts' Vice_ plugin freezing when loading the plugin. This + happened because the plugin tried to spawn new threads and perform drawing + calls when changing the sample rate or block size from the audio thread. We're + now doing these things from the main GUI thread, so please let me know if this + results in loading issues with any other VST2 plugins. - Fixed the drag-and-drop implementation not sending an `XdndStatus` message on the very first tick. This fixes drag-and-drop from _Samplab_ which has a broken drag-and-drop implementation and only starts the operation after the diff --git a/src/wine-host/bridges/vst2.cpp b/src/wine-host/bridges/vst2.cpp index b4fdf23f..b07b554c 100644 --- a/src/wine-host/bridges/vst2.cpp +++ b/src/wine-host/bridges/vst2.cpp @@ -94,10 +94,15 @@ static const std::unordered_set safe_mutually_recursive_requests{ * NOTE: `effSetChunk` and `effGetChunk` should be callable from any thread, but * Algonaut Atlas doesn't restore chunk data unless `effSetChunk` is run * from the GUI thread + * NOTE: `effSetSampleRate` and `effSetBlockSize` really shouldn't be here, but + * New Sonic Arts' Vice plugin spawns a new thread and calls drawing code + * while changing sample rate and block size. We'll need to see if doing + * this on the main thread introduces any regressions. */ static const std::unordered_set unsafe_requests{ - effOpen, effClose, effEditGetRect, effEditOpen, effEditClose, - effEditIdle, effEditTop, effMainsChanged, effGetChunk, effSetChunk}; + effOpen, effClose, effEditGetRect, effEditOpen, + effEditClose, effEditIdle, effEditTop, effMainsChanged, + effGetChunk, effSetChunk, effSetSampleRate, effSetBlockSize}; /** * These opcodes from `unsafe_requests` should be run under realtime scheduling