|
AWE Core 8.D.12 Documentation
|
Using the AudioWeaver Plugin API to load plugin libraries. More...
Data Structures | |
| struct | _awe_PluginLoaderMethods |
| Method table to provide overrides to awe_PluginLoader_initWithMethods. More... | |
Typedefs | |
| typedef struct _awe_PluginLoaderMethods | awe_PluginLoaderMethods |
| Method table to provide overrides to awe_PluginLoader_initWithMethods. More... | |
Enumerations | |
| enum | awe_PluginLoader_Status { AWE_PLUGIN_LOADER_SUCCESS = 0 , AWE_PLUGIN_LOADER_UNINITIALIZED = -1 , AWE_PLUGIN_LOADER_ALREADY_INITIALIZED = -2 , AWE_PLUGIN_LOADER_MISSING_METHOD = -3 , AWE_PLUGIN_LOADER_ALLOCATION_FAILED = -4 , AWE_PLUGIN_LOADER_INVALID_INDEX = -5 , AWE_PLUGIN_LOADER_DL_OPEN_FAILED = -6 , AWE_PLUGIN_LOADER_DL_SYMBOL_NOT_FOUND = -7 , AWE_PLUGIN_LOADER_DL_INTERNAL_FAILURE = -8 } |
| Possible statuses which may be returned by plugin loader API functions. More... | |
Functions | |
| enum awe_PluginLoader_Status | awe_PluginLoader_init (size_t reserved_count) |
| Initialize the plugin loader. More... | |
| enum awe_PluginLoader_Status | awe_PluginLoader_initWithMethods (size_t reserved_count, const awe_PluginLoaderMethods *const overrides) |
| Initialize the plugin loader with a set of override callbacks. More... | |
| enum awe_PluginLoader_Status | awe_PluginLoader_load (const AWEPlugin **plugin, const char *file) |
| Load a plugin library. More... | |
| enum awe_PluginLoader_Status | awe_PluginLoader_loadWithNamespacePrefix (const AWEPlugin **plugin, const char *file, const char *prefix) |
| Load a plugin library with a namespaced entrypoint name. More... | |
| enum awe_PluginLoader_Status | awe_PluginLoader_loadWithEntrypoint (const AWEPlugin **plugin, const char *file, const char *entrypoint) |
| Load a plugin library with a custom entrypoint name. More... | |
| size_t | awe_PluginLoader_count () |
| Get the number of currently loaded plugins. More... | |
| enum awe_PluginLoader_Status | awe_PluginLoader_get (const AWEPlugin **plugin, size_t index) |
| Retrieve a loaded plugin by index. More... | |
| void | awe_PluginLoader_free () |
| Clean up the plugin loader. More... | |
| const char * | awe_PluginLoader_statusToString (const enum awe_PluginLoader_Status status) |
| Get a description of the given status. More... | |
Using the AudioWeaver Plugin API to load plugin libraries.
For information on how to create a plugin, see Creating a Plugin.
| typedef struct _awe_PluginLoaderMethods awe_PluginLoaderMethods |
Method table to provide overrides to awe_PluginLoader_initWithMethods.
This struct defines a set of function pointers which are used by awe_PluginLoader to perform memory allocation, dynamic library loading, and symbol resolution. It should be passed to awe_PluginLoader_initWithMethods. To avoid overriding a default value, leave it null.
Possible statuses which may be returned by plugin loader API functions.
| enum awe_PluginLoader_Status awe_PluginLoader_init | ( | size_t | reserved_count | ) |
Initialize the plugin loader.
This function (or awe_PluginLoader_initWithMethods) must be called before the plugin loader can be used. Will error if called while the loader is already initialized, but doing so is otherwise safe.
| reserved_count | The number of plugin entries to preallocate. |
| enum awe_PluginLoader_Status awe_PluginLoader_initWithMethods | ( | size_t | reserved_count, |
| const awe_PluginLoaderMethods *const | overrides | ||
| ) |
Initialize the plugin loader with a set of override callbacks.
Like awe_PluginLoader_init, except it will use functions provided via overrides instead of the defaults.
| reserved_count | The number of plugin entries to preallocate. | |
| [in] | overrides | Callbacks which replace system functions used by the plugin loader. Note that the loader does not take ownership of this pointer. If it is dynamically allocated, it must be freed by the caller. However, it also does not need to outlive this function call, as the loader's initialization method maintains a copy internally. Consequently, it is impossible to change the loader's internal callback table without reinitializing it. |
| enum awe_PluginLoader_Status awe_PluginLoader_load | ( | const AWEPlugin ** | plugin, |
| const char * | file | ||
| ) |
Load a plugin library.
Open a dynamic library and attempt to load it using its entrypoint method. This is idempotent, meaning once a plugin has been loaded this method will output the same cached value until the loader is freed. It is thus safe to call this method more than once without reinitializing the loader. Calling this method without first initializing the loader will return an error status, but is otherwise safe.
| [out] | plugin | If successful, the function will output a pointer to a valid AWEPlugin struct. Otherwise, it will be set to NULL. |
| [in] | file | A dynamic library to be loaded. The details of what exactly constitutes a valid file identifier may vary across platform, but generally speaking this should be a valid argument to dlopen. |
| enum awe_PluginLoader_Status awe_PluginLoader_loadWithNamespacePrefix | ( | const AWEPlugin ** | plugin, |
| const char * | file, | ||
| const char * | prefix | ||
| ) |
Load a plugin library with a namespaced entrypoint name.
Open a dynamic library and attempt to load it using its entrypoint method. Provide a prefix string which will be prepended to symbol lookups.
| [out] | plugin | If successful, the function will output a pointer to a valid AWEPlugin struct. Otherwise, it will be set to NULL. |
| [in] | file | A dynamic library to be loaded. The details of what exactly constitutes a valid file identifier may vary across platform, but generally speaking this should be a valid argument to dlopen. |
| [in] | prefix | A null-terminated string which will be prepended to the name of the entrypoint symbol when we search for it in the plugin library. |
| enum awe_PluginLoader_Status awe_PluginLoader_loadWithEntrypoint | ( | const AWEPlugin ** | plugin, |
| const char * | file, | ||
| const char * | entrypoint | ||
| ) |
Load a plugin library with a custom entrypoint name.
Open a dynamic library and attempt to load it using its entrypoint method, whose name is provided by the caller. Note that this does not apply to the fallback "legacy" plugin ABI.
| [out] | plugin | If successful, the function will output a pointer to a valid AWEPlugin struct. Otherwise, it will be set to NULL. |
| [in] | file | A dynamic library to be loaded. The details of what exactly constitutes a valid file identifier may vary across platform, but generally speaking this should be a valid argument to dlopen. |
| [in] | entrypoint | A null-terminated string which will be used to look up the entrypoint symbol in the plugin library. |
| size_t awe_PluginLoader_count | ( | ) |
Get the number of currently loaded plugins.
| enum awe_PluginLoader_Status awe_PluginLoader_get | ( | const AWEPlugin ** | plugin, |
| size_t | index | ||
| ) |
Retrieve a loaded plugin by index.
Indices do not change during the lifetime of the loader, but this should be considered an implementation detail and should not be relied on. This method is typically intended to be used in the context of a loop iterating over all loaded plugins. In all other contexts, awe_PluginLoader_load should be prefered as a means to access plugins (even plugins which have already been loaded).
| [out] | plugin | If successful, the function will output a pointer to a valid AWEPlugin struct. Otherwise, it will be set to NULL. |
| index | The index of the desired plugin in the loader's internal plugin list. |
| void awe_PluginLoader_free | ( | ) |
Clean up the plugin loader.
Invalidates all loaded AWEPlugin handles.
Close all plugin libraries and free internal dynamic memory used by the loader. Once the loader has been freed, it may be reinitialized if so desired. However, after calling this function, all existing AWEPlugin handles may point to freed or otherwise inaccessible memory. The caller is responsible for making sure they are not used. The simplest way to guarantee this will typically be to initialize the loader once at the start of main and free it just before the process exits.
| const char * awe_PluginLoader_statusToString | ( | const enum awe_PluginLoader_Status | status | ) |
Get a description of the given status.
| status | A status code. |