Add a function for temporarily blocking event loop

This can be used to prevent the Win32 message loop from running while
there are plugins in some partially initialized state.
This commit is contained in:
Robbert van der Helm
2021-01-27 18:46:36 +01:00
parent 04d0ff0949
commit 72e29d044a
5 changed files with 89 additions and 9 deletions
+17 -3
View File
@@ -285,6 +285,10 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context,
});
}
bool Vst2Bridge::inhibits_event_loop() {
return !is_initialized;
}
void Vst2Bridge::run() {
sockets.host_vst_dispatch.receive_events(
std::nullopt, [&](Event& event, bool /*on_main_thread*/) {
@@ -352,9 +356,19 @@ void Vst2Bridge::run() {
if (unsafe_opcodes.contains(opcode)) {
return main_context
.run_in_context<intptr_t>([&]() {
return dispatch_wrapper(plugin, opcode,
index, value, data,
option);
const intptr_t result =
dispatch_wrapper(plugin, opcode, index,
value, data, option);
// The Win32 message loop will not be run up
// to this point to prevent plugins with
// partially initialized states from
// misbehaving
if (opcode == effOpen) {
is_initialized = true;
}
return result;
})
.get();
} else {