summaryrefslogtreecommitdiff
path: root/src/post/visualizations/fftscope.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/post/visualizations/fftscope.c')
-rw-r--r--src/post/visualizations/fftscope.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/post/visualizations/fftscope.c b/src/post/visualizations/fftscope.c
index e95fd1f64..736f07366 100644
--- a/src/post/visualizations/fftscope.c
+++ b/src/post/visualizations/fftscope.c
@@ -22,7 +22,7 @@
*
* FFT code by Steve Haehnichen, originally licensed under GPL v1
*
- * $Id: fftscope.c,v 1.2 2003/01/14 06:30:43 tmmm Exp $
+ * $Id: fftscope.c,v 1.3 2003/01/14 21:00:29 miguelfreitas Exp $
*
*/
@@ -59,6 +59,7 @@ struct post_plugin_fftscope_s {
int data_idx;
complex wave[2][NUMSAMPLES];
+ audio_buffer_t buf; /* dummy buffer just to hold a copy of audio data */
int bits;
int mode;
@@ -463,6 +464,23 @@ static void fftscope_port_put_buffer (xine_audio_port_t *port_gen,
int samples_used = 0;
uint64_t vpts = buf->vpts;
int i, j;
+
+ /* make a copy of buf data for private use */
+ if( this->buf.mem_size < buf->mem_size ) {
+ this->buf.mem = realloc(this->buf.mem, buf->mem_size);
+ this->buf.mem_size = buf->mem_size;
+ }
+ memcpy(this->buf.mem, buf->mem,
+ buf->num_frames*this->channels*((this->bits == 8)?1:2));
+ this->buf.num_frames = buf->num_frames;
+
+ /* pass data to original port */
+ port->original_port->put_buffer(port->original_port, buf, stream );
+
+ /* we must not use original data anymore, it should have already being moved
+ * to the fifo of free audio buffers. just use our private copy instead.
+ */
+ buf = &this->buf;
this->sample_counter += buf->num_frames;
@@ -515,7 +533,6 @@ static void fftscope_port_put_buffer (xine_audio_port_t *port_gen,
frame->free(frame);
}
} while( this->sample_counter >= this->samples_per_frame );
- port->original_port->put_buffer(port->original_port, buf, stream );
}
static void fftscope_dispose(post_plugin_t *this_gen)
@@ -533,6 +550,8 @@ static void fftscope_dispose(post_plugin_t *this_gen)
free(xine_list_first_content(this->post.output));
xine_list_free(this->post.input);
xine_list_free(this->post.output);
+ if(this->buf.mem)
+ free(this->buf.mem);
free(this);
}
@@ -559,6 +578,8 @@ static post_plugin_t *fftscope_open_plugin(post_class_t *class_gen, int inputs,
this->sample_counter = 0;
this->stream = NULL;
this->vo_port = video_target[0];
+ this->buf.mem = NULL;
+ this->buf.mem_size = 0;
port = post_intercept_audio_port(&this->post, audio_target[0]);
port->port.open = fftscope_port_open;