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/fooviz.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/fooviz.c')
-rw-r--r-- | src/post/visualizations/fooviz.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/post/visualizations/fooviz.c b/src/post/visualizations/fooviz.c index dbfef60bf..443c244cd 100644 --- a/src/post/visualizations/fooviz.c +++ b/src/post/visualizations/fooviz.c @@ -23,7 +23,7 @@ * process. It simply paints the screen a solid color and rotates through * colors on each iteration. * - * $Id: fooviz.c,v 1.2 2003/01/05 23:38:23 tmattern Exp $ + * $Id: fooviz.c,v 1.3 2003/01/14 21:00:36 miguelfreitas Exp $ * */ @@ -51,6 +51,7 @@ struct post_plugin_fooviz_s { int data_idx; short data [2][NUMSAMPLES]; + audio_buffer_t buf; /* dummy buffer just to hold a copy of audio data */ int bits; int mode; @@ -170,6 +171,23 @@ static void fooviz_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; @@ -219,7 +237,6 @@ static void fooviz_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 fooviz_dispose(post_plugin_t *this_gen) @@ -237,6 +254,8 @@ static void fooviz_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); } @@ -263,6 +282,8 @@ static post_plugin_t *fooviz_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 = fooviz_port_open; |