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§
- ParamC
Strings CStringsderived from a singleParamInfo. All four conversions follow the same pattern (unwrap_or_default()so a\0in metadata degrades to an empty C string instead of panicking the host); pulling them into one struct keeps the per-format vtable loops uniform.- Plugin
Cell - Plugin
Guard - Guard handing out the exclusive
&mut T; releases the handoff on drop so the next owner’sAcquiresees this owner’s writes.
Functions§
- default_
io_ channels (input_channels, output_channels)for the plugin’s default bus layout, orNonewhen the plugin declares no layouts. Used by every format’s vtable / descriptor to advertise channel counts at registration time.- enter_
plugin - Take ownership of the plugin for the current callback. Never blocks:
the audio thread owns the plugin while active, the host thread while
inactive, and the host contract keeps the two from overlapping, so
there is nothing to wait on. The returned guard’s
&mutis exclusive by that contract; theAcquireinside observes the previous owner’s writes. - find_
bus_ layout - Find the
bus_layouts()index whose total input/output channel counts match(inputs, outputs). Wrappers that negotiate a layout from a host-proposed arrangement (VST3setBusArrangements, AU channel-config selection, the standalone device match, VST2’s fixed I/O at load) use this to map a request onto a supported layout.Nonewhen nothing matches; the caller then rejects the arrangement or falls back to the first layout. - first_
bus_ layout - Pick the plugin’s first bus layout, or
Nonewhen 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. - 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.”declaredis the plugin’s per-direction port count; nothing is logged for the single-port (or zero-port) case.directionis"input"/"output". - log_
missing_ bus_ layout - Standard diagnostic emitted by
register_*whenfirst_bus_layoutordefault_io_channelsreturnsNone. Centralised so every wrapper prints the same actionable message. - max_
io_ channels (max_input_channels, max_output_channels)across every declared bus layout, orNonewhen the plugin declares no layouts. Wrappers that let the host switch layouts at runtime (AU’s per-instance stream format) size their process-time scratch to this so a later, wider layout selection doesn’t outgrow buffers allocated for the first one.- run_
audio_ block - Run a per-block audio-thread
bodyunderstd::panic::catch_unwind. - run_
audio_ block_ with - Like
run_audio_blockbut for callbacks that return a status code. Returnsbody’s value on a clean exit,fallbackif the body panicked. Used by the CLAP wrapper, whose process callback returns aclap_process_statusi32. - run_
extern_ callback_ with - Run a generic
extern "C"callback body understd::panic::catch_unwind. Returnsbody’s value on a clean exit,fallbackif the body panicked. - run_
register - Run a
register_*body understd::panic::catch_unwind. - save_
extra - Read the plugin’s custom-state blob for a host state save.
- shared_
plugin - Wrap a freshly created plugin in the wrapper-standard ownership
cell. See
SharedPlugin.
Type Aliases§
- Shared
Plugin - The ownership cell every format wrapper puts around its plugin
instance. The audio thread owns the plugin while the host is
processing (
process, the queued state apply); the host thread owns it while processing is stopped (init,reset, an inactive state load). The host contract makes those two mutually exclusive in time - a spec-compliant host never overlapsprocesswith a lifecycle callback - soPluginCellholds no OS lock and the audio thread never waits. Ownership handoff carries a release-acquire edge (each owner observes the previous owner’s writes), not mutual exclusion.