mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-24 04:47:31 +02:00
Fix potential issue with plugins reporting size
I thought this was a problem for a plugin when it was not, but I can still see this being a source of segfaults.
This commit is contained in:
@@ -18,6 +18,7 @@ Versioning](https://semver.org/spec/v2.0.0.html).
|
|||||||
|
|
||||||
- Added a workaround for the compilation issues under Wine 5.7 and above as
|
- Added a workaround for the compilation issues under Wine 5.7 and above as
|
||||||
caused by [Wine bug 49138](https://bugs.winehq.org/show_bug.cgi?id=49138).
|
caused by [Wine bug 49138](https://bugs.winehq.org/show_bug.cgi?id=49138).
|
||||||
|
- Fixed potential issue with plugins not returning their editor size.
|
||||||
|
|
||||||
## [1.1.2] - 2020-05-09
|
## [1.1.2] - 2020-05-09
|
||||||
|
|
||||||
|
|||||||
+18
-6
@@ -253,10 +253,14 @@ template <typename F>
|
|||||||
auto passthrough_event(AEffect* plugin, F callback) {
|
auto passthrough_event(AEffect* plugin, F callback) {
|
||||||
return [=](Event& event) -> EventResult {
|
return [=](Event& event) -> EventResult {
|
||||||
// This buffer is used to write strings and small objects to. We'll
|
// This buffer is used to write strings and small objects to. We'll
|
||||||
// initialize it with a single null to prevent it from being read as
|
// initialize the beginning with null values to both prevent it from
|
||||||
// some arbitrary C-style string.
|
// being read as some arbitrary C-style string, and to make sure that
|
||||||
|
// `*static_cast<void**>(string_buffer.data)` will be a null pointer if
|
||||||
|
// the plugin is supposed to write a pointer there but doesn't (such as
|
||||||
|
// with `effEditGetRect`/`WantsVstRect`).
|
||||||
std::array<char, max_string_length> string_buffer;
|
std::array<char, max_string_length> string_buffer;
|
||||||
string_buffer[0] = 0;
|
std::fill(string_buffer.begin(), string_buffer.begin() + sizeof(size_t),
|
||||||
|
0);
|
||||||
|
|
||||||
auto read_payload_fn = overload{
|
auto read_payload_fn = overload{
|
||||||
[&](const std::nullptr_t&) -> void* { return nullptr; },
|
[&](const std::nullptr_t&) -> void* { return nullptr; },
|
||||||
@@ -345,9 +349,17 @@ auto passthrough_event(AEffect* plugin, F callback) {
|
|||||||
},
|
},
|
||||||
[&](WantsAEffectUpdate&) -> EventResultPayload { return *plugin; },
|
[&](WantsAEffectUpdate&) -> EventResultPayload { return *plugin; },
|
||||||
[&](WantsVstRect&) -> EventResultPayload {
|
[&](WantsVstRect&) -> EventResultPayload {
|
||||||
// The plugin has written a pointer to a VstRect struct into the
|
// The plugin should have written a pointer to a VstRect struct
|
||||||
// data poitner
|
// into the data pointer. I haven't seen this fail yet, but
|
||||||
return **static_cast<VstRect**>(data);
|
// since some hosts will call `effEditGetRect()` before
|
||||||
|
// `effEditOpen()` I can assume there are plugins that don't
|
||||||
|
// handle this correctly.
|
||||||
|
VstRect* editor_rect = *static_cast<VstRect**>(data);
|
||||||
|
if (editor_rect == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *editor_rect;
|
||||||
},
|
},
|
||||||
[&](WantsVstTimeInfo&) -> EventResultPayload {
|
[&](WantsVstTimeInfo&) -> EventResultPayload {
|
||||||
// Not sure why the VST API has twenty different ways of
|
// Not sure why the VST API has twenty different ways of
|
||||||
|
|||||||
@@ -342,7 +342,12 @@ class DispatchDataConverter : DefaultDataConverter {
|
|||||||
update_aeffect(plugin, updated_plugin);
|
update_aeffect(plugin, updated_plugin);
|
||||||
} break;
|
} break;
|
||||||
case effEditGetRect: {
|
case effEditGetRect: {
|
||||||
// Write back the (hopefully) updated editor dimensions
|
// Either the plugin will have returned (a pointer to) their
|
||||||
|
// editor dimensions, or they will not have written anything.
|
||||||
|
if (std::holds_alternative<std::nullptr_t>(response.payload)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto new_rect = std::get<VstRect>(response.payload);
|
const auto new_rect = std::get<VstRect>(response.payload);
|
||||||
rect = new_rect;
|
rect = new_rect;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user