Phase 15: host trusted LADSPA processors with persisted graph state

This commit is contained in:
Johannes Findeisen 2026-10-27 04:00:27 +01:00
commit f72314b5a3
24 changed files with 1046 additions and 70 deletions

View file

@ -8,6 +8,8 @@ extern "C" {
#endif
typedef struct xtc_graph xtc_graph;
/* Control-thread independent model copy; out is NULL on failure. */
xtc_result xtc_graph_clone(const xtc_graph *source, xtc_graph **out);
typedef enum {
XTC_SIGNAL_AUDIO = 1,
@ -35,7 +37,8 @@ typedef enum {
XTC_NODE_OUTPUT,
XTC_NODE_AUDIO, /* Timeline mix source, output only. */
XTC_NODE_INSTRUMENT, /* Internal MIDI instrument, output only. */
XTC_NODE_NATIVE /* Trusted source/effect; see xtc_native.h. */
XTC_NODE_NATIVE, /* Trusted source/effect; see xtc_native.h. */
XTC_NODE_PLUGIN /* Persisted LADSPA source/effect; see xtc_plugin.h. */
} xtc_node_type;
typedef struct {

39
include/xtc/xtc_plugin.h Normal file
View file

@ -0,0 +1,39 @@
#ifndef XTC_PLUGIN_H
#define XTC_PLUGIN_H
#include "xtc_processor.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XTC_PLUGIN_CONTROLS 16U
/* Plain copied model: no library handles or callback pointers. Absolute trusted
* module path, descriptor index + unique ID + label checked again on compile.
* Controls are actual LADSPA port indices, in ascending order. */
typedef struct {
char path[512], label[64];
unsigned int index, unique_id, inputs, control_count;
unsigned int ports[XTC_PLUGIN_CONTROLS];
float values[XTC_PLUGIN_CONTROLS];
} xtc_plugin_spec;
typedef struct xtc_plugin xtc_plugin;
/* Control thread only. Probe explicitly enumerates a file by descriptor index;
* NOT_FOUND means end, UNSUPPORTED means descriptor/layout unsupported. Loading
* trusted libraries can execute arbitrary constructors. Never probe in audio. */
xtc_result xtc_plugin_probe(const char *path, unsigned int index, double rate, xtc_plugin_spec *out);
/* Control-thread parameter names, computed ranges/defaults at this sample rate.
* Output has spec->control_count entries; IDs are LADSPA port indices. */
xtc_result xtc_plugin_parameters(const xtc_plugin_spec *spec, double rate, xtc_parameter_info out[XTC_PLUGIN_CONTROLS]);
/* Metadata-only validation: never opens libraries. */
xtc_result xtc_plugin_spec_validate(const xtc_plugin_spec *spec);
xtc_result xtc_plugin_create(const xtc_plugin_spec *spec, double rate, size_t frames, xtc_plugin **out);
void xtc_plugin_destroy(xtc_plugin *plugin); /* control, after quiescence */
/* Single audio owner. No loading/allocation/I/O in host process; trusted run()
* must obey realtime rules. No MIDI; max one mono input and one mono output.
* Transport reset retains LADSPA delay history (no realtime reset contract). */
xtc_result xtc_plugin_process(xtc_plugin *plugin, const float *input, float *output, size_t frames);
xtc_result xtc_graph_add_plugin(xtc_graph *graph, const xtc_plugin_spec *spec, size_t *id);
xtc_result xtc_graph_get_plugin(const xtc_graph *graph, size_t id, xtc_plugin_spec *out);
xtc_result xtc_graph_set_plugin(xtc_graph *graph, size_t id, const xtc_plugin_spec *spec);
#ifdef __cplusplus
}
#endif
#endif