AWE Core OS 8.B.22 Documentation
AWEPluginLoader.h
Go to the documentation of this file.
1/*******************************************************************************
2*
3* AudioWeaver Plugins
4* -------------------
5*
6********************************************************************************
7* AWEPluginLoader.h
8********************************************************************************
9*
10* Description: API used to load plugin libraries.
11*
12* Copyright: (c) 2025 DSP Concepts, Inc. All rights reserved.
13* 3235 Kifer Road
14* Santa Clara, CA 95054
15*
16*******************************************************************************/
17
30#ifndef AWE_PLUGIN_LOADER_H
31#define AWE_PLUGIN_LOADER_H
32
33#include "AWEPluginTypes.h"
34
35#include <stdarg.h>
36#include <stdint.h>
37#include <stdbool.h>
38#include <stddef.h>
39
54{
55 void* (*malloc)(size_t size);
56 void* (*realloc)(void* ptr, size_t size);
57 void (*free)(void* ptr);
58 void* (*open)(const char* file);
59 void (*close)(void* handle);
60 void* (*sym)(void* handle, const char* name);
61 void (*vlog)(int32_t level, uint32_t type, const char* fmt, va_list args);
63
68{
78};
79
80#ifdef __cplusplus
81extern "C" {
82#endif /* __cplusplus */
83
93enum awe_PluginLoader_Status awe_PluginLoader_init(size_t reserved_count);
94
109enum awe_PluginLoader_Status awe_PluginLoader_initWithMethods(size_t reserved_count, const awe_PluginLoaderMethods* const overrides);
110
125enum awe_PluginLoader_Status awe_PluginLoader_load(const AWEPlugin** plugin, const char* file);
126
143
160enum awe_PluginLoader_Status awe_PluginLoader_loadWithNamespacePrefix(const AWEPlugin** plugin, const char* file, const char* prefix);
161
177enum awe_PluginLoader_Status awe_PluginLoader_loadWithEntrypoint(const AWEPlugin** plugin, const char* file, const char* entrypoint);
178
187
204enum awe_PluginLoader_Status awe_PluginLoader_get(const AWEPlugin** plugin, size_t index);
205
220enum awe_PluginLoader_Status awe_PluginLoader_find(const AWEPlugin** plugin, const char* file);
221
222
237
246const char* awe_PluginLoader_statusToString(const enum awe_PluginLoader_Status status);
247
248#ifdef __cplusplus
249}
250#endif /* __cplusplus */
251
254#endif /* AWE_PLUGIN_LOADER_H */
AudioWeaver Plugin Types.
struct _awe_PluginLoaderMethods awe_PluginLoaderMethods
Method table to provide overrides to awe_PluginLoader_initWithMethods.
enum awe_PluginLoader_Status awe_PluginLoader_load(const AWEPlugin **plugin, const char *file)
Load a plugin library.
Definition: PluginLoader.c:563
size_t awe_PluginLoader_count()
Get the number of currently loaded plugins.
Definition: PluginLoader.c:617
awe_PluginLoader_Status
Possible statuses which may be returned by plugin loader API functions.
Definition: AWEPluginLoader.h:68
enum awe_PluginLoader_Status awe_PluginLoader_get(const AWEPlugin **plugin, size_t index)
Retrieve a loaded plugin by index.
Definition: PluginLoader.c:627
enum awe_PluginLoader_Status awe_PluginLoader_find(const AWEPlugin **plugin, const char *file)
Retrieve a loaded plugin by file name.
Definition: PluginLoader.c:657
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.
Definition: PluginLoader.c:573
enum awe_PluginLoader_Status awe_PluginLoader_init(size_t reserved_count)
Initialize the plugin loader.
Definition: PluginLoader.c:512
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.
Definition: PluginLoader.c:473
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.
Definition: PluginLoader.c:568
enum awe_PluginLoader_Status awe_PluginLoader_unload(const char *file)
Unload a plugin library.
Definition: PluginLoader.c:578
void awe_PluginLoader_free()
Clean up the plugin loader.
Definition: PluginLoader.c:691
const char * awe_PluginLoader_statusToString(const enum awe_PluginLoader_Status status)
Get a description of the given status.
Definition: PluginLoader.c:706
@ AWE_PLUGIN_LOADER_DL_OPEN_FAILED
Failed to open the dynamic library.
Definition: AWEPluginLoader.h:75
@ AWE_PLUGIN_LOADER_UNINITIALIZED
Plugin loader is uninitialized.
Definition: AWEPluginLoader.h:70
@ AWE_PLUGIN_LOADER_INVALID_INDEX
Plugin index is out of range.
Definition: AWEPluginLoader.h:74
@ AWE_PLUGIN_LOADER_MISSING_METHOD
A required method is missing after applying overrides (this can happen when the library was not compi...
Definition: AWEPluginLoader.h:72
@ AWE_PLUGIN_LOADER_ALREADY_INITIALIZED
Attempting to initialize the plugin loader after it has already been initialized.
Definition: AWEPluginLoader.h:71
@ AWE_PLUGIN_LOADER_DL_INTERNAL_FAILURE
The plugin library's initialization function returned null.
Definition: AWEPluginLoader.h:77
@ AWE_PLUGIN_LOADER_SUCCESS
Operation succeeded.
Definition: AWEPluginLoader.h:69
@ AWE_PLUGIN_LOADER_DL_SYMBOL_NOT_FOUND
Initialization function was not found in the plugin library.
Definition: AWEPluginLoader.h:76
@ AWE_PLUGIN_LOADER_ALLOCATION_FAILED
Memory allocation failed.
Definition: AWEPluginLoader.h:73
Method table to provide overrides to awe_PluginLoader_initWithMethods.
Definition: AWEPluginLoader.h:54
void(* vlog)(int32_t level, uint32_t type, const char *fmt, va_list args)
Handle a log message.
Definition: AWEPluginLoader.h:61
void(* close)(void *handle)
Close a shared library.
Definition: AWEPluginLoader.h:59
void(* free)(void *ptr)
Free memory.
Definition: AWEPluginLoader.h:57
A struct encapsulating the functionality which can be provided by a plugin library.
Definition: AWEPluginTypes.h:81