From 57f11c5ed8d2817395068ca5d3e60c509683d7d0 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 12 Jan 2007 21:58:43 +0000 Subject: ext/ladspa/gstsignalprocessor.c (gst_signal_processor_fixate) Original commit message from CVS: 2007-01-12 Andy Wingo * ext/ladspa/gstsignalprocessor.c (gst_signal_processor_fixate) (gst_signal_processor_ouija_caps, gst_signal_processor_prepare): Remove fixate/ouija stuff, thankfully, due to the new part-negotiation.txt pull-mode negotiation scheme. (gst_signal_processor_setcaps_pull) (gst_signal_processor_setcaps): Implement upstream set_caps pull proxying for pull mode. Now this works: ladspa-sine-fcac ! audioconvert ! alsasink. --- ext/ladspa/gstsignalprocessor.c | 94 ++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 39 deletions(-) (limited to 'ext/ladspa') diff --git a/ext/ladspa/gstsignalprocessor.c b/ext/ladspa/gstsignalprocessor.c index e0b92397..5c0fff83 100644 --- a/ext/ladspa/gstsignalprocessor.c +++ b/ext/ladspa/gstsignalprocessor.c @@ -156,7 +156,6 @@ static GstFlowReturn gst_signal_processor_getrange (GstPad * pad, static GstFlowReturn gst_signal_processor_chain (GstPad * pad, GstBuffer * buffer); static gboolean gst_signal_processor_setcaps (GstPad * pad, GstCaps * caps); -static void gst_signal_processor_fixate (GstPad * pad, GstCaps * caps); static void @@ -199,8 +198,6 @@ gst_signal_processor_add_pad_from_template (GstSignalProcessor * self, gst_pad_set_setcaps_function (new, GST_DEBUG_FUNCPTR (gst_signal_processor_setcaps)); - gst_pad_set_fixatecaps_function (new, - GST_DEBUG_FUNCPTR (gst_signal_processor_fixate)); if (templ->direction == GST_PAD_SINK) { GST_DEBUG ("added new sink pad"); @@ -372,6 +369,52 @@ gst_signal_processor_cleanup (GstSignalProcessor * self) self->state = GST_SIGNAL_PROCESSOR_STATE_NULL; } +static gboolean +gst_signal_processor_setcaps_pull (GstSignalProcessor * self, GstPad * pad, + GstCaps * caps) +{ + if (GST_PAD_IS_SRC (pad)) { + GList *l; + + for (l = GST_ELEMENT (self)->sinkpads; l; l = l->next) + if (!gst_pad_set_caps (GST_PAD (l->data), caps)) + goto src_setcaps_failed; + } else { + GstPad *peer; + gboolean res; + + peer = gst_pad_get_peer (pad); + if (!peer) + goto unlinked_sink; + + res = gst_pad_set_caps (peer, caps); + gst_object_unref (peer); + + if (!res) + goto peer_setcaps_failed; + } + + return TRUE; + +src_setcaps_failed: + { + /* not logging, presumably the sink pad already logged */ + return FALSE; + } +unlinked_sink: + { + GST_WARNING_OBJECT (self, "unlinked sink pad %" GST_PTR_FORMAT ", I wonder " + "how we passed activate_pull()", pad); + return FALSE; + } +peer_setcaps_failed: + { + GST_INFO_OBJECT (self, "peer of %" GST_PTR_FORMAT " did not accept caps", + pad); + return FALSE; + } +} + static gboolean gst_signal_processor_setcaps (GstPad * pad, GstCaps * caps) { @@ -379,6 +422,10 @@ gst_signal_processor_setcaps (GstPad * pad, GstCaps * caps) self = GST_SIGNAL_PROCESSOR (gst_pad_get_parent (pad)); + if (self->mode == GST_ACTIVATE_PULL && !gst_caps_is_equal (caps, self->caps) + && !gst_signal_processor_setcaps_pull (self, pad, caps)) + goto setcaps_pull_failed; + /* the whole processor has one caps; if the sample rate changes, let subclass implementations know */ if (!gst_caps_is_equal (caps, self->caps)) { @@ -430,6 +477,11 @@ start_failed: gst_object_unref (self); return FALSE; } +setcaps_pull_failed: + { + gst_object_unref (self); + return FALSE; + } impossible: { g_critical ("something impossible happened"); @@ -438,14 +490,6 @@ impossible: } } -static void -gst_signal_processor_fixate (GstPad * pad, GstCaps * caps) -{ - /* last-ditch attempt at sanity */ - gst_structure_fixate_field_nearest_int - (gst_caps_get_structure (caps, 0), "rate", 44100); -} - static gboolean gst_signal_processor_event (GstPad * pad, GstEvent * event) { @@ -478,32 +522,6 @@ gst_signal_processor_event (GstPad * pad, GstEvent * event) return ret; } -static void -gst_signal_processor_ouija_caps (GstSignalProcessor * self) -{ - GstElement *element; - GstPad *srcpad; - GstCaps *srccaps, *peercaps, *caps; - - /* we have no sink pads, no way to know what caps we should be producing. - guess! */ - - element = GST_ELEMENT (self); - g_return_if_fail (element->sinkpads == NULL); - g_return_if_fail (element->srcpads != NULL); - srcpad = GST_PAD (element->srcpads->data); - - srccaps = gst_pad_get_caps (srcpad); - peercaps = gst_pad_peer_get_caps (srcpad); - caps = gst_caps_intersect (srccaps, peercaps); - gst_caps_unref (srccaps); - gst_caps_unref (peercaps); - gst_caps_truncate (caps); - gst_pad_fixate_caps (srcpad, caps); - gst_signal_processor_setcaps (srcpad, caps); - gst_caps_unref (caps); -} - static guint gst_signal_processor_prepare (GstSignalProcessor * self, guint nframes) { @@ -552,8 +570,6 @@ gst_signal_processor_prepare (GstSignalProcessor * self, guint nframes) } } - if (!self->caps) - gst_signal_processor_ouija_caps (self); g_return_val_if_fail (GST_SIGNAL_PROCESSOR_IS_RUNNING (self), 0); /* now allocate for any remaining outputs */ -- cgit v1.2.1