AWE Core OS 8.B.23 Documentation
Loading...
Searching...
No Matches
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
45#ifndef AWE_PLUGIN_LOADER_MAX_PATH_LENGTH
49#define AWE_PLUGIN_LOADER_MAX_PATH_LENGTH (1024)
50#endif /* AWE_PLUGIN_LOADER_MAX_PATH_LENGTH */
51
61{
62 void* (*malloc)(size_t size);
63 void* (*realloc)(void* ptr, size_t size);
64 void (*free)(void* ptr);
65 void* (*open)(const char* file);
66 void (*close)(void* handle);
67 void* (*sym)(void* handle, const char* name);
68 void (*vlog)(int32_t level, uint32_t type, const char* fmt, va_list args);
70
87
88#ifdef __cplusplus
89extern "C" {
90#endif /* __cplusplus */
91
101enum awe_PluginLoader_Status awe_PluginLoader_init(size_t reserved_count);
102
117enum awe_PluginLoader_Status awe_PluginLoader_initWithMethods(size_t reserved_count, const awe_PluginLoaderMethods* const overrides);
118
133enum awe_PluginLoader_Status awe_PluginLoader_load(const AWEPlugin** plugin, const char* file);
134
151
168enum awe_PluginLoader_Status awe_PluginLoader_loadWithNamespacePrefix(const AWEPlugin** plugin, const char* file, const char* prefix);
169
185enum awe_PluginLoader_Status awe_PluginLoader_loadWithEntrypoint(const AWEPlugin** plugin, const char* file, const char* entrypoint);
186
195
212enum awe_PluginLoader_Status awe_PluginLoader_get(const AWEPlugin** plugin, size_t index);
213
228enum awe_PluginLoader_Status awe_PluginLoader_find(const AWEPlugin** plugin, const char* file);
229
230
245
254const char* awe_PluginLoader_statusToString(const enum awe_PluginLoader_Status status);
255
256#ifdef __cplusplus
257}
258#endif /* __cplusplus */
259
262#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:588
size_t awe_PluginLoader_count()
Get the number of currently loaded plugins.
Definition PluginLoader.c:645
awe_PluginLoader_Status
Possible statuses which may be returned by plugin loader API functions.
Definition AWEPluginLoader.h:75
enum awe_PluginLoader_Status awe_PluginLoader_get(const AWEPlugin **plugin, size_t index)
Retrieve a loaded plugin by index.
Definition PluginLoader.c:655
enum awe_PluginLoader_Status awe_PluginLoader_find(const AWEPlugin **plugin, const char *file)
Retrieve a loaded plugin by file name.
Definition PluginLoader.c:685
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:598
enum awe_PluginLoader_Status awe_PluginLoader_init(size_t reserved_count)
Initialize the plugin loader.
Definition PluginLoader.c:531
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:492
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:593
enum awe_PluginLoader_Status awe_PluginLoader_unload(const char *file)
Unload a plugin library.
Definition PluginLoader.c:603
void awe_PluginLoader_free()
Clean up the plugin loader.
Definition PluginLoader.c:724
const char * awe_PluginLoader_statusToString(const enum awe_PluginLoader_Status status)
Get a description of the given status.
Definition PluginLoader.c:739
@ AWE_PLUGIN_LOADER_DL_OPEN_FAILED
Failed to open the dynamic library.
Definition AWEPluginLoader.h:82
@ AWE_PLUGIN_LOADER_UNINITIALIZED
Plugin loader is uninitialized.
Definition AWEPluginLoader.h:77
@ AWE_PLUGIN_LOADER_INVALID_INDEX
Plugin index is out of range.
Definition AWEPluginLoader.h:81
@ 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:79
@ AWE_PLUGIN_LOADER_ALREADY_INITIALIZED
Attempting to initialize the plugin loader after it has already been initialized.
Definition AWEPluginLoader.h:78
@ AWE_PLUGIN_LOADER_LIBRARY_FILE_NAME_TOO_LONG
The plugin loader was provided with a file name which is longer than AWE_PLUGIN_LOADER_MAX_PATH_LENGT...
Definition AWEPluginLoader.h:85
@ AWE_PLUGIN_LOADER_DL_INTERNAL_FAILURE
The plugin library's initialization function returned null.
Definition AWEPluginLoader.h:84
@ AWE_PLUGIN_LOADER_SUCCESS
Operation succeeded.
Definition AWEPluginLoader.h:76
@ AWE_PLUGIN_LOADER_DL_SYMBOL_NOT_FOUND
Initialization function was not found in the plugin library.
Definition AWEPluginLoader.h:83
@ AWE_PLUGIN_LOADER_ALLOCATION_FAILED
Memory allocation failed.
Definition AWEPluginLoader.h:80
Method table to provide overrides to awe_PluginLoader_initWithMethods.
Definition AWEPluginLoader.h:61
void(* vlog)(int32_t level, uint32_t type, const char *fmt, va_list args)
Handle a log message.
Definition AWEPluginLoader.h:68
void(* close)(void *handle)
Close a shared library.
Definition AWEPluginLoader.h:66
void(* free)(void *ptr)
Free memory.
Definition AWEPluginLoader.h:64
A struct encapsulating the functionality which can be provided by a plugin library.
Definition AWEPluginTypes.h:81