mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Add a limit to all Win32 message loops #28
This works around Waves plugins causing an infinite message loop. Since we run the loop 30 times per second anyways splitting the loop up into chunks of 20 shouldn't be an issue.
This commit is contained in:
@@ -262,12 +262,14 @@ void GroupBridge::async_handle_events() {
|
||||
MSG msg;
|
||||
|
||||
// Keep the loop responsive by not handling too many events at once
|
||||
// TODO: For some reason the Melda plugins run into a seemingly
|
||||
// infinite timer loop for a little while after opening a
|
||||
// second editor. Without this limit everything will get
|
||||
// blocked indefinitely. How could this be fixed?
|
||||
for (int i = 0;
|
||||
i < 20 && PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE); i++) {
|
||||
//
|
||||
// For some reason the Melda plugins run into a seemingly infinite
|
||||
// timer loop for a little while after opening a second editor.
|
||||
// Without this limit everything will get blocked indefinitely. How
|
||||
// could this be fixed?
|
||||
for (int i = 0; i < max_win32_messages &&
|
||||
PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE);
|
||||
i++) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
@@ -397,22 +397,23 @@ intptr_t Vst2Bridge::dispatch_wrapper(AEffect* plugin,
|
||||
}
|
||||
|
||||
void Vst2Bridge::handle_win32_events() {
|
||||
std::visit(
|
||||
overload{[](Editor& editor) { editor.handle_win32_events(); },
|
||||
[](std::monostate&) {
|
||||
MSG msg;
|
||||
std::visit(overload{[](Editor& editor) { editor.handle_win32_events(); },
|
||||
[](std::monostate&) {
|
||||
MSG msg;
|
||||
|
||||
while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
},
|
||||
[](EditorOpening&) {
|
||||
// Don't handle any events in this
|
||||
// particular case as explained in
|
||||
// `Vst2Bridge::editor`
|
||||
}},
|
||||
editor);
|
||||
for (int i = 0;
|
||||
i < max_win32_messages &&
|
||||
PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE);
|
||||
i++) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
},
|
||||
[](EditorOpening&) {
|
||||
// Don't handle any events in this particular case
|
||||
// as explained in `Vst2Bridge::editor`
|
||||
}},
|
||||
editor);
|
||||
}
|
||||
|
||||
void Vst2Bridge::handle_x11_events() {
|
||||
|
||||
Reference in New Issue
Block a user