From 2b5fdf422e62d17fe018bf207aa363402dbbce24 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Sat, 6 Jan 2007 17:22:12 +0000 Subject: ext/ladspa/gstsignalprocessor.c Original commit message from CVS: 2007-01-06 Andy Wingo * ext/ladspa/gstsignalprocessor.c (gst_signal_processor_ouija_caps): Move around in the source file... (gst_signal_processor_prepare, gst_signal_processor_do_pulls): Call ouija_caps in prepare() instead of do_pulls(), a bit earlier. This allows us to have caps when we do the pad_alloc_buffer(). (gst_pad_alloc_buffer_and_set_caps): Use self->caps instead of the pad caps, which might not be set yet. --- ChangeLog | 9 ++++++ ext/ladspa/gstsignalprocessor.c | 62 ++++++++++++++++++++--------------------- 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index e929a2f0..ce2f3734 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2007-01-06 Andy Wingo + * ext/ladspa/gstsignalprocessor.c + (gst_signal_processor_ouija_caps): Move around in the source + file... + (gst_signal_processor_prepare, gst_signal_processor_do_pulls): + Call ouija_caps in prepare() instead of do_pulls(), a bit earlier. + This allows us to have caps when we do the pad_alloc_buffer(). + (gst_pad_alloc_buffer_and_set_caps): Use self->caps instead of the + pad caps, which might not be set yet. + * ext/ladspa/gstsignalprocessor.c: (gst_signal_processor_add_pad_from_template) (gst_signal_processor_fixate): Add a fixate function, to assist in diff --git a/ext/ladspa/gstsignalprocessor.c b/ext/ladspa/gstsignalprocessor.c index 7e025778..e0b92397 100644 --- a/ext/ladspa/gstsignalprocessor.c +++ b/ext/ladspa/gstsignalprocessor.c @@ -478,6 +478,32 @@ 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) { @@ -526,6 +552,10 @@ 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 */ while (srcs) { GstSignalProcessorPad *srcpad; @@ -535,7 +565,7 @@ gst_signal_processor_prepare (GstSignalProcessor * self, guint nframes) ret = gst_pad_alloc_buffer_and_set_caps (GST_PAD (srcpad), -1, - samples_avail * sizeof (gfloat), GST_PAD_CAPS (srcpad), &srcpad->pen); + samples_avail * sizeof (gfloat), self->caps, &srcpad->pen); if (ret != GST_FLOW_OK) { self->flow_state = ret; @@ -591,7 +621,6 @@ gst_signal_processor_process (GstSignalProcessor * self, guint nframes) g_return_if_fail (self->pending_in == 0); g_return_if_fail (self->pending_out == 0); - g_return_if_fail (GST_SIGNAL_PROCESSOR_IS_RUNNING (self)); elem = GST_ELEMENT (self); @@ -672,32 +701,6 @@ gst_signal_processor_flush (GstSignalProcessor * self) self->pending_in = klass->num_audio_in; } -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 void gst_signal_processor_do_pulls (GstSignalProcessor * self, guint nframes) { @@ -735,9 +738,6 @@ gst_signal_processor_do_pulls (GstSignalProcessor * self, guint nframes) } } - if (!self->caps) - gst_signal_processor_ouija_caps (self); - if (self->pending_in != 0) { g_critical ("Something wierd happened..."); self->flow_state = GST_FLOW_ERROR; -- cgit v1.2.1