2001-12-23 15:26:43 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* <2001> Steve Baker <stevebaker_org@yahoo.co.uk>
|
2003-12-04 10:37:38 +00:00
|
|
|
* 2003 Andy Wingo <wingo at pobox.com>
|
2001-12-23 15:26:43 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-11-06 23:36:33 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-23 15:26:43 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
2003-07-19 23:25:25 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
#include "gstladspa.h"
|
2004-03-15 19:32:27 +00:00
|
|
|
#include <ladspa.h> /* main ladspa sdk include file */
|
|
|
|
#include "utils.h" /* ladspa sdk utility functions */
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2003-12-04 10:37:38 +00:00
|
|
|
/* 1.0 and the 1.1 preliminary headers don't define a version, but 1.1 final
|
|
|
|
does */
|
|
|
|
#ifndef LADSPA_VERSION
|
|
|
|
#define LADSPA_VERSION "1.0"
|
|
|
|
#endif
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticCaps ladspa_pad_caps =
|
|
|
|
GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_ladspa_class_init (GstLADSPAClass * klass);
|
|
|
|
static void gst_ladspa_base_init (GstLADSPAClass * klass);
|
|
|
|
static void gst_ladspa_init (GstLADSPA * ladspa);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_ladspa_update_int (const GValue * value, gpointer data);
|
|
|
|
static GstPadLinkReturn gst_ladspa_link (GstPad * pad, const GstCaps * caps);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_ladspa_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_ladspa_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static gboolean gst_ladspa_instantiate (GstLADSPA * ladspa);
|
|
|
|
static void gst_ladspa_activate (GstLADSPA * ladspa);
|
|
|
|
static void gst_ladspa_deactivate (GstLADSPA * ladspa);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstElementStateReturn gst_ladspa_change_state (GstElement * element);
|
|
|
|
static void gst_ladspa_loop (GstElement * element);
|
|
|
|
static void gst_ladspa_chain (GstPad * pad, GstData * _data);
|
|
|
|
static GstData *gst_ladspa_get (GstPad * pad);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
|
|
|
static GstPlugin *ladspa_plugin;
|
|
|
|
static GHashTable *ladspa_descriptors;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-07-19 23:25:25 +00:00
|
|
|
ARG_0,
|
|
|
|
ARG_SAMPLERATE,
|
|
|
|
ARG_BUFFERSIZE,
|
2004-05-21 23:28:57 +00:00
|
|
|
ARG_LAST
|
2003-07-19 23:25:25 +00:00
|
|
|
};
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (ladspa_debug);
|
2004-04-05 17:32:43 +00:00
|
|
|
#define GST_CAT_DEFAULT ladspa_debug
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2003-11-02 13:55:40 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_base_init (GstLADSPAClass * klass)
|
2003-11-02 13:55:40 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
GstPadTemplate *templ;
|
|
|
|
GstElementDetails *details;
|
|
|
|
LADSPA_Descriptor *desc;
|
2004-03-14 22:34:33 +00:00
|
|
|
gint j, sinkcount, srccount;
|
2003-11-02 13:55:40 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
desc = g_hash_table_lookup (ladspa_descriptors,
|
|
|
|
GINT_TO_POINTER (G_TYPE_FROM_CLASS (klass)));
|
2003-11-02 23:58:20 +00:00
|
|
|
if (!desc)
|
2004-03-14 22:34:33 +00:00
|
|
|
desc = g_hash_table_lookup (ladspa_descriptors, GINT_TO_POINTER (0));
|
2003-11-02 23:58:20 +00:00
|
|
|
g_assert (desc);
|
2003-11-02 13:55:40 +00:00
|
|
|
|
|
|
|
/* pad templates */
|
|
|
|
klass->numports = desc->PortCount;
|
|
|
|
klass->numsinkpads = 0;
|
|
|
|
klass->numsrcpads = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
for (j = 0; j < desc->PortCount; j++) {
|
|
|
|
if (LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[j])) {
|
|
|
|
gchar *name = g_strdup ((gchar *) desc->PortNames[j]);
|
|
|
|
|
2003-11-02 13:55:40 +00:00
|
|
|
g_strcanon (name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
|
|
|
|
|
|
|
|
/* the factories take ownership of the name */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[j])) {
|
2004-03-15 19:32:27 +00:00
|
|
|
templ = gst_pad_template_new (name, GST_PAD_SINK, GST_PAD_ALWAYS,
|
|
|
|
gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps)));
|
|
|
|
klass->numsinkpads++;
|
2003-11-02 13:55:40 +00:00
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
templ = gst_pad_template_new (name, GST_PAD_SRC, GST_PAD_ALWAYS,
|
|
|
|
gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps)));
|
|
|
|
klass->numsrcpads++;
|
2003-11-02 13:55:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class, templ);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-12 18:18:51 +00:00
|
|
|
/* construct the element details struct */
|
2004-03-14 22:34:33 +00:00
|
|
|
details = g_new0 (GstElementDetails, 1);
|
2004-07-19 21:44:49 +00:00
|
|
|
details->longname = g_locale_to_utf8 (desc->Name, -1, NULL, NULL, NULL);
|
|
|
|
if (!details->longname)
|
|
|
|
details->longname = g_strdup ("no description available");
|
2004-02-12 18:18:51 +00:00
|
|
|
details->description = details->longname;
|
2004-07-19 21:44:49 +00:00
|
|
|
details->author = g_locale_to_utf8 (desc->Maker, -1, NULL, NULL, NULL);
|
|
|
|
if (!details->author)
|
|
|
|
details->author = g_strdup ("no author available");
|
2004-03-14 22:34:33 +00:00
|
|
|
if ((klass->numsinkpads > 0) && (klass->numsrcpads > 0))
|
|
|
|
details->klass = "Filter/Effect/Audio/LADSPA";
|
|
|
|
else if ((klass->numsinkpads == 0) && (klass->numsrcpads > 0))
|
|
|
|
details->klass = "Source/Audio/LADSPA";
|
|
|
|
else if ((klass->numsinkpads > 0) && (klass->numsrcpads == 0))
|
|
|
|
details->klass = "Sink/Audio/LADSPA";
|
|
|
|
else
|
2004-03-15 19:32:27 +00:00
|
|
|
details->klass = "Filter/Effect/Audio/LADSPA"; /* whatever this is */
|
2004-02-12 18:18:51 +00:00
|
|
|
gst_element_class_set_details (element_class, details);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
klass->srcpad_portnums = g_new0 (gint, klass->numsrcpads);
|
|
|
|
klass->sinkpad_portnums = g_new0 (gint, klass->numsinkpads);
|
2003-11-02 13:55:40 +00:00
|
|
|
sinkcount = 0;
|
|
|
|
srccount = 0;
|
|
|
|
|
|
|
|
/* walk through the ports, note the portnums for srcpads, sinkpads */
|
2004-03-14 22:34:33 +00:00
|
|
|
for (j = 0; j < desc->PortCount; j++) {
|
|
|
|
if (LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[j])) {
|
|
|
|
if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[j]))
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->sinkpad_portnums[sinkcount++] = j;
|
2003-11-02 13:55:40 +00:00
|
|
|
else
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->srcpad_portnums[srccount++] = j;
|
2003-11-02 13:55:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
klass->descriptor = desc;
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_class_init (GstLADSPAClass * klass)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
LADSPA_Descriptor *desc;
|
2004-03-14 22:34:33 +00:00
|
|
|
gint i, current_portnum, controlcount;
|
2001-12-23 15:26:43 +00:00
|
|
|
gint hintdesc;
|
2004-03-14 22:34:33 +00:00
|
|
|
gint argtype, argperms;
|
2001-12-23 15:26:43 +00:00
|
|
|
GParamSpec *paramspec = NULL;
|
2002-01-22 04:42:11 +00:00
|
|
|
gchar *argname, *tempstr, *paren;
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_ladspa_set_property;
|
|
|
|
gobject_class->get_property = gst_ladspa_get_property;
|
|
|
|
|
|
|
|
gstelement_class->change_state = gst_ladspa_change_state;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* look up and store the ladspa descriptor */
|
2004-03-14 22:34:33 +00:00
|
|
|
desc = g_hash_table_lookup (ladspa_descriptors,
|
|
|
|
GINT_TO_POINTER (G_TYPE_FROM_CLASS (klass)));
|
2003-11-02 23:58:20 +00:00
|
|
|
if (!desc)
|
2004-03-14 22:34:33 +00:00
|
|
|
desc = g_hash_table_lookup (ladspa_descriptors, GINT_TO_POINTER (0));
|
2003-11-02 23:58:20 +00:00
|
|
|
g_assert (desc);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
klass->numcontrols = 0;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* walk through the ports, count the input, output and control ports */
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0; i < desc->PortCount; i++) {
|
|
|
|
if (!LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[i]) &&
|
2004-03-15 19:32:27 +00:00
|
|
|
LADSPA_IS_PORT_INPUT (desc->PortDescriptors[i]))
|
2001-12-23 15:26:43 +00:00
|
|
|
klass->numcontrols++;
|
|
|
|
}
|
|
|
|
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG ("ladspa element class: init %s with %d sink, %d src, %d control\n",
|
2004-03-14 22:34:33 +00:00
|
|
|
g_type_name (G_TYPE_FROM_CLASS (klass)),
|
|
|
|
klass->numsinkpads, klass->numsrcpads, klass->numcontrols);
|
2003-07-16 16:08:13 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
klass->control_portnums = g_new0 (gint, klass->numcontrols);
|
2001-12-23 15:26:43 +00:00
|
|
|
controlcount = 0;
|
|
|
|
|
2003-11-02 13:55:40 +00:00
|
|
|
/* walk through the ports, note the portnums for control params */
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0; i < desc->PortCount; i++) {
|
|
|
|
if (!LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[i]) &&
|
2004-03-15 19:32:27 +00:00
|
|
|
LADSPA_IS_PORT_INPUT (desc->PortDescriptors[i]))
|
2001-12-23 15:26:43 +00:00
|
|
|
klass->control_portnums[controlcount++] = i;
|
|
|
|
}
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
/* now build the control info from the control ports */
|
2004-03-14 22:34:33 +00:00
|
|
|
klass->control_info = g_new0 (ladspa_control_info, klass->numcontrols);
|
|
|
|
|
|
|
|
for (i = 0; i < klass->numcontrols; i++) {
|
2001-12-23 15:26:43 +00:00
|
|
|
current_portnum = klass->control_portnums[i];
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* short name for hint descriptor */
|
2001-12-23 15:26:43 +00:00
|
|
|
hintdesc = desc->PortRangeHints[current_portnum].HintDescriptor;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* get the various bits */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (LADSPA_IS_HINT_TOGGLED (hintdesc))
|
2001-12-23 15:26:43 +00:00
|
|
|
klass->control_info[i].toggled = TRUE;
|
2004-03-14 22:34:33 +00:00
|
|
|
if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
|
2001-12-23 15:26:43 +00:00
|
|
|
klass->control_info[i].logarithmic = TRUE;
|
2004-03-14 22:34:33 +00:00
|
|
|
if (LADSPA_IS_HINT_INTEGER (hintdesc))
|
2001-12-23 15:26:43 +00:00
|
|
|
klass->control_info[i].integer = TRUE;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* figure out the argument details */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (klass->control_info[i].toggled)
|
|
|
|
argtype = G_TYPE_BOOLEAN;
|
|
|
|
else if (klass->control_info[i].integer)
|
|
|
|
argtype = G_TYPE_INT;
|
|
|
|
else
|
|
|
|
argtype = G_TYPE_FLOAT;
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* grab the bounds */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (LADSPA_IS_HINT_BOUNDED_BELOW (hintdesc)) {
|
2001-12-23 15:26:43 +00:00
|
|
|
klass->control_info[i].lower = TRUE;
|
|
|
|
klass->control_info[i].lowerbound =
|
2004-03-15 19:32:27 +00:00
|
|
|
desc->PortRangeHints[current_portnum].LowerBound;
|
2001-12-23 15:26:43 +00:00
|
|
|
} else {
|
2004-03-14 22:34:33 +00:00
|
|
|
if (argtype == G_TYPE_INT)
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->control_info[i].lowerbound = (gfloat) G_MININT;
|
2004-03-14 22:34:33 +00:00
|
|
|
if (argtype == G_TYPE_FLOAT)
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->control_info[i].lowerbound = -G_MAXFLOAT;
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
if (LADSPA_IS_HINT_BOUNDED_ABOVE (hintdesc)) {
|
2001-12-23 15:26:43 +00:00
|
|
|
klass->control_info[i].upper = TRUE;
|
|
|
|
klass->control_info[i].upperbound =
|
2004-03-15 19:32:27 +00:00
|
|
|
desc->PortRangeHints[current_portnum].UpperBound;
|
2004-03-14 22:34:33 +00:00
|
|
|
if (LADSPA_IS_HINT_SAMPLE_RATE (hintdesc)) {
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->control_info[i].samplerate = TRUE;
|
|
|
|
klass->control_info[i].upperbound *= 44100; /* FIXME? */
|
2003-07-16 16:08:13 +00:00
|
|
|
}
|
2001-12-23 15:26:43 +00:00
|
|
|
} else {
|
2004-03-14 22:34:33 +00:00
|
|
|
if (argtype == G_TYPE_INT)
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->control_info[i].upperbound = (gfloat) G_MAXINT;
|
2004-03-14 22:34:33 +00:00
|
|
|
if (argtype == G_TYPE_FLOAT)
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->control_info[i].upperbound = G_MAXFLOAT;
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
/* use the lowerbound as the default value */
|
2002-07-24 18:32:00 +00:00
|
|
|
klass->control_info[i].def = klass->control_info[i].lowerbound;
|
|
|
|
|
|
|
|
#ifdef LADSPA_IS_HINT_HAS_DEFAULT
|
|
|
|
/* figure out the defaults */
|
|
|
|
if (LADSPA_IS_HINT_HAS_DEFAULT (hintdesc)) {
|
|
|
|
if (LADSPA_IS_HINT_DEFAULT_MINIMUM (hintdesc))
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->control_info[i].def = klass->control_info[i].lowerbound;
|
2002-07-24 18:32:00 +00:00
|
|
|
else if (LADSPA_IS_HINT_DEFAULT_LOW (hintdesc))
|
2004-03-15 19:32:27 +00:00
|
|
|
if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
|
|
|
|
klass->control_info[i].def =
|
|
|
|
exp (0.75 * log (klass->control_info[i].lowerbound) +
|
|
|
|
0.25 * log (klass->control_info[i].upperbound));
|
|
|
|
else
|
|
|
|
klass->control_info[i].def =
|
|
|
|
(0.75 * klass->control_info[i].lowerbound +
|
|
|
|
0.25 * klass->control_info[i].upperbound);
|
2002-07-24 18:32:00 +00:00
|
|
|
else if (LADSPA_IS_HINT_DEFAULT_MIDDLE (hintdesc))
|
2004-03-15 19:32:27 +00:00
|
|
|
if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
|
|
|
|
klass->control_info[i].def =
|
|
|
|
exp (0.5 * log (klass->control_info[i].lowerbound) +
|
|
|
|
0.5 * log (klass->control_info[i].upperbound));
|
|
|
|
else
|
|
|
|
klass->control_info[i].def =
|
|
|
|
(0.5 * klass->control_info[i].lowerbound +
|
|
|
|
0.5 * klass->control_info[i].upperbound);
|
2002-07-24 18:32:00 +00:00
|
|
|
else if (LADSPA_IS_HINT_DEFAULT_HIGH (hintdesc))
|
2004-03-15 19:32:27 +00:00
|
|
|
if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
|
|
|
|
klass->control_info[i].def =
|
|
|
|
exp (0.25 * log (klass->control_info[i].lowerbound) +
|
|
|
|
0.75 * log (klass->control_info[i].upperbound));
|
|
|
|
else
|
|
|
|
klass->control_info[i].def =
|
|
|
|
(0.25 * klass->control_info[i].lowerbound +
|
|
|
|
0.75 * klass->control_info[i].upperbound);
|
2002-07-24 18:32:00 +00:00
|
|
|
else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM (hintdesc))
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->control_info[i].def = klass->control_info[i].upperbound;
|
2002-07-24 18:32:00 +00:00
|
|
|
else if (LADSPA_IS_HINT_DEFAULT_0 (hintdesc))
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->control_info[i].def = 0.0;
|
2002-07-24 18:32:00 +00:00
|
|
|
else if (LADSPA_IS_HINT_DEFAULT_1 (hintdesc))
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->control_info[i].def = 1.0;
|
2002-07-24 18:32:00 +00:00
|
|
|
else if (LADSPA_IS_HINT_DEFAULT_100 (hintdesc))
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->control_info[i].def = 100.0;
|
2002-07-24 18:32:00 +00:00
|
|
|
else if (LADSPA_IS_HINT_DEFAULT_440 (hintdesc))
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->control_info[i].def = 440.0;
|
2002-07-24 18:32:00 +00:00
|
|
|
}
|
|
|
|
#endif /* LADSPA_IS_HINT_HAS_DEFAULT */
|
2002-09-20 21:51:50 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
klass->control_info[i].def = CLAMP (klass->control_info[i].def,
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->control_info[i].lowerbound, klass->control_info[i].upperbound);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[current_portnum])) {
|
2001-12-23 15:26:43 +00:00
|
|
|
argperms = G_PARAM_READWRITE;
|
|
|
|
klass->control_info[i].writable = TRUE;
|
|
|
|
} else {
|
|
|
|
argperms = G_PARAM_READABLE;
|
|
|
|
klass->control_info[i].writable = FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
klass->control_info[i].name = g_strdup (desc->PortNames[current_portnum]);
|
|
|
|
argname = g_strdup (klass->control_info[i].name);
|
2002-01-22 04:42:11 +00:00
|
|
|
/* find out if there is a (unitname) at the end of the argname and get rid
|
|
|
|
of it */
|
|
|
|
paren = g_strrstr (argname, " (");
|
|
|
|
if (paren != NULL) {
|
|
|
|
*paren = '\0';
|
|
|
|
}
|
2002-01-10 01:17:29 +00:00
|
|
|
/* this is the same thing that param_spec_* will do */
|
2001-12-23 15:26:43 +00:00
|
|
|
g_strcanon (argname, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
|
2002-01-10 01:17:29 +00:00
|
|
|
/* satisfy glib2 (argname[0] must be [A-Za-z]) */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!((argname[0] >= 'a' && argname[0] <= 'z') || (argname[0] >= 'A'
|
2004-03-15 19:32:27 +00:00
|
|
|
&& argname[0] <= 'Z'))) {
|
2002-01-10 01:17:29 +00:00
|
|
|
tempstr = argname;
|
2004-03-14 22:34:33 +00:00
|
|
|
argname = g_strconcat ("param-", argname, NULL);
|
2002-01-10 01:17:29 +00:00
|
|
|
g_free (tempstr);
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-01-10 01:17:29 +00:00
|
|
|
/* check for duplicate property names */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (g_object_class_find_property (G_OBJECT_CLASS (klass), argname) != NULL) {
|
|
|
|
gint numarg = 1;
|
|
|
|
gchar *numargname = g_strdup_printf ("%s_%d", argname, numarg++);
|
|
|
|
|
|
|
|
while (g_object_class_find_property (G_OBJECT_CLASS (klass),
|
2004-03-15 19:32:27 +00:00
|
|
|
numargname) != NULL) {
|
|
|
|
g_free (numargname);
|
|
|
|
numargname = g_strdup_printf ("%s_%d", argname, numarg++);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
argname = numargname;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
klass->control_info[i].param_name = argname;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG ("adding arg %s from %s with access-mode=%d", argname,
|
|
|
|
klass->control_info[i].name, argperms);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
if (argtype == G_TYPE_BOOLEAN) {
|
|
|
|
paramspec =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_param_spec_boolean (argname, argname, argname, FALSE, argperms);
|
2004-03-14 22:34:33 +00:00
|
|
|
} else if (argtype == G_TYPE_INT) {
|
2004-04-05 17:32:43 +00:00
|
|
|
if (klass->control_info[i].lowerbound > klass->control_info[i].upperbound) {
|
|
|
|
gfloat swap;
|
|
|
|
|
|
|
|
GST_ERROR
|
|
|
|
(" wrong order of parameter bounds %f ... %f ... %f in \"%s\" plugin",
|
|
|
|
klass->control_info[i].lowerbound, klass->control_info[i].def,
|
|
|
|
klass->control_info[i].upperbound, klass->descriptor->Name);
|
|
|
|
|
|
|
|
swap = klass->control_info[i].upperbound;
|
|
|
|
klass->control_info[i].upperbound = klass->control_info[i].lowerbound;
|
|
|
|
klass->control_info[i].lowerbound = swap;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
paramspec = g_param_spec_int (argname, argname, argname,
|
2004-03-15 19:32:27 +00:00
|
|
|
(gint) klass->control_info[i].lowerbound,
|
|
|
|
(gint) klass->control_info[i].upperbound,
|
|
|
|
(gint) klass->control_info[i].def, argperms);
|
2004-03-14 22:34:33 +00:00
|
|
|
} else if (klass->control_info[i].samplerate) {
|
|
|
|
paramspec = g_param_spec_float (argname, argname, argname,
|
2004-03-15 19:32:27 +00:00
|
|
|
0.0, G_MAXFLOAT, 0.0, argperms);
|
2001-12-23 15:26:43 +00:00
|
|
|
} else {
|
2004-04-05 17:32:43 +00:00
|
|
|
if (klass->control_info[i].lowerbound > klass->control_info[i].upperbound) {
|
|
|
|
gfloat swap;
|
|
|
|
|
|
|
|
GST_ERROR
|
|
|
|
(" wrong order of parameter bounds %f ... %f ... %f in \"%s\" plugin",
|
|
|
|
klass->control_info[i].lowerbound, klass->control_info[i].def,
|
|
|
|
klass->control_info[i].upperbound, klass->descriptor->Name);
|
|
|
|
|
|
|
|
swap = klass->control_info[i].upperbound;
|
|
|
|
klass->control_info[i].upperbound = klass->control_info[i].lowerbound;
|
|
|
|
klass->control_info[i].lowerbound = swap;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
paramspec = g_param_spec_float (argname, argname, argname,
|
2004-03-15 19:32:27 +00:00
|
|
|
klass->control_info[i].lowerbound, klass->control_info[i].upperbound,
|
|
|
|
klass->control_info[i].def, argperms);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
/* properties have an offset of 1 */
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), i + 1, paramspec);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_init (GstLADSPA * ladspa)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
2003-07-16 16:08:13 +00:00
|
|
|
GstLADSPAClass *oclass;
|
2002-04-20 13:57:00 +00:00
|
|
|
ladspa_control_info cinfo;
|
2003-07-16 16:08:13 +00:00
|
|
|
GList *l;
|
2001-12-23 15:26:43 +00:00
|
|
|
LADSPA_Descriptor *desc;
|
2004-03-14 22:34:33 +00:00
|
|
|
gint i, sinkcount, srccount;
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
oclass = (GstLADSPAClass *) G_OBJECT_GET_CLASS (ladspa);
|
2001-12-23 15:26:43 +00:00
|
|
|
desc = oclass->descriptor;
|
|
|
|
ladspa->descriptor = oclass->descriptor;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* allocate the various arrays */
|
2004-03-14 22:34:33 +00:00
|
|
|
ladspa->srcpads = g_new0 (GstPad *, oclass->numsrcpads);
|
|
|
|
ladspa->sinkpads = g_new0 (GstPad *, oclass->numsinkpads);
|
|
|
|
ladspa->controls = g_new (gfloat, oclass->numcontrols);
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
/* set up pads */
|
2001-12-23 15:26:43 +00:00
|
|
|
sinkcount = 0;
|
|
|
|
srccount = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
for (l = GST_ELEMENT_CLASS (oclass)->padtemplates; l; l = l->next) {
|
2003-07-16 16:08:13 +00:00
|
|
|
GstPad *pad = gst_pad_new_from_template (GST_PAD_TEMPLATE (l->data),
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_PAD_TEMPLATE_NAME_TEMPLATE (l->data));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
gst_pad_set_link_function (pad, gst_ladspa_link);
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_element_add_pad ((GstElement *) ladspa, pad);
|
2003-07-16 16:08:13 +00:00
|
|
|
|
|
|
|
if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK)
|
|
|
|
ladspa->sinkpads[sinkcount++] = pad;
|
|
|
|
else
|
|
|
|
ladspa->srcpads[srccount++] = pad;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-09-16 05:38:53 +00:00
|
|
|
/* nonzero default needed to instantiate() some plugins */
|
|
|
|
ladspa->samplerate = 44100;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
ladspa->buffer_frames = 0; /* should be set with caps */
|
2001-12-23 15:26:43 +00:00
|
|
|
ladspa->activated = FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
ladspa->inplace_broken =
|
|
|
|
LADSPA_IS_INPLACE_BROKEN (ladspa->descriptor->Properties);
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (sinkcount == 0 && srccount == 1) {
|
2002-01-22 04:42:11 +00:00
|
|
|
/* get mode (no sink pads) */
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG_OBJECT (ladspa, "mono get mode with 1 src pad");
|
2002-09-16 06:13:41 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
gst_pad_set_get_function (ladspa->srcpads[0], gst_ladspa_get);
|
2004-03-14 22:34:33 +00:00
|
|
|
} else if (sinkcount == 1) {
|
2002-04-20 13:57:00 +00:00
|
|
|
/* with one sink we can use the chain function */
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG_OBJECT (ladspa, "chain mode");
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
gst_pad_set_chain_function (ladspa->sinkpads[0], gst_ladspa_chain);
|
2004-03-14 22:34:33 +00:00
|
|
|
} else if (sinkcount > 1) {
|
2002-04-20 13:57:00 +00:00
|
|
|
/* more than one sink pad needs loop mode */
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG_OBJECT (ladspa, "loop mode with %d sink pads and %d src pads",
|
|
|
|
sinkcount, srccount);
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-03-30 17:06:26 +00:00
|
|
|
gst_element_set_loop_function (GST_ELEMENT (ladspa), gst_ladspa_loop);
|
2004-03-14 22:34:33 +00:00
|
|
|
} else if (sinkcount == 0 && srccount == 0) {
|
2003-07-16 16:08:13 +00:00
|
|
|
/* for example, a plugin with only control inputs and output -- just ignore
|
|
|
|
* it for now */
|
2002-04-20 13:57:00 +00:00
|
|
|
} else {
|
2004-03-14 22:34:33 +00:00
|
|
|
g_warning ("%d sink pads, %d src pads not yet supported", sinkcount,
|
2004-03-15 19:32:27 +00:00
|
|
|
srccount);
|
2002-04-20 13:57:00 +00:00
|
|
|
}
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-09-16 05:38:53 +00:00
|
|
|
gst_ladspa_instantiate (ladspa);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_update_int (const GValue * value, gpointer data)
|
2002-04-20 13:57:00 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
gfloat *target = (gfloat *) data;
|
|
|
|
|
|
|
|
*target = (gfloat) g_value_get_int (value);
|
2002-04-20 13:57:00 +00:00
|
|
|
}
|
|
|
|
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_link (GstPad * pad, const GstCaps * caps)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstElement *element = (GstElement *) GST_PAD_PARENT (pad);
|
|
|
|
GstLADSPA *ladspa = (GstLADSPA *) element;
|
2003-07-16 16:08:13 +00:00
|
|
|
const GList *l = NULL;
|
2002-03-30 17:06:26 +00:00
|
|
|
gint rate;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
/* if this fails in some other plugin, the graph is left in an inconsistent
|
|
|
|
state */
|
2004-03-14 22:34:33 +00:00
|
|
|
for (l = gst_element_get_pad_list (element); l; l = l->next)
|
|
|
|
if (pad != (GstPad *) l->data)
|
|
|
|
if (gst_pad_try_set_caps ((GstPad *) l->data, caps) <= 0)
|
2004-03-15 19:32:27 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
/* we assume that the ladspa plugin can handle any sample rate, so this
|
|
|
|
check gets put last */
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
gst_structure_get_int (structure, "rate", &rate);
|
|
|
|
/* have to instantiate ladspa plugin when samplerate changes (groan) */
|
|
|
|
if (ladspa->samplerate != rate) {
|
|
|
|
ladspa->samplerate = rate;
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!gst_ladspa_instantiate (ladspa))
|
2003-12-22 01:47:09 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
gst_structure_get_int (structure, "buffer-frames", &ladspa->buffer_frames);
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
return GST_PAD_LINK_OK;
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
#if 0
|
2003-07-16 16:08:13 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_force_src_caps (GstLADSPA * ladspa, GstPad * pad)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
2003-07-16 16:08:13 +00:00
|
|
|
if (!ladspa->buffer_frames) {
|
2004-03-15 19:32:27 +00:00
|
|
|
ladspa->buffer_frames = 256; /* 5 ms at 44100 kHz (just a default...) */
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG_OBJECT (ladspa, "forcing caps with rate=%d, buffer-frames=%d",
|
2004-03-14 22:34:33 +00:00
|
|
|
ladspa->samplerate, ladspa->buffer_frames);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2003-07-19 23:25:25 +00:00
|
|
|
gst_pad_try_set_caps (pad,
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_caps_new ("ladspa_src_caps",
|
2004-03-15 19:32:27 +00:00
|
|
|
"audio/x-raw-float",
|
|
|
|
gst_props_new ("width", G_TYPE_INT (32),
|
|
|
|
"endianness", G_TYPE_INT (G_BYTE_ORDER),
|
|
|
|
"rate", G_TYPE_INT (ladspa->samplerate),
|
|
|
|
"buffer-frames", G_TYPE_INT (ladspa->buffer_frames),
|
|
|
|
"channels", G_TYPE_INT (1), NULL)));
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
2003-12-22 01:47:09 +00:00
|
|
|
#endif
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_set_property (GObject * object, guint prop_id, const GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstLADSPA *ladspa = (GstLADSPA *) object;
|
2001-12-23 15:26:43 +00:00
|
|
|
GstLADSPAClass *oclass;
|
|
|
|
ladspa_control_info *control_info;
|
2003-07-19 23:25:25 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (object));
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
/* remember, properties have an offset of 1 */
|
|
|
|
prop_id--;
|
|
|
|
|
|
|
|
/* verify it exists */
|
|
|
|
g_return_if_fail (prop_id < oclass->numcontrols);
|
2003-07-19 23:25:25 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
control_info = &(oclass->control_info[prop_id]);
|
2001-12-23 15:26:43 +00:00
|
|
|
g_return_if_fail (control_info->name != NULL);
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* check to see if it's writable */
|
2001-12-23 15:26:43 +00:00
|
|
|
g_return_if_fail (control_info->writable);
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* now see what type it is */
|
2003-07-16 16:08:13 +00:00
|
|
|
if (control_info->toggled)
|
|
|
|
ladspa->controls[prop_id] = g_value_get_boolean (value) ? 1.f : 0.f;
|
|
|
|
else if (control_info->integer)
|
|
|
|
ladspa->controls[prop_id] = g_value_get_int (value);
|
|
|
|
else
|
|
|
|
ladspa->controls[prop_id] = g_value_get_float (value);
|
|
|
|
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG_OBJECT (object, "set arg %s to %f", control_info->name,
|
2004-03-14 22:34:33 +00:00
|
|
|
ladspa->controls[prop_id]);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstLADSPA *ladspa = (GstLADSPA *) object;
|
|
|
|
GstLADSPAClass *oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (object));
|
2001-12-23 15:26:43 +00:00
|
|
|
ladspa_control_info *control_info;
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
/* remember, properties have an offset of 1 */
|
|
|
|
prop_id--;
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
/* verify it exists */
|
|
|
|
g_return_if_fail (prop_id < oclass->numcontrols);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
control_info = &(oclass->control_info[prop_id]);
|
|
|
|
g_return_if_fail (control_info->name != NULL);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* now see what type it is */
|
2003-07-16 16:08:13 +00:00
|
|
|
if (control_info->toggled)
|
|
|
|
g_value_set_boolean (value, ladspa->controls[prop_id] == 1.0);
|
|
|
|
else if (control_info->integer)
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_int (value, (gint) ladspa->controls[prop_id]);
|
2003-07-16 16:08:13 +00:00
|
|
|
else
|
|
|
|
g_value_set_float (value, ladspa->controls[prop_id]);
|
|
|
|
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG_OBJECT (object, "got arg %s as %f", control_info->name,
|
2004-03-14 22:34:33 +00:00
|
|
|
ladspa->controls[prop_id]);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_instantiate (GstLADSPA * ladspa)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
|
|
|
LADSPA_Descriptor *desc;
|
|
|
|
int i;
|
2004-03-14 22:34:33 +00:00
|
|
|
GstLADSPAClass *oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
|
2001-12-23 15:26:43 +00:00
|
|
|
gboolean was_activated;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
desc = ladspa->descriptor;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* check for old handle */
|
2001-12-23 15:26:43 +00:00
|
|
|
was_activated = ladspa->activated;
|
2004-03-14 22:34:33 +00:00
|
|
|
if (ladspa->handle != NULL) {
|
|
|
|
gst_ladspa_deactivate (ladspa);
|
|
|
|
desc->cleanup (ladspa->handle);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
/* instantiate the plugin */
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG_OBJECT (ladspa, "instantiating the plugin at %d Hz",
|
|
|
|
ladspa->samplerate);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
ladspa->handle = desc->instantiate (desc, ladspa->samplerate);
|
2001-12-23 15:26:43 +00:00
|
|
|
g_return_val_if_fail (ladspa->handle != NULL, FALSE);
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
/* connect the control ports */
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0; i < oclass->numcontrols; i++)
|
|
|
|
desc->connect_port (ladspa->handle,
|
2004-03-15 19:32:27 +00:00
|
|
|
oclass->control_portnums[i], &(ladspa->controls[i]));
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* reactivate if it was activated before the reinstantiation */
|
2003-07-16 16:08:13 +00:00
|
|
|
if (was_activated)
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_activate (ladspa);
|
2003-07-16 16:08:13 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstElementStateReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_change_state (GstElement * element)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
|
|
|
LADSPA_Descriptor *desc;
|
2004-03-14 22:34:33 +00:00
|
|
|
GstLADSPA *ladspa = (GstLADSPA *) element;
|
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
desc = ladspa->descriptor;
|
|
|
|
|
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
|
|
|
case GST_STATE_NULL_TO_READY:
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_activate (ladspa);
|
2001-12-23 15:26:43 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_READY_TO_NULL:
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_deactivate (ladspa);
|
2001-12-23 15:26:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
|
|
|
|
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_activate (GstLADSPA * ladspa)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
|
|
|
LADSPA_Descriptor *desc;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
desc = ladspa->descriptor;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
if (ladspa->activated)
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_deactivate (ladspa);
|
|
|
|
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG_OBJECT (ladspa, "activating");
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* activate the plugin (function might be null) */
|
2003-07-16 16:08:13 +00:00
|
|
|
if (desc->activate != NULL)
|
2004-03-14 22:34:33 +00:00
|
|
|
desc->activate (ladspa->handle);
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
ladspa->activated = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_deactivate (GstLADSPA * ladspa)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
|
|
|
LADSPA_Descriptor *desc;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
desc = ladspa->descriptor;
|
|
|
|
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG_OBJECT (ladspa, "deactivating");
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* deactivate the plugin (function might be null) */
|
2003-07-16 16:08:13 +00:00
|
|
|
if (ladspa->activated && (desc->deactivate != NULL))
|
2004-03-14 22:34:33 +00:00
|
|
|
desc->deactivate (ladspa->handle);
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
ladspa->activated = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_loop (GstElement * element)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
guint i, j, numsrcpads, numsinkpads;
|
2005-08-01 16:22:31 +00:00
|
|
|
glong num_samples;
|
2004-03-14 22:34:33 +00:00
|
|
|
LADSPA_Data **data_in, **data_out;
|
|
|
|
GstBuffer **buffers_in, **buffers_out;
|
|
|
|
|
|
|
|
GstLADSPA *ladspa = (GstLADSPA *) element;
|
|
|
|
GstLADSPAClass *oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
|
2002-01-22 04:42:11 +00:00
|
|
|
LADSPA_Descriptor *desc = ladspa->descriptor;
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
numsinkpads = oclass->numsinkpads;
|
|
|
|
numsrcpads = oclass->numsrcpads;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
/* fixme: these mallocs need to die */
|
2004-03-14 22:34:33 +00:00
|
|
|
data_in = g_new0 (LADSPA_Data *, numsinkpads);
|
|
|
|
data_out = g_new0 (LADSPA_Data *, numsrcpads);
|
|
|
|
buffers_in = g_new0 (GstBuffer *, numsinkpads);
|
|
|
|
buffers_out = g_new0 (GstBuffer *, numsrcpads);
|
|
|
|
|
2005-08-01 16:22:31 +00:00
|
|
|
/* determine largest buffer */
|
|
|
|
num_samples = -1;
|
2002-04-20 13:57:00 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
/* first get all the necessary data from the input ports */
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0; i < numsinkpads; i++) {
|
2003-07-16 16:08:13 +00:00
|
|
|
get_buffer:
|
2003-10-08 16:08:19 +00:00
|
|
|
buffers_in[i] = GST_BUFFER (gst_pad_pull (ladspa->sinkpads[i]));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
if (GST_IS_EVENT (buffers_in[i])) {
|
|
|
|
/* push it out on all pads */
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_data_ref_by_count ((GstData *) buffers_in[i], numsrcpads);
|
|
|
|
for (j = 0; j < numsrcpads; j++)
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_pad_push (ladspa->srcpads[j], GST_DATA (buffers_in[i]));
|
2003-07-16 16:08:13 +00:00
|
|
|
if (GST_EVENT_TYPE (buffers_in[i]) == GST_EVENT_EOS) {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* shut down */
|
|
|
|
gst_element_set_eos (element);
|
|
|
|
return;
|
2002-04-20 13:57:00 +00:00
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
goto get_buffer;
|
2002-01-22 04:42:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-01 16:22:31 +00:00
|
|
|
if (num_samples < 0)
|
|
|
|
num_samples = GST_BUFFER_SIZE (buffers_in[i]) / sizeof (gfloat);
|
2003-07-16 16:08:13 +00:00
|
|
|
else
|
2005-08-01 16:22:31 +00:00
|
|
|
num_samples =
|
|
|
|
MIN (GST_BUFFER_SIZE (buffers_in[i]) / sizeof (gfloat), num_samples);
|
2004-03-14 22:34:33 +00:00
|
|
|
data_in[i] = (LADSPA_Data *) GST_BUFFER_DATA (buffers_in[i]);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffers_in[i]) = ladspa->timestamp;
|
2003-07-16 16:08:13 +00:00
|
|
|
}
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
i = 0;
|
2003-07-16 16:08:13 +00:00
|
|
|
if (!ladspa->inplace_broken) {
|
2004-03-14 22:34:33 +00:00
|
|
|
for (; i < numsrcpads && i < numsinkpads; i++) {
|
2003-07-16 16:08:13 +00:00
|
|
|
/* reuse input buffers */
|
|
|
|
buffers_out[i] = buffers_in[i];
|
|
|
|
data_out[i] = data_in[i];
|
2002-01-22 04:42:11 +00:00
|
|
|
}
|
2003-07-16 16:08:13 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
for (; i < numsrcpads; i++) {
|
|
|
|
buffers_out[i] =
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_buffer_new_and_alloc (ladspa->buffer_frames * sizeof (gfloat));
|
2003-07-16 16:08:13 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (buffers_out[i]) = ladspa->timestamp;
|
2004-03-14 22:34:33 +00:00
|
|
|
data_out[i] = (LADSPA_Data *) GST_BUFFER_DATA (buffers_out[i]);
|
2003-07-16 16:08:13 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-08-01 16:22:31 +00:00
|
|
|
/* process chunk */
|
|
|
|
for (i = 0; i < numsinkpads; i++)
|
|
|
|
desc->connect_port (ladspa->handle, oclass->sinkpad_portnums[i],
|
|
|
|
data_in[i]);
|
|
|
|
for (i = 0; i < numsrcpads; i++)
|
|
|
|
desc->connect_port (ladspa->handle, oclass->srcpad_portnums[i],
|
|
|
|
data_out[i]);
|
2002-04-20 13:57:00 +00:00
|
|
|
|
2005-08-01 16:22:31 +00:00
|
|
|
desc->run (ladspa->handle, num_samples);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
for (i = 0; i < numsinkpads; i++) {
|
2003-07-16 16:08:13 +00:00
|
|
|
if (i >= numsrcpads || buffers_out[i] != buffers_in[i])
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_buffer_unref (buffers_in[i]);
|
2003-07-16 16:08:13 +00:00
|
|
|
data_in[i] = NULL;
|
|
|
|
buffers_in[i] = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
for (i = 0; i < numsrcpads; i++) {
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG_OBJECT (ladspa, "pushing buffer (%p) on src pad %d",
|
|
|
|
buffers_out[i], i);
|
2003-10-08 16:08:19 +00:00
|
|
|
gst_pad_push (ladspa->srcpads[i], GST_DATA (buffers_out[i]));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
data_out[i] = NULL;
|
|
|
|
buffers_out[i] = NULL;
|
2002-04-20 13:57:00 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
ladspa->timestamp += ladspa->buffer_frames * GST_SECOND / ladspa->samplerate;
|
|
|
|
|
|
|
|
/* FIXME: move these mallocs and frees to the state-change handler */
|
2002-04-20 13:57:00 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
g_free (buffers_out);
|
2002-04-20 13:57:00 +00:00
|
|
|
g_free (buffers_in);
|
|
|
|
g_free (data_out);
|
|
|
|
g_free (data_in);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_chain (GstPad * pad, GstData * _data)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
2003-10-08 16:08:19 +00:00
|
|
|
GstBuffer *buffer_in = GST_BUFFER (_data);
|
2001-12-23 15:26:43 +00:00
|
|
|
LADSPA_Descriptor *desc;
|
2002-04-20 21:42:51 +00:00
|
|
|
LADSPA_Data *data_in, **data_out = NULL;
|
|
|
|
GstBuffer **buffers_out = NULL;
|
2005-08-01 16:22:31 +00:00
|
|
|
gulong num_samples;
|
|
|
|
guint i, numsrcpads;
|
2001-12-23 15:26:43 +00:00
|
|
|
GstLADSPA *ladspa;
|
|
|
|
GstLADSPAClass *oclass;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
ladspa = (GstLADSPA *) GST_OBJECT_PARENT (pad);
|
2002-04-20 13:57:00 +00:00
|
|
|
oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
|
2004-03-14 22:34:33 +00:00
|
|
|
data_in = (LADSPA_Data *) GST_BUFFER_DATA (buffer_in);
|
|
|
|
num_samples = GST_BUFFER_SIZE (buffer_in) / sizeof (gfloat);
|
2003-07-16 16:08:13 +00:00
|
|
|
numsrcpads = oclass->numsrcpads;
|
|
|
|
desc = ladspa->descriptor;
|
2002-04-20 13:57:00 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
/* we shouldn't get events here... */
|
|
|
|
g_return_if_fail (GST_IS_BUFFER (buffer_in));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
/* FIXME: this function shouldn't need to malloc() anything */
|
|
|
|
if (numsrcpads > 0) {
|
2004-03-14 22:34:33 +00:00
|
|
|
buffers_out = g_new (GstBuffer *, numsrcpads);
|
|
|
|
data_out = g_new (LADSPA_Data *, numsrcpads);
|
2003-07-16 16:08:13 +00:00
|
|
|
}
|
2002-04-20 13:57:00 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
i = 0;
|
2003-07-16 16:08:13 +00:00
|
|
|
if (!ladspa->inplace_broken && numsrcpads) {
|
|
|
|
/* reuse the first (chained) buffer */
|
|
|
|
buffers_out[i] = buffer_in;
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG ("reuse: %d", GST_BUFFER_SIZE (buffer_in));
|
2003-07-16 16:08:13 +00:00
|
|
|
data_out[i] = data_in;
|
|
|
|
i++;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
for (; i < numsrcpads; i++) {
|
|
|
|
buffers_out[i] = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buffer_in));
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG ("new %d", GST_BUFFER_SIZE (buffer_in));
|
2003-07-16 16:08:13 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (buffers_out[i]) = ladspa->timestamp;
|
2004-03-14 22:34:33 +00:00
|
|
|
data_out[i] = (LADSPA_Data *) GST_BUFFER_DATA (buffers_out[i]);
|
2002-01-22 04:42:11 +00:00
|
|
|
}
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2005-08-01 16:22:31 +00:00
|
|
|
/* process chunk */
|
|
|
|
desc->connect_port (ladspa->handle, oclass->sinkpad_portnums[0], data_in);
|
|
|
|
for (i = 0; i < numsrcpads; i++)
|
|
|
|
desc->connect_port (ladspa->handle, oclass->srcpad_portnums[i],
|
|
|
|
data_out[i]);
|
2002-04-20 13:57:00 +00:00
|
|
|
|
2005-08-01 16:22:31 +00:00
|
|
|
desc->run (ladspa->handle, num_samples);
|
2002-04-20 13:57:00 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
if (!numsrcpads || buffers_out[0] != buffer_in)
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_buffer_unref (buffer_in);
|
2003-07-16 16:08:13 +00:00
|
|
|
|
|
|
|
if (numsrcpads) {
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0; i < numsrcpads; i++) {
|
2004-04-05 17:32:43 +00:00
|
|
|
GST_DEBUG_OBJECT (ladspa,
|
|
|
|
"pushing buffer (%p, length %u bytes) on src pad %d", buffers_out[i],
|
|
|
|
GST_BUFFER_SIZE (buffers_out[i]), i);
|
2003-10-08 16:08:19 +00:00
|
|
|
gst_pad_push (ladspa->srcpads[i], GST_DATA (buffers_out[i]));
|
2002-04-20 13:57:00 +00:00
|
|
|
}
|
2003-07-16 16:08:13 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_free (buffers_out);
|
|
|
|
g_free (data_out);
|
2002-04-20 13:57:00 +00:00
|
|
|
}
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
2003-10-08 16:08:19 +00:00
|
|
|
static GstData *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ladspa_get (GstPad * pad)
|
|
|
|
{
|
2001-12-23 15:26:43 +00:00
|
|
|
GstLADSPA *ladspa;
|
|
|
|
GstLADSPAClass *oclass;
|
|
|
|
GstBuffer *buf;
|
2002-04-20 13:57:00 +00:00
|
|
|
LADSPA_Data *data;
|
|
|
|
LADSPA_Descriptor *desc;
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
ladspa = (GstLADSPA *) gst_pad_get_parent (pad);
|
|
|
|
oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
|
2003-07-16 16:08:13 +00:00
|
|
|
desc = ladspa->descriptor;
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
/* 4096 is arbitrary */
|
|
|
|
buf = gst_buffer_new_and_alloc (4096);
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (buf) = ladspa->timestamp;
|
|
|
|
data = (LADSPA_Data *) GST_BUFFER_DATA (buf);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2005-08-01 16:22:31 +00:00
|
|
|
/* update timestamp */
|
|
|
|
ladspa->timestamp += num_to_process * GST_SECOND / ladspa->samplerate;
|
2002-04-20 13:57:00 +00:00
|
|
|
|
2005-08-01 16:22:31 +00:00
|
|
|
/* process chunk */
|
|
|
|
desc->connect_port (ladspa->handle, oclass->srcpad_portnums[0], data);
|
2002-05-29 18:54:17 +00:00
|
|
|
|
2005-08-01 16:22:31 +00:00
|
|
|
desc->run (ladspa->handle, ladspa->buffer_frames);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-10-08 16:08:19 +00:00
|
|
|
return GST_DATA (buf);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
ladspa_describe_plugin (const char *pcFullFilename,
|
|
|
|
void *pvPluginHandle, LADSPA_Descriptor_Function pfDescriptorFunction)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
|
|
|
const LADSPA_Descriptor *desc;
|
2003-11-02 13:55:40 +00:00
|
|
|
gint i;
|
2001-12-23 15:26:43 +00:00
|
|
|
GTypeInfo typeinfo = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstLADSPAClass),
|
|
|
|
(GBaseInitFunc) gst_ladspa_base_init,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_ladspa_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (GstLADSPA),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_ladspa_init,
|
2001-12-23 15:26:43 +00:00
|
|
|
};
|
|
|
|
GType type;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* walk through all the plugins in this pluginlibrary */
|
2001-12-23 15:26:43 +00:00
|
|
|
i = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
while ((desc = pfDescriptorFunction (i++))) {
|
2001-12-23 15:26:43 +00:00
|
|
|
gchar *type_name;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* construct the type */
|
2004-03-14 22:34:33 +00:00
|
|
|
type_name = g_strdup_printf ("ladspa-%s", desc->Label);
|
2003-07-16 16:08:13 +00:00
|
|
|
g_strcanon (type_name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-+", '-');
|
2002-01-22 04:42:11 +00:00
|
|
|
/* if it's already registered, drop it */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (g_type_from_name (type_name)) {
|
|
|
|
g_free (type_name);
|
2001-12-23 15:26:43 +00:00
|
|
|
continue;
|
|
|
|
}
|
2003-11-02 23:58:20 +00:00
|
|
|
|
|
|
|
/* base-init temp alloc */
|
2004-03-14 22:34:33 +00:00
|
|
|
g_hash_table_insert (ladspa_descriptors,
|
2004-03-15 19:32:27 +00:00
|
|
|
GINT_TO_POINTER (0), (gpointer) desc);
|
2003-11-02 23:58:20 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* create the type now */
|
2004-03-14 22:34:33 +00:00
|
|
|
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
|
2003-11-02 13:55:40 +00:00
|
|
|
if (!gst_element_register (ladspa_plugin, type_name, GST_RANK_NONE, type))
|
|
|
|
continue;
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* add this plugin to the hash */
|
2004-03-14 22:34:33 +00:00
|
|
|
g_hash_table_insert (ladspa_descriptors,
|
2004-03-15 19:32:27 +00:00
|
|
|
GINT_TO_POINTER (type), (gpointer) desc);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
2003-11-02 23:58:20 +00:00
|
|
|
|
|
|
|
g_hash_table_remove (ladspa_descriptors, GINT_TO_POINTER (0));
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
2003-07-16 16:08:13 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (ladspa_debug, "ladspa",
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG_FG_GREEN | GST_DEBUG_BG_BLACK | GST_DEBUG_BOLD, "LADSPA");
|
2003-07-16 16:08:13 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
ladspa_descriptors = g_hash_table_new (NULL, NULL);
|
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
ladspa_plugin = plugin;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
LADSPAPluginSearch (ladspa_describe_plugin);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"ladspa",
|
|
|
|
"All LADSPA plugins",
|
|
|
|
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
|