pub struct PluginLoader { /* private fields */ }Expand description
Owner of all loaded plugin cdylibs.
See the module docs for the lifetime / RT-safety contract.
Implementations§
Source§impl PluginLoader
impl PluginLoader
Sourcepub fn load(&mut self, path: &Path) -> Result<PluginId>
pub fn load(&mut self, path: &Path) -> Result<PluginId>
Load and ABI-verify a plugin cdylib, returning its assigned id.
§Steps
- Validate the path (must be an existing, readable file).
dlopenthe library.- Look up and call
audio_plugin_abi_magic; requireAUDIO_PLUGIN_ABI_MAGIC. - Look up and call
audio_plugin_abi_version; require a major match (seeis_abi_compatible). - Look up
audio_plugin_metadataand copy out an ownedPluginMetadata. - Look up
audio_plugin_create(required) andaudio_plugin_destroy(optional). - Register the plugin under a fresh
PluginId.
Loading the same path twice is permitted: each call receives its own id
and its own dlopen handle.
§Errors
PluginError::InvalidPath— missing file or non-UTF-8 path.PluginError::LibraryLoad—dlopenfailed.PluginError::SymbolMissing— a required symbol is absent.PluginError::InvalidMetadata— magic mismatch or bad metadata.PluginError::AbiVersionMismatch— ABI major differs.
Sourcepub fn unload(&mut self, id: PluginId) -> Result<()>
pub fn unload(&mut self, id: PluginId) -> Result<()>
Unload a plugin, dropping its library (dlclose).
The caller must ensure no AudioNode
instantiated from this plugin is still alive — the adapter owns an
opaque handle into the plugin’s memory and calling it after dlclose
is undefined behaviour.
§Errors
Returns PluginError::NotLoaded when id is not registered.
Sourcepub fn get(&self, id: PluginId) -> Result<&LoadedPlugin>
pub fn get(&self, id: PluginId) -> Result<&LoadedPlugin>
Sourcepub fn get_mut(&mut self, id: PluginId) -> Result<&mut LoadedPlugin>
pub fn get_mut(&mut self, id: PluginId) -> Result<&mut LoadedPlugin>
Mutably borrow a loaded plugin by id.
§Errors
Returns PluginError::NotLoaded when id is not registered.
Sourcepub fn metadata(&self, id: PluginId) -> Result<&PluginMetadata>
pub fn metadata(&self, id: PluginId) -> Result<&PluginMetadata>
Sourcepub fn instantiate(&mut self, id: PluginId) -> Result<Box<dyn AudioNode>>
pub fn instantiate(&mut self, id: PluginId) -> Result<Box<dyn AudioNode>>
Instantiate a fresh AudioNode from a loaded plugin.
Runs on the setup thread; the returned node is then moved onto the RT thread by the caller.
§Errors
Returns PluginError::NotLoaded when id is not registered.