summaryrefslogtreecommitdiffstats
path: root/ext/ladspa
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2005-08-25 09:30:24 +0000
committerAndy Wingo <wingo@pobox.com>2005-08-25 09:30:24 +0000
commit0582ab12916859fdc3815010e68aafb131c9570c (patch)
tree2284e326926c95feed4e5b849acf1f4b3485f604 /ext/ladspa
parent38d8867a0f70785789dbf469d8d4129a45517a95 (diff)
ext/ladspa/gstladspa.*: Halfway-ported. Doesn't compile yet.
Original commit message from CVS: 2005-08-25 Andy Wingo <wingo@pobox.com> * ext/ladspa/gstladspa.h: * ext/ladspa/gstladspa.c: Halfway-ported. Doesn't compile yet. * ext/ladspa/gstsignalprocessor.h: * ext/ladspa/gstsignalprocessor.c: New files, the start of a base class for DSP elements. * configure.ac: Sort the external libs checks, add a ladspa check, output the ladspa makefile.
Diffstat (limited to 'ext/ladspa')
-rw-r--r--ext/ladspa/Makefile.am8
-rw-r--r--ext/ladspa/gstladspa.c136
-rw-r--r--ext/ladspa/gstladspa.h33
3 files changed, 97 insertions, 80 deletions
diff --git a/ext/ladspa/Makefile.am b/ext/ladspa/Makefile.am
index c7c654fd..ce5302d5 100644
--- a/ext/ladspa/Makefile.am
+++ b/ext/ladspa/Makefile.am
@@ -1,9 +1,9 @@
plugin_LTLIBRARIES = libgstladspa.la
-libgstladspa_la_SOURCES = gstladspa.c search.c load.c
-libgstladspa_la_CFLAGS = $(GST_CFLAGS)
-libgstladspa_la_LIBADD = $(GST_LIBS)
+libgstladspa_la_SOURCES = gstsignalprocessor.c gstladspa.c search.c load.c
+libgstladspa_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
+libgstladspa_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-@GST_MAJORMINOR@
libgstladspa_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-noinst_HEADERS = gstladspa.h utils.h
+noinst_HEADERS = gstsignalprocessor.h gstladspa.h utils.h
diff --git a/ext/ladspa/gstladspa.c b/ext/ladspa/gstladspa.c
index 06ba497f..074ccdac 100644
--- a/ext/ladspa/gstladspa.c
+++ b/ext/ladspa/gstladspa.c
@@ -36,50 +36,34 @@
#define LADSPA_VERSION "1.0"
#endif
-static GstStaticCaps ladspa_pad_caps =
-GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
-
-static void gst_ladspa_class_init (GstLADSPAClass * klass);
-static void gst_ladspa_base_init (GstLADSPAClass * klass);
-static void gst_ladspa_init (GstLADSPA * ladspa);
-
-static void gst_ladspa_update_int (const GValue * value, gpointer data);
-static GstPadLinkReturn gst_ladspa_link (GstPad * pad, const GstCaps * caps);
+GST_BOILERPLATE (GstLADSPA, GST_TYPE_LADSPA, GstSignalProcessor,
+ GST_TYPE_SIGNAL_PROCESSOR);
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);
-static gboolean gst_ladspa_instantiate (GstLADSPA * ladspa);
-static void gst_ladspa_activate (GstLADSPA * ladspa);
-static void gst_ladspa_deactivate (GstLADSPA * ladspa);
+static gboolean gst_ladspa_setup (GstSignalProcessor * sigproc,
+ guint sample_rate, guint buffer_frames);
+static gboolean gst_ladspa_activate (GstSignalProcessor * sigproc);
+static gboolean gst_ladspa_deactivate (GstSignalProcessor * sigproc);
+static gboolean gst_ladspa_process (GstSignalProcessor * sigproc);
-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);
-
-static GstElementClass *parent_class = NULL;
static GstPlugin *ladspa_plugin;
static GHashTable *ladspa_descriptors;
-enum
-{
- ARG_0,
- ARG_SAMPLERATE,
- ARG_BUFFERSIZE,
- ARG_LAST
-};
GST_DEBUG_CATEGORY_STATIC (ladspa_debug);
#define GST_CAT_DEFAULT ladspa_debug
+
static void
gst_ladspa_base_init (GstLADSPAClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GstSignalProcessorClass *gsp_class = GST_SIGNAL_PROCESSOR_CLASS (klass);
GstPadTemplate *templ;
GstElementDetails *details;
LADSPA_Descriptor *desc;
@@ -92,27 +76,24 @@ gst_ladspa_base_init (GstLADSPAClass * klass)
g_assert (desc);
/* pad templates */
- klass->numports = desc->PortCount;
- klass->numsinkpads = 0;
- klass->numsrcpads = 0;
+ gsp_class->num_audio_in = 0;
+ gsp_class->num_audio_out = 0;
+ /* control gets set in the class init */
+
for (j = 0; j < desc->PortCount; j++) {
- if (LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[j])) {
+ LADSPA_PortDescriptor p = desc->PortDescriptors[j];
+
+ if (LADSPA_IS_PORT_AUDIO (p)) {
gchar *name = g_strdup ((gchar *) desc->PortNames[j]);
g_strcanon (name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
- /* the factories take ownership of the name */
- if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[j])) {
- templ = gst_pad_template_new (name, GST_PAD_SINK, GST_PAD_ALWAYS,
- gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps)));
- klass->numsinkpads++;
- } else {
- templ = gst_pad_template_new (name, GST_PAD_SRC, GST_PAD_ALWAYS,
- gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps)));
- klass->numsrcpads++;
- }
-
- gst_element_class_add_pad_template (element_class, templ);
+ if (LADSPA_IS_PORT_INPUT (p))
+ gst_signal_processor_class_add_pad_template (name, GST_PAD_SINK,
+ gsp_class->num_audio_in++);
+ else
+ gst_signal_processor_class_add_pad_template (name, GST_PAD_SRC,
+ gsp_class->num_audio_out++);
}
}
@@ -125,28 +106,24 @@ gst_ladspa_base_init (GstLADSPAClass * klass)
details->author = g_locale_to_utf8 (desc->Maker, -1, NULL, NULL, NULL);
if (!details->author)
details->author = g_strdup ("no author available");
- if ((klass->numsinkpads > 0) && (klass->numsrcpads > 0))
- details->klass = "Filter/Effect/Audio/LADSPA";
- else if ((klass->numsinkpads == 0) && (klass->numsrcpads > 0))
+ if (gsp_class->num_audio_in == 0)
details->klass = "Source/Audio/LADSPA";
- else if ((klass->numsinkpads > 0) && (klass->numsrcpads == 0))
+ else if (gsp_class->num_audio_out == 0)
details->klass = "Sink/Audio/LADSPA";
else
- details->klass = "Filter/Effect/Audio/LADSPA"; /* whatever this is */
+ details->klass = "Filter/Effect/Audio/LADSPA";
gst_element_class_set_details (element_class, details);
- klass->srcpad_portnums = g_new0 (gint, klass->numsrcpads);
- klass->sinkpad_portnums = g_new0 (gint, klass->numsinkpads);
- sinkcount = 0;
- srccount = 0;
+ klass->audio_in_portnums = g_new0 (gint, klass->num_audio_in);
+ klass->audio_out_portnums = g_new0 (gint, gsp_class->num_audio_out);
- /* walk through the ports, note the portnums for srcpads, sinkpads */
+ sinkcount = srccount = 0;
for (j = 0; j < desc->PortCount; j++) {
if (LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[j])) {
if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[j]))
- klass->sinkpad_portnums[sinkcount++] = j;
+ klass->audio_in_portnums[sinkcount++] = j;
else
- klass->srcpad_portnums[srccount++] = j;
+ klass->audio_out_portnums[srccount++] = j;
}
}
@@ -158,6 +135,7 @@ gst_ladspa_class_init (GstLADSPAClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
+ GstSignalProcessorClass *gsp_class = GST_SIGNAL_PROCESSOR_CLASS (klass);
LADSPA_Descriptor *desc;
gint i, current_portnum, controlcount;
gint hintdesc;
@@ -173,6 +151,58 @@ gst_ladspa_class_init (GstLADSPAClass * klass)
gstelement_class->change_state = gst_ladspa_change_state;
+ gsp_class->num_control_in = 0;
+ gsp_class->num_control_in = 0;
+
+ for (j = 0; j < desc->PortCount; j++) {
+ LADSPA_PortDescriptor p = desc->PortDescriptors[j];
+
+ if (LADSPA_IS_PORT_AUDIO (p)) {
+ gchar *name = g_strdup ((gchar *) desc->PortNames[j]);
+
+ g_strcanon (name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
+
+ if (LADSPA_IS_PORT_INPUT (p))
+ gst_signal_processor_class_add_pad_template (name, GST_PAD_SINK,
+ gsp_class->num_audio_in++);
+ else
+ gst_signal_processor_class_add_pad_template (name, GST_PAD_SRC,
+ gsp_class->num_audio_out++);
+ }
+ }
+
+ /* construct the element details struct */
+ details = g_new0 (GstElementDetails, 1);
+ details->longname = g_locale_to_utf8 (desc->Name, -1, NULL, NULL, NULL);
+ if (!details->longname)
+ details->longname = g_strdup ("no description available");
+ details->description = details->longname;
+ details->author = g_locale_to_utf8 (desc->Maker, -1, NULL, NULL, NULL);
+ if (!details->author)
+ details->author = g_strdup ("no author available");
+ if (gsp_class->num_audio_in == 0)
+ details->klass = "Source/Audio/LADSPA";
+ else if (gsp_class->num_audio_out == 0)
+ details->klass = "Sink/Audio/LADSPA";
+ else
+ details->klass = "Filter/Effect/Audio/LADSPA";
+ gst_element_class_set_details (element_class, details);
+
+ klass->audio_in_portnums = g_new0 (gint, klass->num_audio_in);
+ klass->audio_out_portnums = g_new0 (gint, gsp_class->num_audio_out);
+
+ sinkcount = srccount = 0;
+ for (j = 0; j < desc->PortCount; j++) {
+ if (LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[j])) {
+ if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[j]))
+ klass->audio_in_portnums[sinkcount++] = j;
+ else
+ klass->audio_out_portnums[srccount++] = j;
+ }
+ }
+
+ klass->descriptor = desc;
+
/* look up and store the ladspa descriptor */
desc = g_hash_table_lookup (ladspa_descriptors,
GINT_TO_POINTER (G_TYPE_FROM_CLASS (klass)));
diff --git a/ext/ladspa/gstladspa.h b/ext/ladspa/gstladspa.h
index 81f06729..cb6f1afa 100644
--- a/ext/ladspa/gstladspa.h
+++ b/ext/ladspa/gstladspa.h
@@ -24,15 +24,15 @@
#define __GST_LADSPA_H__
+#include <ladspa.h>
+
#include <gst/gst.h>
-#include <gst/bytestream/bytestream.h>
-#include "ladspa.h"
+#include "gstsignalprocessor.h"
+
+G_BEGIN_DECLS
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
typedef struct _ladspa_control_info {
gchar *name;
@@ -43,37 +43,26 @@ typedef struct _ladspa_control_info {
gboolean toggled, logarithmic, integer, writable;
} ladspa_control_info;
+
typedef struct _GstLADSPA GstLADSPA;
typedef struct _GstLADSPAClass GstLADSPAClass;
+
struct _GstLADSPA {
- GstElement element;
+ GstSignalProcessor parent;
LADSPA_Descriptor *descriptor;
LADSPA_Handle *handle;
- gfloat *controls;
-
- GstPad **sinkpads,
- **srcpads;
-
gboolean activated;
-
- gint samplerate, buffer_frames;
- gint64 timestamp;
gboolean inplace_broken;
};
struct _GstLADSPAClass {
- GstElementClass parent_class;
+ GstSignalProcessorClass parent_class;
LADSPA_Descriptor *descriptor;
- gint numports,
- numsinkpads,
- numsrcpads,
- numcontrols;
-
gint *sinkpad_portnums,
*srcpad_portnums,
*control_portnums;
@@ -82,9 +71,7 @@ struct _GstLADSPAClass {
};
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* __GST_LADSPA_H__ */