-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin_handler.c
More file actions
58 lines (46 loc) · 1.34 KB
/
plugin_handler.c
File metadata and controls
58 lines (46 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "plugin_handler.h"
#define MAX_PLUGINS 10
Plugin_t *registeredPlugins[MAX_PLUGINS];
int plugin_count = 0;
int registerPluginToChain(Plugin_t *pluginToRegister)
{
if (plugin_count >= MAX_PLUGINS)
{
printf("Error: Plugin Chain is full.");
return -1;
}
registeredPlugins[plugin_count] = pluginToRegister;
/* Return index where plugin was registered */
return plugin_count++;
}
int initAllPlugins(double sampleRate, int numChannels)
{
for (uint16_t i = 0; i < plugin_count; i++)
{
Plugin_t *nextPluginToInitialise = registeredPlugins[i];
printf("Initialising plugin: %s\n", nextPluginToInitialise->name);
if (nextPluginToInitialise->init(sampleRate,
numChannels) != 0)
{
printf("Failed to initialise plugin.\n");
return -1;
}
}
return 0;
}
int processPluginChain(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer)
{
for (uint16_t i = 0; i < plugin_count; i++)
{
Plugin_t *nextPluginToProcessWith = registeredPlugins[i];
if (nextPluginToProcessWith == NULL)
{
return -1;
}
nextPluginToProcessWith->process(inputBuffer, outputBuffer, framesPerBuffer);
}
return 0;
}
void shutdownAllPlugins(void)
{
}