DPF icon indicating copy to clipboard operation
DPF copied to clipboard

Current state of Plugin::updateStateValue()

Open lucianoiam opened this issue 1 year ago • 2 comments

Given

    void ExamplePluginStates::activate() override
    {
        d_stderr("activate");
        updateStateValue("top-left", "hello");
    }

    ExampleUIStates::ExampleUIStates()
    {
    ...
        d_stderr("open ui");
    }

    void ExampleUIStates::stateChanged(const char* key, const char* value) override
    {
    ...
        d_stderr("state changed %s = %s", key, value);
    }

Loading the plugins prints the following:

VST

activate
updateStateValueCallback 0x0
open ui
open ui
open ui
state changed bottom-center = false
state changed bottom-left = false
state changed bottom-right = false
state changed middle-center = false
state changed middle-left = false
state changed middle-right = false
state changed top-center = false
state changed top-left = false
state changed top-right = false

VST3

activate
updateStateValueCallback 0x0
activate
updateStateValueCallback 0x0
open ui
open ui
state changed bottom-center = false
state changed bottom-left = false
state changed bottom-right = false
state changed middle-center = false
state changed middle-left = false
state changed middle-right = false
state changed top-center = false
state changed top-left = false
state changed top-right = false

CLAP

activate
updateStateValueCallback 0x11c59ca20
open ui
open ui
state changed bottom-center = false
state changed bottom-left = false
state changed bottom-right = false
state changed middle-center = false
state changed middle-left = false
state changed middle-right = false
state changed top-center = false
state changed top-left = false
state changed top-right = false

LV2 (Plugin builds but REAPER/Mac is not picking it up, no errors shown)

I was expecting the UI to get top-left="hello" instead of the default value "false".

Cardinal calls updateStateValue() from a OSC handler https://github.com/DISTRHO/Cardinal/blob/a238f10eec777f2b0704d3299e226bf5129c022c/src/CardinalCommon.cpp#L331

That piece of code could be interpreted as, timing is important, ie. if updateStateValue() only works after the UI opens, but it seems not:

    void activate() override
    {
        t = new std::thread([this](){
            d_msleep(1000);
            d_stderr("thread");
            updateStateValue("top-left", "hello");
        });
    }
open ui
open ui
state changed bottom-center = false
state changed bottom-left = false
state changed bottom-right = false
state changed middle-center = false
state changed middle-left = false
state changed middle-right = false
state changed top-center = false
state changed top-left = false
state changed top-right = false
thread
updateStateValueCallback 0x1382728d0

Are these tests valid at all?

updateStateValueCallback 0x0 means some formats still do not support this right?

lucianoiam avatar Feb 02 '23 18:02 lucianoiam