Phase 23: refine routing inspection, signal-flow layout and atomic wire insertion

This commit is contained in:
Johannes Findeisen 2026-10-27 16:00:29 +01:00
commit ba5c2503a7
15 changed files with 533 additions and 22 deletions

View file

@ -49,7 +49,7 @@ typedef struct {
size_t channel_count;
} xtc_port_info;
/* Control-thread API. Limits: 256 nodes, mono audio only. IDs are stable
/* Control-thread API. Limits: 256 nodes, one audio lane per port (stereo plans use paired lanes). IDs are stable
* monotonically assigned identifiers; removed IDs are never reused. Output
* parameters are written only on success, except create/compile/apply_edit
* which set their output pointer to NULL on failure. */
@ -67,7 +67,8 @@ typedef enum {
XTC_EDIT_ADD_NODE = 1,
XTC_EDIT_REMOVE_NODE,
XTC_EDIT_CONNECT,
XTC_EDIT_DISCONNECT
XTC_EDIT_DISCONNECT,
XTC_EDIT_INSERT_GAIN /* Atomic wire replacement by a unity gain/bus node. */
} xtc_graph_edit_kind;
typedef struct {
@ -84,6 +85,18 @@ typedef struct {
} data;
} xtc_graph_edit;
/* Control-thread routing diagnostics in dense-node order, matching get_node.
* level = longest source-to-node edge count. reaches_output follows explicit
* output nodes (or legacy terminal fallback only when no output nodes exist).
* external_input = no incoming wire and an input port: renderer uses external
* audio there, NOT silence. Reachability is structural, not an audibility test.
* No allocation/plugin loading. Failure leaves items and out_count unchanged. */
typedef struct {
size_t id, inputs, outputs, level;
int reaches_output, external_input;
} xtc_routing_info;
xtc_result xtc_graph_analyze(const xtc_graph *graph, xtc_routing_info *items, size_t capacity, size_t *out_count);
/* Read-only snapshots; indexes enumerate dense lists, distinct from stable IDs.
* No borrowed pointers into graph storage are exposed. */
/**
@ -125,7 +138,9 @@ xtc_result xtc_graph_get_connection(const xtc_graph *graph, size_t index, xtc_co
xtc_result xtc_graph_require_output_nodes(xtc_graph *graph, int required);
/* Transactional command: on success caller owns a new graph; source unchanged.
* Failure sets *out_graph=NULL, leaves source and out_added_id unchanged.
* out_added_id is optional and written only for successful ADD_NODE. */
* out_added_id is optional and written only for successful ADD_NODE/INSERT_GAIN.
* INSERT_GAIN uses data.connection: the existing wire is replaced by
* source -> new unity gain -> destination, without publishing intermediate states. */
/**
* @brief Applies an edit to a new graph copy, leaving the source unchanged.
*