Skip to main content

Module wrapper

Module wrapper 

Source
Expand description

Helpers shared across format wrappers (CLAP, VST3, VST2, AU, AAX, LV2).

Each wrapper still owns its format-specific descriptor types and callback tables; those don’t unify cleanly. What unifies is the “boring” boundary glue: building CStrings from ParamInfo fields, picking the default bus layout, and resolving install-time name overrides.

Each helper is a single small function so the wrappers stay greppable - the per-format vtable construction code reads as “for each param, get cstrings, build descriptor” without inlined CString::new(...).unwrap_or_default() boilerplate.

Adding a new format wrapper? Reach for these first; only fall back to direct CString::new etc. when the format genuinely needs something none of the other formats does.

Structs§

ParamCStrings
CStrings derived from a single ParamInfo. All four conversions follow the same pattern (unwrap_or_default() so a \0 in metadata degrades to an empty C string instead of panicking the host); pulling them into one struct keeps the per-format vtable loops uniform.
PluginGuard
Guard handing out the exclusive &mut T; unlocks on drop.
PluginMutex
See super::SharedPlugin for the per-platform lock choice.

Functions§

default_io_channels
(input_channels, output_channels) for the plugin’s default bus layout, or None when the plugin declares no layouts. Used by every format’s vtable / descriptor to advertise channel counts at registration time.
first_bus_layout
Pick the plugin’s first bus layout, or None when the plugin declares no layouts. Used by wrappers (AAX, VST2) that need to read the layout before host-side bus-config negotiation, where a missing layout would otherwise produce silently-misreported channel counts.
lock_plugin
Lock the mediation lock, forgiving poison. A poisoned lock means a panic already escaped somewhere and was reported by the wrapper’s panic guard; refusing every later block would turn one bad block into permanent silence, and the plugin’s state is no more suspect than after any other caught panic. (The Linux pthread lock has no poison to forgive; unwind simply unlocks.)
log_midi_ports_clamped
Diagnostic for a plugin that declared more MIDI ports than the format can carry. The wrapper clamps to a single port and routes all traffic to port 0; without this line the truncation would read as “multi-port supported.” declared is the plugin’s per-direction port count; nothing is logged for the single-port (or zero-port) case. direction is "input" / "output".
log_missing_bus_layout
Standard diagnostic emitted by register_* when first_bus_layout or default_io_channels returns None. Centralised so every wrapper prints the same actionable message.
run_audio_block
Run a per-block audio-thread body under std::panic::catch_unwind.
run_audio_block_with
Like run_audio_block but for callbacks that return a status code. Returns body’s value on a clean exit, fallback if the body panicked. Used by the CLAP wrapper, whose process callback returns a clap_process_status i32.
run_extern_callback_with
Run a generic extern "C" callback body under std::panic::catch_unwind. Returns body’s value on a clean exit, fallback if the body panicked.
run_register
Run a register_* body under std::panic::catch_unwind.
shared_plugin
Wrap a freshly created plugin in the wrapper-standard mediation lock. See SharedPlugin.
try_lock_plugin
lock_plugin’s non-blocking twin: None only when the lock is genuinely held (poison is forgiven, same rationale).

Type Aliases§

SharedPlugin
The mediation lock every format wrapper puts around its plugin instance. The audio thread holds the lock for the duration of a block (process, reset, the queued state apply); host-thread state callbacks and the editor’s get_state closure block for the read - safe in that direction, and bounded by the block the audio thread is finishing. Meters ride the lock-free MeterStore instead, so per-frame GUI paints never touch this lock.