From 058c63d1852fc5b3b92e88b1588433d5b11dc7f1 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Fri, 12 Aug 2011 16:57:49 +0200 Subject: [PATCH] spectrascope: make a copy of the audiodata before downmixing and windowing The buffers come from the adapter and the data might overlap. We don't want to modify it in place. --- gst/audiovisualizers/gstspectrascope.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gst/audiovisualizers/gstspectrascope.c b/gst/audiovisualizers/gstspectrascope.c index 9ab5419833..4ebc7a15b2 100644 --- a/gst/audiovisualizers/gstspectrascope.c +++ b/gst/audiovisualizers/gstspectrascope.c @@ -165,7 +165,8 @@ gst_spectra_scope_render (GstBaseAudioVisualizer * bscope, GstBuffer * audio, { GstSpectraScope *scope = GST_SPECTRA_SCOPE (bscope); guint32 *vdata = (guint32 *) GST_BUFFER_DATA (video); - gint16 *adata = (gint16 *) GST_BUFFER_DATA (audio); + gint16 *adata = (gint16 *) g_memdup (GST_BUFFER_DATA (audio), + GST_BUFFER_SIZE (audio)); GstFFTS16Complex *fdata = scope->freq_data; guint x, y, off; guint l, h = bscope->height - 1; @@ -190,6 +191,7 @@ gst_spectra_scope_render (GstBaseAudioVisualizer * bscope, GstBuffer * audio, /* run fft */ gst_fft_s16_window (scope->fft_ctx, adata, GST_FFT_WINDOW_HAMMING); gst_fft_s16_fft (scope->fft_ctx, adata, fdata); + g_free (adata); /* draw lines */ for (x = 0; x < bscope->width; x++) {