diff options
author | Tim-Philipp Müller <tim@centricular.net> | 2006-10-06 11:31:11 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.net> | 2006-10-06 11:31:11 +0000 |
commit | bd2773206d47f2aff574e01b120ea7919c5bb069 (patch) | |
tree | 26b0d0f0135c7c22e778df639ab81df6dd4c129c /gst/spectrum | |
parent | 538303c8aa40f063011410e081396375493b2e4f (diff) | |
download | gst-plugins-bad-bd2773206d47f2aff574e01b120ea7919c5bb069.tar.gz gst-plugins-bad-bd2773206d47f2aff574e01b120ea7919c5bb069.tar.bz2 gst-plugins-bad-bd2773206d47f2aff574e01b120ea7919c5bb069.zip |
gst/spectrum/gstspectrum.c: Fix mem leak, avoid unnecessary memcpy.
Original commit message from CVS:
* gst/spectrum/gstspectrum.c: (gst_spectrum_transform_ip):
Fix mem leak, avoid unnecessary memcpy.
Diffstat (limited to 'gst/spectrum')
-rw-r--r-- | gst/spectrum/gstspectrum.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gst/spectrum/gstspectrum.c b/gst/spectrum/gstspectrum.c index 390bd062..70e5ecae 100644 --- a/gst/spectrum/gstspectrum.c +++ b/gst/spectrum/gstspectrum.c @@ -355,7 +355,6 @@ static GstFlowReturn gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * in) { GstSpectrum *spectrum = GST_SPECTRUM (trans); - gint16 *samples; gint wanted; gint i, j, k; gint32 acc; @@ -373,9 +372,10 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * in) /* FIXME: 4.0 was 2.0 before, but that include the mirrored spectrum */ step = (gfloat) spectrum->len / (spectrum->bands * 4.0); - while (gst_adapter_available (spectrum->adapter) > wanted) { + while (gst_adapter_available (spectrum->adapter) >= wanted) { + const gint16 *samples; - samples = (gint16 *) gst_adapter_take (spectrum->adapter, wanted); + samples = (const gint16 *) gst_adapter_peek (spectrum->adapter, wanted); for (i = 0, j = 0; i < spectrum->len; i++) { for (k = 0, acc = 0; k < spectrum->channels; k++) @@ -413,6 +413,8 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * in) } spectrum->num_frames = 0; } + + gst_adapter_flush (spectrum->adapter, wanted); } return GST_FLOW_OK; |