AWE Core OS 8.B.22 Documentation
Functions
Creating a Plugin

Using the AudioWeaver Plugin API to create a dynamically loadable list of modules. More...

Functions

const AWEPluginAWEPlugin_initialize (const awe_PluginCallbacks *methods)
 AWEPlugin entrypoint method. More...
 

Detailed Description

Using the AudioWeaver Plugin API to create a dynamically loadable list of modules.

Plugins will typically be created as follows.

#include "Framework.h"
#include "ModulePackAweStandard.h"
#include "AWEPlugin.h"
static const ModClassModule *PLUGIN_MODULES[] = { LISTOFCLASSOBJECTS };
static const AWEPlugin ModulePackAweStandardPlugin = {
.pluginVersion = NULL,
.name = "ModulePackAweStandard",
.modules = {
.count = sizeof(PLUGIN_MODULES) / sizeof(PLUGIN_MODULES[0]),
.array = PLUGIN_MODULES,
},
.cleanup = NULL,
};
{
const AWEPlugin *plugin = NULL;
if ((callbacks != NULL) && callbacks->checkApiVersion(AWE_PLUGIN_API_VERSION))
{
plugin = &ModulePackAweStandardPlugin;
}
return plugin;
}
AudioWeaver Plugin API.
const AWEPlugin * AWEPlugin_initialize(const awe_PluginCallbacks *methods)
AWEPlugin entrypoint method.
#define AWE_PLUGIN_API_VERSION
Version of the AudioWeaver Plugin API.
Definition: AWEPluginTypes.h:52
A struct encapsulating the functionality which can be provided by a plugin library.
Definition: AWEPluginTypes.h:81
const char * apiVersion
API version that this plugin was built with.
Definition: AWEPluginTypes.h:87
Callbacks passed by the loader to each plugin entrypoint.
Definition: AWEPluginTypes.h:126
bool(* checkApiVersion)(const char *version)
Used to verify compatibility with the loader's API version.
Definition: AWEPluginTypes.h:127

In this example, the plugin struct is a static variable, but it can also be allocated dynamically. In that case, the memory should be freed in the plugin's cleanup function.

For information on how to load these plugins, see Loading a Plugin.

Function Documentation

◆ AWEPlugin_initialize()

const AWEPlugin * AWEPlugin_initialize ( const awe_PluginCallbacks methods)

AWEPlugin entrypoint method.

A valid AWE Plugin must implement this method with external linkage. The loader will call it after opening the dynamic library to initialize the plugin. The loader takes ownership of the returned pointer in the sense that it will call its cleanup method when the loader's internal plugin list is freed, however it will not actually call free on the returned pointer directly. This is because many plugins will not need to dynamically allocate their AWEPlugin struct.

Parameters
[in]methodsCallbacks which the plugin entrypoint method may use during initialization.
See also
awe_PluginCallbacks