From: <wi...@ke...> - 2006-07-31 22:03:25
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wingo Date: Mon Jul 31 2006 22:03:21 UTC Log message: 2006-08-01 Andy Wingo <wi...@po...> * ext/ladspa/gstsignalprocessor.c (gst_signal_processor_init): No more default sample rate, although we never check that the sample rate actually gets set. Something for the future. (gst_signal_processor_setcaps): Some refcount fixes, flow fixes. (gst_signal_processor_event): Refcount fixen. (gst_signal_processor_process): Pull the number of frames to process from the sizes of the buffers in the input pens. (gst_signal_processor_pen_buffer): Remove an incorrect FIXME :) (gst_signal_processor_do_pulls): Add an nframes argument, and use it instead of buffer_frames. (gst_signal_processor_getrange): Refcount fixen, pass nframes on to do_pulls. (gst_signal_processor_chain) (gst_signal_processor_sink_activate_push) (gst_signal_processor_src_activate_pull): Refcount fixen. * ext/ladspa/gstsignalprocessor.h: No more buffer_frames, yay. Modified files: . : ChangeLog ext/ladspa : gstsignalprocessor.c gstsignalprocessor.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.2470&r2=1.2471 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ext/ladspa/gstsignalprocessor.c.diff?r1=1.10&r2=1.11 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ext/ladspa/gstsignalprocessor.h.diff?r1=1.4&r2=1.5 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.2470 retrieving revision 1.2471 diff -u -d -r1.2470 -r1.2471 --- ChangeLog 31 Jul 2006 19:44:18 -0000 1.2470 +++ ChangeLog 31 Jul 2006 22:03:08 -0000 1.2471 @@ -1,3 +1,23 @@ +2006-08-01 Andy Wingo <wi...@po...> + + * ext/ladspa/gstsignalprocessor.c (gst_signal_processor_init): No + more default sample rate, although we never check that the sample + rate actually gets set. Something for the future. + (gst_signal_processor_setcaps): Some refcount fixes, flow fixes. + (gst_signal_processor_event): Refcount fixen. + (gst_signal_processor_process): Pull the number of frames to + process from the sizes of the buffers in the input pens. + (gst_signal_processor_pen_buffer): Remove an incorrect FIXME :) + (gst_signal_processor_do_pulls): Add an nframes argument, and use + it instead of buffer_frames. + (gst_signal_processor_getrange): Refcount fixen, pass nframes on + to do_pulls. + (gst_signal_processor_chain) + (gst_signal_processor_sink_activate_push) + (gst_signal_processor_src_activate_pull): Refcount fixen. + * ext/ladspa/gstsignalprocessor.h: No more buffer_frames, yay. 2006-07-31 Stefan Kost <en...@us...> * ext/ladspa/gstsignalprocessor.c: (gst_signal_processor_setcaps), Index: gstsignalprocessor.c RCS file: /cvs/gstreamer/gst-plugins-good/ext/ladspa/gstsignalprocessor.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- gstsignalprocessor.c 31 Jul 2006 19:44:18 -0000 1.10 +++ gstsignalprocessor.c 31 Jul 2006 22:03:09 -0000 1.11 @@ -237,10 +237,7 @@ self->audio_out = g_new0 (gfloat *, klass->num_audio_out); self->control_out = g_new0 (gfloat, klass->num_control_out); - /* defaults */ - self->sample_rate = 44100; - self->buffer_frames = 16384; - + self->sample_rate = 0; } static void @@ -266,10 +263,11 @@ GstSignalProcessor *self; GstSignalProcessorClass *klass; - self = GST_SIGNAL_PROCESSOR (GST_PAD_PARENT (pad)); + self = GST_SIGNAL_PROCESSOR (gst_pad_get_parent (pad)); klass = GST_SIGNAL_PROCESSOR_GET_CLASS (self); - /* FIXME: why this? */ + /* the whole processor has one caps; if the sample rate changes, let subclass + implementations know */ if (caps != self->caps) { GstStructure *s; gint sample_rate; @@ -277,21 +275,37 @@ s = gst_caps_get_structure (caps, 0); if (!gst_structure_get_int (s, "rate", &sample_rate)) { GST_WARNING ("got no sample-rate"); - return FALSE; + goto impossible; } else { - GST_DEBUG ("Got rate=%d", self->sample_rate); - self->sample_rate = sample_rate; + GST_DEBUG ("Got rate=%d", sample_rate); } if (!klass->setup (self, sample_rate)) + goto setup_failed; + else + self->sample_rate = sample_rate; } else { GST_DEBUG ("skipping, have caps already"); } /* FIXME: handle was_active, etc */ + gst_object_unref (self); return TRUE; +setup_failed: + { + GST_INFO_OBJECT (self, "setup() failed"); + gst_object_unref (self); + return FALSE; + } +impossible: + g_critical ("something impossible happened"); static gboolean @@ -301,14 +315,18 @@ GstSignalProcessorClass *bclass; gboolean ret; bclass = GST_SIGNAL_PROCESSOR_GET_CLASS (self); + /* this probably isn't the correct interface: what about return values, what + about overriding event_default */ if (bclass->event) bclass->event (self, event); ret = gst_pad_event_default (pad, event); return ret; @@ -318,6 +336,7 @@ GstElement *elem; GList *l1, *l2; + guint nframes = G_MAXUINT; g_return_if_fail (self->pending_in == 0); g_return_if_fail (self->pending_out == 0); @@ -326,12 +345,15 @@ /* arrange the output buffers */ for (l1 = elem->sinkpads, l2 = elem->srcpads; l1 || l2; - l1 = l1->next, l2 = l2->next) { + l1 = l1 ? l1->next : NULL, l2 = l2 ? l2->next : NULL) { GstSignalProcessorPad *srcpad, *sinkpad; + if (l1) + nframes = MIN (nframes, GST_BUFFER_SIZE (l1->data) / sizeof (gfloat)); if (!l2) { - /* the output buffers have been covered, yay */ - break; + /* the output buffers have been covered, yay -- just keep looping to check + available frames */ } else if (!l1) { /* need to alloc some output buffers */ for (; l2; l2 = l2->next) { @@ -341,19 +363,21 @@ ret = gst_pad_alloc_buffer_and_set_caps (GST_PAD (srcpad), -1, - self->buffer_frames, GST_PAD_CAPS (srcpad), &srcpad->pen); + nframes, GST_PAD_CAPS (srcpad), &srcpad->pen); if (ret != GST_FLOW_OK) { - GST_WARNING ("gst_pad_alloc_buffer_and_set_caps() returned %d", ret); self->state = ret; - return; + goto flow_error; } else { self->audio_out[srcpad->index] = (gfloat *) GST_BUFFER_DATA (srcpad->pen); self->pending_out++; } } + /* the for condition should cut out because of this, but I assert to be + clear */ + g_assert (l2 == NULL); /* copy input to output */ sinkpad = (GstSignalProcessorPad *) l1->data; @@ -363,21 +387,20 @@ sinkpad->pen = NULL; self->audio_out[srcpad->index] = (gfloat *) GST_BUFFER_DATA (srcpad->pen); self->pending_out++; - /* FIXME: doesn't this need to have: - self->pending_in--; - */ + /* will fail in the ladspa src case, need to check that :-/ */ + g_assert (nframes < G_MAXUINT); - klass->process (self, self->buffer_frames); + klass->process (self, nframes); + /* reset */ self->pending_in = klass->num_audio_in; - GST_DEBUG ("pending in=%d, out=%d", self->pending_in, self->pending_out); /* free unneeded input buffers */ for (l1 = elem->sinkpads; l1; l1 = l1->next) { GstSignalProcessorPad *sinkpad = (GstSignalProcessorPad *) l1->data; @@ -386,6 +409,13 @@ +flow_error: + GST_WARNING ("gst_pad_alloc_buffer_and_set_caps() returned %d", + self->state); + return; @@ -405,9 +435,6 @@ spad->pen = buffer; self->audio_in[spad->index] = (gfloat *) GST_BUFFER_DATA (buffer); - /* FIXME: isn't that bogus? Should it be just: - self->pending_in++; - */ g_assert (self->pending_in != 0); self->pending_in--; @@ -435,7 +462,7 @@ -gst_signal_processor_do_pulls (GstSignalProcessor * self) +gst_signal_processor_do_pulls (GstSignalProcessor * self, guint nframes) { GList *sinkpads; @@ -454,7 +481,7 @@ continue; - ret = gst_pad_pull_range (GST_PAD (spad), -1, self->buffer_frames, &buf); + ret = gst_pad_pull_range (GST_PAD (spad), -1, nframes, &buf); if (ret != GST_FLOW_OK) { self->state = ret; @@ -485,7 +512,7 @@ GstSignalProcessorPad *spad = (GstSignalProcessorPad *) pad; GstFlowReturn ret = GST_FLOW_ERROR; if (spad->pen) { *buffer = spad->pen; @@ -494,8 +521,9 @@ self->pending_out--; ret = GST_FLOW_OK; - gst_signal_processor_do_pulls (self); + gst_signal_processor_do_pulls (self, length); if (!spad->pen) { + /* this is an error condition */ *buffer = NULL; ret = self->state; @@ -506,7 +534,9 @@ - GST_DEBUG ("returns %s", gst_flow_get_name (ret)); + GST_DEBUG_OBJECT (self, "returns %s", gst_flow_get_name (ret)); @@ -554,7 +584,7 @@ gst_signal_processor_pen_buffer (self, pad, buffer); @@ -564,6 +594,8 @@ gst_signal_processor_do_pushes (self); return self->state; @@ -600,7 +632,7 @@ - self = GST_SIGNAL_PROCESSOR (GST_OBJECT_PARENT (pad)); if (active) { @@ -627,6 +659,8 @@ GST_DEBUG ("result : %d", TRUE); return result; @@ -637,7 +671,7 @@ @@ -673,6 +707,8 @@ Index: gstsignalprocessor.h RCS file: /cvs/gstreamer/gst-plugins-good/ext/ladspa/gstsignalprocessor.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gstsignalprocessor.h 8 Apr 2006 18:25:55 -0000 1.4 +++ gstsignalprocessor.h 31 Jul 2006 22:03:09 -0000 1.5 @@ -48,7 +48,6 @@ GstCaps *caps; guint sample_rate; - guint buffer_frames; GstFlowReturn state; |