diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/post/goom/xine_goom.c | 25 | ||||
-rw-r--r-- | src/post/visualizations/fftscope.c | 25 | ||||
-rw-r--r-- | src/post/visualizations/fooviz.c | 25 | ||||
-rw-r--r-- | src/post/visualizations/oscope.c | 29 |
4 files changed, 94 insertions, 10 deletions
diff --git a/src/post/goom/xine_goom.c b/src/post/goom/xine_goom.c index 70e976bd6..7f8e45dbd 100644 --- a/src/post/goom/xine_goom.c +++ b/src/post/goom/xine_goom.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_goom.c,v 1.20 2003/01/06 22:18:24 tmattern Exp $ + * $Id: xine_goom.c,v 1.21 2003/01/14 21:00:23 miguelfreitas Exp $ * * GOOM post plugin. * @@ -73,6 +73,7 @@ struct post_plugin_goom_s { int data_idx; gint16 data [2][512]; + audio_buffer_t buf; /* dummy buffer just to hold a copy of audio data */ int bits; int mode; @@ -206,6 +207,8 @@ static post_plugin_t *goom_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 = goom_port_open; @@ -279,6 +282,8 @@ static void goom_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); } @@ -381,6 +386,23 @@ static void goom_port_put_buffer (xine_audio_port_t *port_gen, uint64_t vpts = buf->vpts; int i, j; uint8_t *dest_ptr; + + /* 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; @@ -488,5 +510,4 @@ static void goom_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 ); } 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; 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; diff --git a/src/post/visualizations/oscope.c b/src/post/visualizations/oscope.c index 237b7ad15..cec79d99e 100644 --- a/src/post/visualizations/oscope.c +++ b/src/post/visualizations/oscope.c @@ -20,7 +20,7 @@ * Basic Oscilloscope Visualization Post Plugin For xine * by Mike Melanson (melanson@pcisys.net) * - * $Id: oscope.c,v 1.2 2003/01/05 15:05:55 miguelfreitas Exp $ + * $Id: oscope.c,v 1.3 2003/01/14 21:00:42 miguelfreitas Exp $ * */ @@ -48,7 +48,8 @@ struct post_plugin_oscope_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; int channels; @@ -268,7 +269,24 @@ static void oscope_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; j = (this->channels >= 2) ? 1 : 0; @@ -318,7 +336,6 @@ static void oscope_port_put_buffer (xine_audio_port_t *port_gen, } } while( this->sample_counter >= this->samples_per_frame ); - port->original_port->put_buffer(port->original_port, buf, stream ); } static void oscope_dispose(post_plugin_t *this_gen) @@ -336,6 +353,8 @@ static void oscope_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); } @@ -362,6 +381,8 @@ static post_plugin_t *oscope_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 = oscope_port_open; |