diff options
author | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2003-01-14 21:00:23 +0000 |
---|---|---|
committer | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2003-01-14 21:00:23 +0000 |
commit | 078248481d0daa452ef839fd79c7c01180b69919 (patch) | |
tree | 29eb8c3575953fc0a838bd65106afaed8a8689c1 /src/post/visualizations/fftscope.c | |
parent | 6cfcc7dcf44b6d974c88c374c0b3a5b7475e503d (diff) | |
download | xine-lib-078248481d0daa452ef839fd79c7c01180b69919.tar.gz xine-lib-078248481d0daa452ef839fd79c7c01180b69919.tar.bz2 |
yet another glue logic for viz plugins. that should fix problems with
jumbo audio buffers (several seconds).
unfortunately it requires an extra data copy, but i don't think that will
make any perceptible difference.
CVS patchset: 3916
CVS date: 2003/01/14 21:00:23
Diffstat (limited to 'src/post/visualizations/fftscope.c')
-rw-r--r-- | src/post/visualizations/fftscope.c | 25 |
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; |