/*
- * JACK Rack
- *
- * Copyright (C) Robert Ham 2002, 2003 (node@users.sourceforge.net)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * JACK Rack
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Original:
+ * Copyright (C) Robert Ham 2002, 2003 (node@users.sourceforge.net)
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Modification for MLT:
+ * Copyright (C) 2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include "jack_rack.h"
#include "lock_free_fifo.h"
-#include "control_message.h"
-#include "ui.h"
#include "plugin_settings.h"
#ifndef _
#define _(x) x
#endif
+#define _x (const xmlChar*)
+#define _s (const char*)
jack_rack_t *
-jack_rack_new (ui_t * ui, unsigned long channels)
+jack_rack_new (const char * client_name, unsigned long channels)
{
jack_rack_t *rack;
rack = g_malloc (sizeof (jack_rack_t));
rack->saved_plugins = NULL;
- rack->ui = ui;
rack->channels = channels;
+ rack->procinfo = process_info_new (client_name, channels, FALSE, FALSE);
+ if (!rack->procinfo) {
+ g_free (rack);
+ return NULL;
+ }
+ rack->plugin_mgr = plugin_mgr_new ();
+ plugin_mgr_set_plugins (rack->plugin_mgr, channels);
return rack;
}
void
jack_rack_destroy (jack_rack_t * jack_rack)
{
+ process_quit (jack_rack->procinfo);
+ plugin_mgr_destroy (jack_rack->plugin_mgr);
+ process_info_destroy (jack_rack->procinfo);
+ g_slist_free (jack_rack->saved_plugins);
g_free (jack_rack);
}
return plugin;
}
-void
-jack_rack_send_add_plugin (jack_rack_t * jack_rack, plugin_desc_t * desc)
-{
- plugin_t * plugin;
- ctrlmsg_t ctrlmsg;
-
- plugin = jack_rack_instantiate_plugin (jack_rack, desc);
-
- if (!plugin)
- return;
-
- /* send the chain link off to the process() callback */
- ctrlmsg.type = CTRLMSG_ADD;
- ctrlmsg.data.add.plugin = plugin;
- lff_write (jack_rack->ui->ui_to_process, &ctrlmsg);
-}
void
jack_rack_add_saved_plugin (jack_rack_t * jack_rack, saved_plugin_t * saved_plugin)
{
+ plugin_t * plugin = jack_rack_instantiate_plugin (jack_rack, saved_plugin->settings->desc);
+ if (!plugin)
+ return;
jack_rack->saved_plugins = g_slist_append (jack_rack->saved_plugins, saved_plugin);
-
- jack_rack_send_add_plugin (jack_rack, saved_plugin->settings->desc);
+ process_add_plugin (jack_rack->procinfo, plugin);
+ jack_rack_add_plugin (jack_rack, plugin);
}
static void
-saved_rack_parse_plugin (saved_rack_t * saved_rack, saved_plugin_t * saved_plugin,
- ui_t * ui, const char * filename, xmlNodePtr plugin)
+saved_rack_parse_plugin (jack_rack_t * jack_rack, saved_rack_t * saved_rack, saved_plugin_t * saved_plugin,
+ const char * filename, xmlNodePtr plugin)
{
plugin_desc_t * desc;
settings_t * settings = NULL;
for (node = plugin->children; node; node = node->next)
{
- if (strcmp (node->name, "id") == 0)
+ if (xmlStrcmp (node->name, _x("id")) == 0)
{
content = xmlNodeGetContent (node);
- num = strtoul (content, NULL, 10);
+ num = strtoul (_s(content), NULL, 10);
xmlFree (content);
- desc = plugin_mgr_get_any_desc (ui->plugin_mgr, num);
+ desc = plugin_mgr_get_any_desc (jack_rack->plugin_mgr, num);
if (!desc)
{
fprintf (stderr, _("The file '%s' contains an unknown plugin with ID '%ld'; skipping\n"), filename, num);
settings = settings_new (desc, saved_rack->channels, saved_rack->sample_rate);
}
- else if (strcmp (node->name, "enabled") == 0)
+ else if (xmlStrcmp (node->name, _x("enabled")) == 0)
{
content = xmlNodeGetContent (node);
- settings_set_enabled (settings, strcmp (content, "true") == 0 ? TRUE : FALSE);
+ settings_set_enabled (settings, xmlStrcmp (content, _x("true")) == 0 ? TRUE : FALSE);
xmlFree (content);
}
- else if (strcmp (node->name, "wet_dry_enabled") == 0)
+ else if (xmlStrcmp (node->name, _x("wet_dry_enabled")) == 0)
{
content = xmlNodeGetContent (node);
- settings_set_wet_dry_enabled (settings, strcmp (content, "true") == 0 ? TRUE : FALSE);
+ settings_set_wet_dry_enabled (settings, xmlStrcmp (content, _x("true")) == 0 ? TRUE : FALSE);
xmlFree (content);
}
- else if (strcmp (node->name, "wet_dry_locked") == 0)
+ else if (xmlStrcmp (node->name, _x("wet_dry_locked")) == 0)
{
content = xmlNodeGetContent (node);
- settings_set_wet_dry_locked (settings, strcmp (content, "true") == 0 ? TRUE : FALSE);
+ settings_set_wet_dry_locked (settings, xmlStrcmp (content, _x("true")) == 0 ? TRUE : FALSE);
xmlFree (content);
}
- else if (strcmp (node->name, "wet_dry_values") == 0)
+ else if (xmlStrcmp (node->name, _x("wet_dry_values")) == 0)
{
unsigned long channel = 0;
for (sub_node = node->children; sub_node; sub_node = sub_node->next)
{
- if (strcmp (sub_node->name, "value") == 0)
+ if (xmlStrcmp (sub_node->name, _x("value")) == 0)
{
content = xmlNodeGetContent (sub_node);
- settings_set_wet_dry_value (settings, channel, strtod (content, NULL));
+ settings_set_wet_dry_value (settings, channel, strtod (_s(content), NULL));
xmlFree (content);
channel++;
}
}
}
- else if (strcmp (node->name, "lockall") == 0)
+ else if (xmlStrcmp (node->name, _x("lockall")) == 0)
{
content = xmlNodeGetContent (node);
- settings_set_lock_all (settings, strcmp (content, "true") == 0 ? TRUE : FALSE);
+ settings_set_lock_all (settings, xmlStrcmp (content, _x("true")) == 0 ? TRUE : FALSE);
xmlFree (content);
}
- else if (strcmp (node->name, "controlrow") == 0)
+ else if (xmlStrcmp (node->name, _x("controlrow")) == 0)
{
gint copy = 0;
for (sub_node = node->children; sub_node; sub_node = sub_node->next)
{
- if (strcmp (sub_node->name, "lock") == 0)
+ if (xmlStrcmp (sub_node->name, _x("lock")) == 0)
{
content = xmlNodeGetContent (sub_node);
- settings_set_lock (settings, control, strcmp (content, "true") == 0 ? TRUE : FALSE);
+ settings_set_lock (settings, control, xmlStrcmp (content, _x("true")) == 0 ? TRUE : FALSE);
xmlFree (content);
}
- else if (strcmp (sub_node->name, "value") == 0)
+ else if (xmlStrcmp (sub_node->name, _x("value")) == 0)
{
content = xmlNodeGetContent (sub_node);
- settings_set_control_value (settings, copy, control, strtod (content, NULL));
+ settings_set_control_value (settings, copy, control, strtod (_s(content), NULL));
xmlFree (content);
copy++;
}
}
static void
-saved_rack_parse_jackrack (saved_rack_t * saved_rack, ui_t * ui, const char * filename, xmlNodePtr jackrack)
+saved_rack_parse_jackrack (jack_rack_t * jack_rack, saved_rack_t * saved_rack, const char * filename, xmlNodePtr jackrack)
{
xmlNodePtr node;
xmlChar *content;
for (node = jackrack->children; node; node = node->next)
{
- if (strcmp (node->name, "channels") == 0)
+ if (xmlStrcmp (node->name, _x("channels")) == 0)
{
content = xmlNodeGetContent (node);
- saved_rack->channels = strtoul (content, NULL, 10);
+ saved_rack->channels = strtoul (_s(content), NULL, 10);
xmlFree (content);
}
- else if (strcmp (node->name, "samplerate") == 0)
+ else if (xmlStrcmp (node->name, _x("samplerate")) == 0)
{
content = xmlNodeGetContent (node);
- saved_rack->sample_rate = strtoul (content, NULL, 10);
+ saved_rack->sample_rate = strtoul (_s(content), NULL, 10);
xmlFree (content);
}
- else if (strcmp (node->name, "plugin") == 0)
+ else if (xmlStrcmp (node->name, _x("plugin")) == 0)
{
saved_plugin = g_malloc0 (sizeof (saved_plugin_t));
saved_rack->plugins = g_slist_append (saved_rack->plugins, saved_plugin);
- saved_rack_parse_plugin (saved_rack, saved_plugin, ui, filename, node);
+ saved_rack_parse_plugin (jack_rack, saved_rack, saved_plugin, filename, node);
}
}
}
static saved_rack_t *
-saved_rack_new (ui_t * ui, const char * filename, xmlDocPtr doc)
+saved_rack_new (jack_rack_t * jack_rack, const char * filename, xmlDocPtr doc)
{
xmlNodePtr node;
saved_rack_t *saved_rack;
for (node = doc->children; node; node = node->next)
{
- if (strcmp (node->name, "jackrack") == 0)
- saved_rack_parse_jackrack (saved_rack, ui, filename, node);
+ if (xmlStrcmp (node->name, _x("jackrack")) == 0)
+ saved_rack_parse_jackrack (jack_rack, saved_rack, filename, node);
}
return saved_rack;
static void
saved_rack_destroy (saved_rack_t * saved_rack)
{
-/* GSList * list;*/
-
-/* for (list = saved_rack->settings; list; list = g_slist_next (list))
- settings_destroy ((settings_t *) list->data); */
-/* g_slist_free (saved_rack->settings); */
+ GSList * list;
+ for (list = saved_rack->plugins; list; list = g_slist_next (list))
+ settings_destroy (((saved_plugin_t *) list->data)->settings);
+ g_slist_free (saved_rack->plugins);
g_free (saved_rack);
}
int
-jack_rack_open_file (ui_t * ui, const char * filename)
+jack_rack_open_file (jack_rack_t * jack_rack, const char * filename)
{
xmlDocPtr doc;
saved_rack_t * saved_rack;
return 1;
}
- if (strcmp ( ((xmlDtdPtr)doc->children)->name, "jackrack") != 0)
+ if (xmlStrcmp ( ((xmlDtdPtr)doc->children)->name, _x("jackrack")) != 0)
{
fprintf (stderr, _("The file '%s' is not a JACK Rack settings file\n"), filename);
return 1;
}
- saved_rack = saved_rack_new (ui, filename, doc);
+ saved_rack = saved_rack_new (jack_rack, filename, doc);
xmlFreeDoc (doc);
if (!saved_rack)
settings_set_sample_rate (saved_plugin->settings, sample_rate);
- jack_rack_add_saved_plugin (ui->jack_rack, saved_plugin);
+ jack_rack_add_saved_plugin (jack_rack, saved_plugin);
}
- g_slist_free (saved_rack->plugins);
- g_free (saved_rack);
+ saved_rack_destroy (saved_rack);
return 0;
}