lv2: log and urid now always optional, fixed ui-related feature request in ttl, include with angled brackets

This commit is contained in:
Stefano D'Angelo 2025-01-19 08:28:25 +01:00
parent 63391b158f
commit ae513dae30
3 changed files with 46 additions and 35 deletions

View File

@ -22,7 +22,7 @@
lv2:microVersion {{=/^[0-9]+\.([0-9]+)/.exec(it.lv2.version)[1]}} ; lv2:microVersion {{=/^[0-9]+\.([0-9]+)/.exec(it.lv2.version)[1]}} ;
{{?(it.tibia.lv2.ports.find(p => p.type == "midi" && !p.optional))}} {{?(it.tibia.lv2.ports.find(p => p.type == "midi" && !p.optional))}}
lv2:requiredFeature urid:map ; lv2:requiredFeature urid:map ;
{{??(it.tibia.lv2.ports.find(p => p.type == "midi") || (it.product.state && it.product.state.dspCustom))}} {{??}}
lv2:optionalFeature urid:map ; lv2:optionalFeature urid:map ;
{{?}} {{?}}
{{?(it.tibia.lv2.ports.find(p => p.type == "midi") || (it.product.state && it.product.state.dspCustom))}} {{?(it.tibia.lv2.ports.find(p => p.type == "midi") || (it.product.state && it.product.state.dspCustom))}}
@ -31,7 +31,6 @@
lv2:optionalFeature lv2:hardRTCapable ; lv2:optionalFeature lv2:hardRTCapable ;
{{?it.product.ui}} {{?it.product.ui}}
ui:ui plugin:ui ; ui:ui plugin:ui ;
lv2:extensionData ui:idleInterface ;
{{?}} {{?}}
{{?(it.product.state && it.product.state.dspCustom)}} {{?(it.product.state && it.product.state.dspCustom)}}
lv2:extensionData state:interface ; lv2:extensionData state:interface ;

View File

@ -27,6 +27,10 @@
#define DATA_PRODUCT_CONTROL_INPUTS_N {{=it.product.parameters.filter(x => x.direction == "input").length}} #define DATA_PRODUCT_CONTROL_INPUTS_N {{=it.product.parameters.filter(x => x.direction == "input").length}}
#define DATA_PRODUCT_CONTROL_OUTPUTS_N {{=it.product.parameters.filter(x => x.direction == "output").length}} #define DATA_PRODUCT_CONTROL_OUTPUTS_N {{=it.product.parameters.filter(x => x.direction == "output").length}}
{{?it.product.buses.find(x => x.type == "midi" && !x.optional)}}
#define DATA_PRODUCT_MIDI_REQUIRED
{{?}}
#if DATA_PRODUCT_MIDI_INPUTS_N > 0 #if DATA_PRODUCT_MIDI_INPUTS_N > 0
static uint32_t midi_in_index[DATA_PRODUCT_MIDI_INPUTS_N] = { static uint32_t midi_in_index[DATA_PRODUCT_MIDI_INPUTS_N] = {
{{~it.tibia.lv2.ports.filter(x => x.type == "midi" && x.direction == "input") :p}}{{=p.busIndex}}, {{~}} {{~it.tibia.lv2.ports.filter(x => x.type == "midi" && x.direction == "input") :p}}{{=p.busIndex}}, {{~}}

View File

@ -31,23 +31,23 @@
#endif #endif
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#include "lv2/core/lv2.h" #include <lv2/core/lv2.h>
#include <lv2/core/lv2_util.h>
#include <lv2/log/log.h>
#include <lv2/log/logger.h>
#include <lv2/urid/urid.h>
#if (DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0) || defined(DATA_STATE_DSP_CUSTOM) #if (DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0) || defined(DATA_STATE_DSP_CUSTOM)
# include "lv2/core/lv2_util.h" # include <lv2/atom/atom.h>
# include "lv2/log/log.h"
# include "lv2/log/logger.h"
# include "lv2/urid/urid.h"
# include "lv2/atom/atom.h"
# if DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0 # if DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0
# include "lv2/atom/util.h" # include <lv2/atom/util.h>
# include "lv2/midi/midi.h" # include <lv2/midi/midi.h>
# endif # endif
#endif #endif
#ifdef DATA_UI #ifdef DATA_UI
# include "lv2/ui/ui.h" # include <lv2/ui/ui.h>
#endif #endif
#ifdef DATA_STATE_DSP_CUSTOM #ifdef DATA_STATE_DSP_CUSTOM
# include "lv2/state/state.h" # include <lv2/state/state.h>
#endif #endif
#include <string.h> #include <string.h>
@ -95,7 +95,6 @@ typedef struct {
#endif #endif
void * mem; void * mem;
char * bundle_path; char * bundle_path;
#if (DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0) || defined(DATA_STATE_DSP_CUSTOM)
LV2_Log_Logger logger; LV2_Log_Logger logger;
LV2_URID_Map * map; LV2_URID_Map * map;
#if DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0 #if DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0
@ -107,7 +106,6 @@ typedef struct {
LV2_State_Store_Function state_store; LV2_State_Store_Function state_store;
LV2_State_Handle state_handle; LV2_State_Handle state_handle;
#endif #endif
#endif
} plugin_instance; } plugin_instance;
static const char * get_bundle_path_cb(void *handle) { static const char * get_bundle_path_cb(void *handle) {
@ -144,7 +142,6 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s
if (instance->bundle_path == NULL) if (instance->bundle_path == NULL)
goto err_bundle_path; goto err_bundle_path;
#if (DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0) || defined(DATA_STATE_DSP_CUSTOM)
// from https://lv2plug.in/book // from https://lv2plug.in/book
const char * missing = lv2_features_query(features, const char * missing = lv2_features_query(features,
LV2_LOG__log, &instance->logger.log, false, LV2_LOG__log, &instance->logger.log, false,
@ -154,16 +151,20 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s
lv2_log_logger_set_map(&instance->logger, instance->map); lv2_log_logger_set_map(&instance->logger, instance->map);
if (missing) { if (missing) {
lv2_log_error(&instance->logger, "Missing feature <%s>\n", missing); lv2_log_error(&instance->logger, "Missing feature <%s>\n", missing);
#ifdef DATA_PRODUCT_MIDI_REQUIRED
goto err_urid; goto err_urid;
#endif
} }
#if DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0 #if DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0
if (instance->map)
instance->uri_midi_MidiEvent = instance->map->map(instance->map->handle, LV2_MIDI__MidiEvent); instance->uri_midi_MidiEvent = instance->map->map(instance->map->handle, LV2_MIDI__MidiEvent);
#endif #endif
#ifdef DATA_STATE_DSP_CUSTOM #ifdef DATA_STATE_DSP_CUSTOM
if (instance->map) {
instance->uri_atom_Chunk = instance->map->map(instance->map->handle, LV2_ATOM__Chunk); instance->uri_atom_Chunk = instance->map->map(instance->map->handle, LV2_ATOM__Chunk);
instance->uri_state_data = instance->map->map(instance->map->handle, DATA_LV2_URI "#state_data"); instance->uri_state_data = instance->map->map(instance->map->handle, DATA_LV2_URI "#state_data");
# endif }
#endif #endif
plugin_callbacks cbs = { plugin_callbacks cbs = {
@ -222,7 +223,9 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s
err_mem: err_mem:
plugin_fini(&instance->p); plugin_fini(&instance->p);
#ifdef DATA_PRODUCT_MIDI_REQUIRED
err_urid: err_urid:
#endif
free(instance->bundle_path); free(instance->bundle_path);
err_bundle_path: err_bundle_path:
free(instance); free(instance);
@ -305,6 +308,7 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
#if DATA_PRODUCT_MIDI_INPUTS_N > 0 #if DATA_PRODUCT_MIDI_INPUTS_N > 0
// from https://lv2plug.in/book // from https://lv2plug.in/book
if (i->map)
for (size_t j = 0; j < DATA_PRODUCT_MIDI_INPUTS_N; j++) { for (size_t j = 0; j < DATA_PRODUCT_MIDI_INPUTS_N; j++) {
if (i->x_midi[j] == NULL) if (i->x_midi[j] == NULL)
continue; continue;
@ -363,6 +367,8 @@ static LV2_State_Status state_save(LV2_Handle instance, LV2_State_Store_Function
(void)features; (void)features;
plugin_instance * i = (plugin_instance *)instance; plugin_instance * i = (plugin_instance *)instance;
if (!i->map)
return LV2_STATE_ERR_UNKNOWN; // evidently buggy host, we don't have an errcode for it, LV2_STATE_ERR_NO_FEATURE has a different meaning
i->state_store = store; i->state_store = store;
i->state_handle = handle; i->state_handle = handle;
return plugin_state_save(&i->p) == 0 ? LV2_STATE_SUCCESS : LV2_STATE_ERR_UNKNOWN; return plugin_state_save(&i->p) == 0 ? LV2_STATE_SUCCESS : LV2_STATE_ERR_UNKNOWN;
@ -373,6 +379,8 @@ static LV2_State_Status state_restore(LV2_Handle instance, LV2_State_Retrieve_Fu
(void)features; (void)features;
plugin_instance * i = (plugin_instance *)instance; plugin_instance * i = (plugin_instance *)instance;
if (!i->map)
return LV2_STATE_ERR_UNKNOWN; // evidently buggy host, we don't have an errcode for it, LV2_STATE_ERR_NO_FEATURE has a different meaning
size_t length; size_t length;
uint32_t type, xflags; // jalv 1.6.6 crashes using NULL as per spec, so we have these two uint32_t type, xflags; // jalv 1.6.6 crashes using NULL as per spec, so we have these two
const char * data = retrieve(handle, i->uri_state_data, &length, &type, &xflags); const char * data = retrieve(handle, i->uri_state_data, &length, &type, &xflags);