Permalink
Browse files

add a destroy method to the plugin structure, to allow plugin handles…

… (not just

instances) to be destroyed


git-svn-id: http://svn.metadecks.org/libremix/trunk@339 e2d53364-18fc-0310-981e-b60a84739af0
  • Loading branch information...
1 parent 55329a5 commit 4498d14d5fbc33238291a251f4bdde63d38f9133 conrad committed Jan 30, 2006
@@ -82,6 +82,7 @@ typedef RemixOpaque RemixMonitor;
typedef CDList * (*RemixPluginInitFunc) (RemixEnv * env);
+typedef int (*RemixPluginDestroyFunc) (RemixEnv * env, RemixPlugin * plugin);
typedef RemixBase * (*RemixInitFunc) (RemixEnv * env, RemixBase * base,
CDSet * parameters);
@@ -187,6 +188,7 @@ struct _RemixPlugin {
CDSet * process_scheme;
RemixSuggestFunc suggest;
void * plugin_data;
+ RemixPluginDestroyFunc destroy;
};
struct _RemixMethods {
@@ -32,12 +32,24 @@
#include "remix.h"
static void
+remix_plugin_destroy (RemixEnv * env, RemixPlugin * plugin)
+{
+ if (plugin->destroy) {
+ plugin->destroy (env, plugin);
+ }
+}
+
+static void
remix_context_destroy (RemixEnv * env)
{
RemixContext * ctx = env->context;
RemixWorld * world = env->world;
world->purging = 1;
+
+ cd_list_apply (env, world->plugins, (CDFunc)remix_plugin_destroy);
+ world->plugins = cd_list_free (env, world->plugins);
+
/* XXX: remix_destroy_list (env, world->plugins); */
/* XXX: remix_destroy_list (env, world->bases); */
remix_channelset_defaults_destroy (env);
@@ -179,6 +179,13 @@ remix_gain_optimise (RemixEnv * env, RemixBase * gain)
return gain;
}
+static int
+remix_gain_plugin_destroy (RemixEnv * env, RemixPlugin * plugin)
+{
+ cd_set_free (env, plugin->process_scheme);
+ return 0;
+}
+
static struct _RemixParameterScheme gain_envelope_scheme = {
"Gain envelope",
"An envelope to control the amplitude",
@@ -205,6 +212,7 @@ static struct _RemixPlugin gain_plugin = {
CD_EMPTY_SET, /* process_scheme */
NULL, /* suggests */
NULL, /* plugin_data */
+ remix_gain_plugin_destroy /* destroy */
};
/* module init function */
@@ -386,6 +386,7 @@ static struct _RemixPlugin sndfile_reader_plugin = {
CD_EMPTY_SET, /* process scheme */
NULL, /* suggests */
NULL, /* plugin data */
+ NULL /* destroy */
};
static struct _RemixPlugin sndfile_writer_plugin = {
@@ -396,6 +397,7 @@ static struct _RemixPlugin sndfile_writer_plugin = {
CD_EMPTY_SET, /* process scheme */
NULL, /* suggests */
NULL, /* plugin data */
+ NULL /* destroy */
};
/* module init function */
@@ -931,6 +931,8 @@ ladspa_wrapper_load_plugins (RemixEnv * env, char * dir, char * name)
plugin->plugin_data = (void *)d;
+ plugin->destroy = NULL;
+
plugins = cd_list_append (env, plugins, CD_POINTER(plugin));
}
}
@@ -128,6 +128,7 @@ static struct _RemixPlugin noise_plugin = {
CD_EMPTY_SET, /* process scheme */
NULL, /* suggests */
NULL, /* plugin data */
+ NULL /* destroy */
};
CDList *

0 comments on commit 4498d14

Please sign in to comment.