Skip to content

Commit

Permalink
Fix for broken LV2 UIs that write to host on port_event
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Sep 30, 2019
1 parent cff1538 commit 3c52461
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lv2vst.h
Expand Up @@ -107,6 +107,7 @@ class Lv2VstUI : public VstGui
LV2_URID _uri_atom_EventTransfer;

void* _lib_handle;
uint32_t _port_event_recursion;
};

class LV2Vst : public VstPlugin
Expand Down
7 changes: 7 additions & 0 deletions src/lv2vstui.cc
Expand Up @@ -47,6 +47,7 @@ Lv2VstUI::Lv2VstUI (LV2Vst* effect)
, _idle_iface (0)
, _atombuf (0)
, _lib_handle (0)
, _port_event_recursion (UINT32_MAX)
{
RtkLv2Description const* desc = _lv2vst->desc ();

Expand Down Expand Up @@ -172,7 +173,9 @@ void Lv2VstUI::idle ()
while (_lv2vst->ctrl_to_ui.read_space () >= 1) {
LV2Vst::ParamVal pv;
_lv2vst->ctrl_to_ui.read (&pv, 1);
_port_event_recursion = pv.p;
plugin_gui->port_event (gui_instance, pv.p, sizeof (float), 0, &pv.v);
_port_event_recursion = UINT32_MAX;
}

const uint32_t portmap_atom_to_ui = _lv2vst->portmap_atom_to_ui ();
Expand All @@ -198,6 +201,10 @@ void Lv2VstUI::idle ()
void
Lv2VstUI::write_to_dsp (uint32_t port_index, uint32_t buffer_size, uint32_t port_protocol, const void* buffer)
{
if (_port_event_recursion == port_index) {
return;
}

if (port_protocol != 0) {
if (_lv2vst->atom_from_ui.write_space () >= buffer_size + sizeof (LV2_Atom)) {
LV2_Atom a = {buffer_size, 0};
Expand Down

0 comments on commit 3c52461

Please sign in to comment.