Apply ldflags-order part of ldflags_order patch from Alberto Villa.
[melted] / src / modules / jackrack / plugin.c
index 753910b..6a483a8 100644 (file)
@@ -1,21 +1,26 @@
 /*
- *   jack-ladspa-host
- *    
- *   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>
@@ -29,7 +34,6 @@
 #include "plugin.h"
 #include "jack_rack.h"
 #include "process.h"
-#include "ui.h"
 
 #define CONTROL_FIFO_SIZE   128
 
@@ -138,7 +142,7 @@ process_remove_plugin (process_info_t * procinfo, plugin_t *plugin)
     procinfo->chain_end = plugin->prev;
     
   /* sort out the aux ports */
-  if (plugin->desc->aux_channels > 0)
+  if (procinfo->jack_client && plugin->desc->aux_channels > 0)
     {
       plugin_t * other;
       
@@ -227,7 +231,7 @@ process_move_plugin (process_info_t * procinfo, plugin_t *plugin, gint up)
        procinfo->chain_end = plugin;
     }
   
-  if (plugin->desc->aux_channels > 0)
+  if (procinfo->jack_client && plugin->desc->aux_channels > 0)
     {
       plugin_t * other;
       other = up ? plugin->next : plugin->prev;
@@ -257,7 +261,7 @@ process_change_plugin (process_info_t * procinfo,
     procinfo->chain_end = new_plugin;
 
   /* sort out the aux ports */
-  if (plugin->desc->aux_channels > 0)
+  if (procinfo->jack_client && plugin->desc->aux_channels > 0)
     {
       plugin_t * other;
       
@@ -392,7 +396,7 @@ plugin_create_aux_ports (plugin_t * plugin, guint copy, jack_rack_t * jack_rack)
                aux_channel);
       
       holder->aux_ports[i] =
-        jack_port_register (jack_rack->ui->procinfo->jack_client,
+        jack_port_register (jack_rack->procinfo->jack_client,
                             port_name,
                             JACK_DEFAULT_AUDIO_TYPE,
                             desc->aux_are_input ? JackPortIsInput : JackPortIsOutput,
@@ -455,7 +459,7 @@ plugin_init_holder (plugin_t * plugin,
         plugin->descriptor-> connect_port (instance, i, &unused_control_port_output);
     }
   
-  if (plugin->desc->aux_channels > 0)
+  if (jack_rack->procinfo->jack_client && plugin->desc->aux_channels > 0)
     plugin_create_aux_ports (plugin, copy, jack_rack);
   
   if (plugin->descriptor->activate)
@@ -502,6 +506,7 @@ plugin_new (plugin_desc_t * desc, jack_rack_t * jack_rack)
   plugin->next = NULL;
   plugin->prev = NULL;
   plugin->wet_dry_enabled = FALSE;
+  plugin->jack_rack = jack_rack;
   
   /* create audio memory and wet/dry stuff */
   plugin->audio_output_memory   = g_malloc (sizeof (LADSPA_Data *) * jack_rack->channels);
@@ -525,7 +530,7 @@ plugin_new (plugin_desc_t * desc, jack_rack_t * jack_rack)
 
 
 void
-plugin_destroy (plugin_t * plugin, ui_t *ui)
+plugin_destroy (plugin_t * plugin)
 {
   unsigned long i, j;
   int err;
@@ -550,11 +555,11 @@ plugin_destroy (plugin_t * plugin, ui_t *ui)
         }
       
       /* aux ports */
-      if (plugin->desc->aux_channels > 0)
+      if (plugin->jack_rack->procinfo->jack_client && plugin->desc->aux_channels > 0)
         {
           for (j = 0; j < plugin->desc->aux_channels; j++)
             {
-              err = jack_port_unregister (ui->procinfo->jack_client,
+              err = jack_port_unregister (plugin->jack_rack->procinfo->jack_client,
                                           plugin->holders[i].aux_ports[j]);
           
               if (err)
@@ -567,7 +572,7 @@ plugin_destroy (plugin_t * plugin, ui_t *ui)
     
   g_free (plugin->holders);
   
-  for (i = 0; i < ui->jack_rack->channels; i++)
+  for (i = 0; i < plugin->jack_rack->channels; i++)
     {
       g_free (plugin->audio_output_memory[i]);
       lff_free (plugin->wet_dry_fifos + i);