From: <en...@ke...> - 2010-02-01 21:52:40
|
Module: gst-plugins-bad Branch: master Commit: ebdf1c2a18405052be242ec115380d00088775cd URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=ebdf1c2a18405052be242ec115380d00088775cd Author: Stefan Kost <en...@us...> Date: Mon Feb 1 22:32:32 2010 +0200 signalprocessor,lv2,ladspa: move sample-rate to baseclass We need the sample-rate in baseclass for upcomming timestamp changes. --- ext/ladspa/gstladspa.c | 16 +++------------- ext/lv2/gstlv2.c | 14 ++------------ gst-libs/gst/signalprocessor/gstsignalprocessor.c | 14 ++++++++++++++ gst-libs/gst/signalprocessor/gstsignalprocessor.h | 4 ++++ 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/ext/ladspa/gstladspa.c b/ext/ladspa/gstladspa.c index e6dd148..5019734 100644 --- a/ext/ladspa/gstladspa.c +++ b/ext/ladspa/gstladspa.c @@ -555,8 +555,6 @@ gst_ladspa_setup (GstSignalProcessor * gsp, GstCaps * caps) GstLADSPAClass *oclass; GstSignalProcessorClass *gsp_class; LADSPA_Descriptor *desc; - GstStructure *s; - gint sample_rate; gint i; gsp_class = GST_SIGNAL_PROCESSOR_GET_CLASS (gsp); @@ -567,13 +565,10 @@ gst_ladspa_setup (GstSignalProcessor * gsp, GstCaps * caps) g_return_val_if_fail (ladspa->handle == NULL, FALSE); g_return_val_if_fail (ladspa->activated == FALSE, FALSE); - s = gst_caps_get_structure (caps, 0); - if (!gst_structure_get_int (s, "rate", &sample_rate)) - goto no_sample_rate; + GST_DEBUG_OBJECT (ladspa, "instantiating the plugin at %d Hz", + gsp->sample_rate); - GST_DEBUG_OBJECT (ladspa, "instantiating the plugin at %d Hz", sample_rate); - - if (!(ladspa->handle = desc->instantiate (desc, sample_rate))) + if (!(ladspa->handle = desc->instantiate (desc, gsp->sample_rate))) goto no_instance; /* connect the control ports */ @@ -586,11 +581,6 @@ gst_ladspa_setup (GstSignalProcessor * gsp, GstCaps * caps) return TRUE; -no_sample_rate: - { - GST_WARNING_OBJECT (gsp, "got no sample-rate"); - return FALSE; - } no_instance: { GST_WARNING_OBJECT (gsp, "could not create instance"); diff --git a/ext/lv2/gstlv2.c b/ext/lv2/gstlv2.c index bb8cfc8..4c01230 100644 --- a/ext/lv2/gstlv2.c +++ b/ext/lv2/gstlv2.c @@ -600,7 +600,6 @@ gst_lv2_setup (GstSignalProcessor * gsp, GstCaps * caps) GstLV2Class *oclass; GstSignalProcessorClass *gsp_class; GstStructure *s; - gint sample_rate; gint i; GstLV2Group *group = NULL; GstAudioChannelPosition *positions = NULL; @@ -613,14 +612,10 @@ gst_lv2_setup (GstSignalProcessor * gsp, GstCaps * caps) g_return_val_if_fail (lv2->activated == FALSE, FALSE); - s = gst_caps_get_structure (caps, 0); - if (!gst_structure_get_int (s, "rate", &sample_rate)) - goto no_sample_rate; - - GST_DEBUG_OBJECT (lv2, "instantiating the plugin at %d Hz", sample_rate); + GST_DEBUG_OBJECT (lv2, "instantiating the plugin at %d Hz", gsp->sample_rate); if (!(lv2->instance = - slv2_plugin_instantiate (oclass->plugin, sample_rate, NULL))) + slv2_plugin_instantiate (oclass->plugin, gsp->sample_rate, NULL))) goto no_instance; /* connect the control ports */ @@ -673,11 +668,6 @@ gst_lv2_setup (GstSignalProcessor * gsp, GstCaps * caps) } return TRUE; -no_sample_rate: - { - GST_WARNING_OBJECT (gsp, "got no sample-rate"); - return FALSE; - } no_instance: { GST_WARNING_OBJECT (gsp, "could not create instance"); diff --git a/gst-libs/gst/signalprocessor/gstsignalprocessor.c b/gst-libs/gst/signalprocessor/gstsignalprocessor.c index bae230e..435ced8 100644 --- a/gst-libs/gst/signalprocessor/gstsignalprocessor.c +++ b/gst-libs/gst/signalprocessor/gstsignalprocessor.c @@ -471,6 +471,8 @@ gst_signal_processor_setcaps (GstPad * pad, GstCaps * caps) /* the whole processor has one caps; if the sample rate changes, let subclass implementations know */ if (!gst_caps_is_equal (caps, self->caps)) { + GstStructure *s; + GST_DEBUG_OBJECT (pad, "got caps %" GST_PTR_FORMAT, caps); if (GST_SIGNAL_PROCESSOR_IS_RUNNING (self)) @@ -478,6 +480,10 @@ gst_signal_processor_setcaps (GstPad * pad, GstCaps * caps) if (GST_SIGNAL_PROCESSOR_IS_INITIALIZED (self)) gst_signal_processor_cleanup (self); + s = gst_caps_get_structure (caps, 0); + if (!gst_structure_get_int (s, "rate", &self->sample_rate)) + goto no_sample_rate; + if (!gst_signal_processor_setup (self, caps)) goto start_or_setup_failed; @@ -502,13 +508,21 @@ gst_signal_processor_setcaps (GstPad * pad, GstCaps * caps) return TRUE; +no_sample_rate: + { + GST_WARNING_OBJECT (self, "got no sample-rate"); + gst_object_unref (self); + return FALSE; + } start_or_setup_failed: { + GST_WARNING_OBJECT (self, "start or setup failed"); gst_object_unref (self); return FALSE; } setcaps_pull_failed: { + GST_WARNING_OBJECT (self, "activating in pull-mode failed"); gst_object_unref (self); return FALSE; } diff --git a/gst-libs/gst/signalprocessor/gstsignalprocessor.h b/gst-libs/gst/signalprocessor/gstsignalprocessor.h index cad85e9..4d512e1 100644 --- a/gst-libs/gst/signalprocessor/gstsignalprocessor.h +++ b/gst-libs/gst/signalprocessor/gstsignalprocessor.h @@ -100,6 +100,10 @@ struct _GstSignalProcessor { /* controls */ gfloat *control_in; gfloat *control_out; + + /* sampling rate */ + gint sample_rate; + }; struct _GstSignalProcessorClass { |