From 1af0fb6261e4dbce0a90cbb4dc6f252a85995c64 Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Mon, 20 Jan 2025 11:55:09 +0100 Subject: [PATCH] api: conditionally define callbacks --- templates/api/src/plugin_api.h | 4 ++++ templates/lv2/src/lv2.c | 9 +-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/templates/api/src/plugin_api.h b/templates/api/src/plugin_api.h index 327db47..2a62362 100644 --- a/templates/api/src/plugin_api.h +++ b/templates/api/src/plugin_api.h @@ -26,10 +26,14 @@ typedef struct { const char * format; const char * (*get_bindir)(void *handle); const char * (*get_datadir)(void *handle); +{{?it.product.state && it.product.state.dspCustom}} int (*write_state)(void *handle, const char *data, size_t length); +{{?it.product.parameters.find(x => x.direction == "input")}} void (*load_parameter)(void *handle, size_t index, float value); +{{?}} void (*lock_state)(void *handle); void (*unlock_state)(void *handle); +{{?}} } plugin_callbacks; typedef struct { diff --git a/templates/lv2/src/lv2.c b/templates/lv2/src/lv2.c index 1355e3e..72109d1 100644 --- a/templates/lv2/src/lv2.c +++ b/templates/lv2/src/lv2.c @@ -212,16 +212,9 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s /* .write_state = */ write_state_cb, # if DATA_PRODUCT_CONTROL_INPUTS_N > 0 /* .load_parameter = */ load_parameter_cb, -# else - /* .load_parameter = */ NULL, # endif /* .lock_state = */ lock_state_cb, - /* .unlock_state = */ unlock_state_cb -# else - /* .write_state = */ NULL, - /* .load_parameter = */ NULL, - /* .state_lock = */ NULL, - /* .state_unlock = */ NULL + /* .unlock_state = */ unlock_state_cb, # endif }; plugin_init(&instance->p, &cbs);