fix state sync in lv2 and vst3
This commit is contained in:
parent
85f70c29c1
commit
c6de99898d
@ -331,8 +331,8 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
||||
|
||||
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||
# ifdef DATA_STATE_DSP_CUSTOM
|
||||
char do_set;
|
||||
if (!atomic_flag_test_and_set(&i->sync_lock_flag)) {
|
||||
_Bool locked = !atomic_flag_test_and_set(&i->sync_lock_flag);
|
||||
if (locked) {
|
||||
if (!i->synced) {
|
||||
if (i->loaded) {
|
||||
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
||||
@ -349,10 +349,7 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
||||
}
|
||||
i->synced = 1;
|
||||
i->loaded = 0;
|
||||
atomic_flag_clear(&i->sync_lock_flag);
|
||||
do_set = 1;
|
||||
} else
|
||||
do_set = 0;
|
||||
}
|
||||
# endif
|
||||
|
||||
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
||||
@ -362,11 +359,20 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
||||
if (v != i->params[j]) {
|
||||
i->params[j] = v;
|
||||
# ifdef DATA_STATE_DSP_CUSTOM
|
||||
if (do_set)
|
||||
if (locked) {
|
||||
i->params_sync[j] = i->params[j];
|
||||
# endif
|
||||
plugin_set_parameter(&i->p, param_data[j].index, v);
|
||||
# ifdef DATA_STATE_DSP_CUSTOM
|
||||
}
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef DATA_STATE_DSP_CUSTOM
|
||||
if (locked)
|
||||
atomic_flag_clear(&i->sync_lock_flag);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if DATA_PRODUCT_MIDI_INPUTS_N > 0
|
||||
|
@ -701,6 +701,7 @@ static Steinberg_tresult pluginSetState(void* thisInterface, struct Steinberg_IB
|
||||
|
||||
if (data)
|
||||
free(data);
|
||||
TRACE(err == 0 ? " ok" : " err");
|
||||
return err == 0 ? Steinberg_kResultOk : Steinberg_kResultFalse;
|
||||
}
|
||||
|
||||
@ -743,6 +744,7 @@ static Steinberg_tresult pluginGetState(void* thisInterface, struct Steinberg_IB
|
||||
err = pluginStateWriteCb(p, data, length);
|
||||
# endif
|
||||
#endif
|
||||
TRACE(err == 0 ? " ok" : " err");
|
||||
return err == 0 ? Steinberg_kResultOk : Steinberg_kResultFalse;
|
||||
}
|
||||
|
||||
@ -867,9 +869,8 @@ static Steinberg_tresult pluginSetProcessing(void* thisInterface, Steinberg_TBoo
|
||||
|
||||
static void processParams(pluginInstance *p, struct Steinberg_Vst_ProcessData *data, char before) {
|
||||
#if DATA_PRODUCT_PARAMETERS_IN_N + DATA_PRODUCT_BUSES_MIDI_INPUT_N > 0
|
||||
# ifdef DATA_STATE_DSP_CUSTOM
|
||||
char do_set;
|
||||
if (!atomic_flag_test_and_set(&p->syncLockFlag)) {
|
||||
_Bool locked = !atomic_flag_test_and_set(&p->syncLockFlag);
|
||||
if (locked) {
|
||||
if (!p->synced) {
|
||||
if (p->loaded) {
|
||||
for (uint32_t j = 0; j < DATA_PRODUCT_PARAMETERS_IN_N; j++) {
|
||||
@ -886,14 +887,13 @@ static void processParams(pluginInstance *p, struct Steinberg_Vst_ProcessData *d
|
||||
}
|
||||
p->synced = 1;
|
||||
p->loaded = 0;
|
||||
atomic_flag_clear(&p->syncLockFlag);
|
||||
do_set = 1;
|
||||
} else
|
||||
do_set = 0;
|
||||
# endif
|
||||
}
|
||||
|
||||
if (data->inputParameterChanges == NULL)
|
||||
if (data->inputParameterChanges == NULL) {
|
||||
if (locked)
|
||||
atomic_flag_clear(&p->syncLockFlag);
|
||||
return;
|
||||
}
|
||||
Steinberg_int32 n = data->inputParameterChanges->lpVtbl->getParameterCount(data->inputParameterChanges);
|
||||
for (Steinberg_int32 i = 0; i < n; i++) {
|
||||
struct Steinberg_Vst_IParamValueQueue *q = data->inputParameterChanges->lpVtbl->getParameterData(data->inputParameterChanges, i);
|
||||
@ -951,13 +951,16 @@ static void processParams(pluginInstance *p, struct Steinberg_Vst_ProcessData *d
|
||||
v = parameterAdjust(parameterInData + ii, parameterMap(parameterInData + ii, v));
|
||||
if (v != p->parametersIn[ii]) {
|
||||
p->parametersIn[ii] = v;
|
||||
# ifdef DATA_STATE_DSP_CUSTOM
|
||||
if (do_set)
|
||||
# endif
|
||||
if (locked) {
|
||||
p->parametersInSync[ii] = p->parametersIn[ii];
|
||||
plugin_set_parameter(&p->p, parameterInData[ii].index, v);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
if (locked)
|
||||
atomic_flag_clear(&p->syncLockFlag);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user