From e422232e6a5235e12fd143481d7d987d201a5208 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Tue, 18 May 2004 03:16:12 +0000 Subject: track number of times the port has being opened. rewiring a closed port won't cause the new destination to be opened. CVS patchset: 6564 CVS date: 2004/05/18 03:16:12 --- src/post/audio/upmix.c | 4 +++- src/post/goom/xine_goom.c | 5 ++++- src/post/visualizations/fftgraph.c | 5 ++++- src/post/visualizations/fftscope.c | 5 ++++- src/post/visualizations/fooviz.c | 5 ++++- src/post/visualizations/oscope.c | 5 ++++- src/xine-engine/post.c | 16 ++++++++++------ src/xine-engine/post.h | 5 ++++- 8 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/post/audio/upmix.c b/src/post/audio/upmix.c index 514475339..129e63f9e 100644 --- a/src/post/audio/upmix.c +++ b/src/post/audio/upmix.c @@ -23,7 +23,7 @@ * It simply creates output channels to match the speaker arrangement. * E.g. Converts Stereo into Surround 5.1 * - * $Id: upmix.c,v 1.11 2004/05/17 21:47:01 jcdutton Exp $ + * $Id: upmix.c,v 1.12 2004/05/18 03:17:02 miguelfreitas Exp $ * */ @@ -184,6 +184,7 @@ static int upmix_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, port->bits = bits; port->rate = rate; port->mode = mode; + port->open_count++; capabilities = port->original_port->get_capabilities(port->original_port); this->ratio = (double)FOO_WIDTH/(double)FOO_HEIGHT; @@ -228,6 +229,7 @@ static void upmix_port_close(xine_audio_port_t *port_gen, xine_stream_t *stream port->stream = NULL; port->original_port->close(port->original_port, stream ); + port->open_count--; _x_post_dec_usage(port); } diff --git a/src/post/goom/xine_goom.c b/src/post/goom/xine_goom.c index 221dd213c..4575e0078 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.51 2004/04/26 17:50:09 mroi Exp $ + * $Id: xine_goom.c,v 1.52 2004/05/18 03:17:02 miguelfreitas Exp $ * * GOOM post plugin. * @@ -364,6 +364,7 @@ static int goom_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, port->bits = bits; port->rate = rate; port->mode = mode; + port->open_count++; this->channels = _x_ao_mode2channels(mode); this->sample_rate = rate; @@ -392,6 +393,8 @@ static void goom_port_close(xine_audio_port_t *port_gen, xine_stream_t *stream ) port->original_port->close(port->original_port, stream ); + port->open_count--; + _x_post_dec_usage(port); } diff --git a/src/post/visualizations/fftgraph.c b/src/post/visualizations/fftgraph.c index 2e905776d..eeb0f246e 100644 --- a/src/post/visualizations/fftgraph.c +++ b/src/post/visualizations/fftgraph.c @@ -20,7 +20,7 @@ * FftGraph Visualization Post Plugin For xine * by Thibaut Mattern (tmattern@noos.fr) * - * $Id: fftgraph.c,v 1.10 2004/02/12 18:25:08 mroi Exp $ + * $Id: fftgraph.c,v 1.11 2004/05/18 03:17:03 miguelfreitas Exp $ * */ @@ -224,6 +224,7 @@ static int fftgraph_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream port->bits = bits; port->rate = rate; port->mode = mode; + port->open_count++; this->ratio = (double)FFTGRAPH_WIDTH / (double)FFTGRAPH_HEIGHT; @@ -304,6 +305,8 @@ static void fftgraph_port_close(xine_audio_port_t *port_gen, xine_stream_t *stre port->original_port->close(port->original_port, stream ); + port->open_count--; + _x_post_dec_usage(port); } diff --git a/src/post/visualizations/fftscope.c b/src/post/visualizations/fftscope.c index eb0f2b2f1..d2a98bb9f 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.25 2004/02/12 18:25:08 mroi Exp $ + * $Id: fftscope.c,v 1.26 2004/05/18 03:17:03 miguelfreitas Exp $ * */ @@ -284,6 +284,7 @@ static int fftscope_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream port->bits = bits; port->rate = rate; port->mode = mode; + port->open_count++; this->ratio = (double)FFT_WIDTH/(double)FFT_HEIGHT; @@ -325,6 +326,8 @@ static void fftscope_port_close(xine_audio_port_t *port_gen, xine_stream_t *stre port->original_port->close(port->original_port, stream ); + port->open_count--; + _x_post_dec_usage(port); } diff --git a/src/post/visualizations/fooviz.c b/src/post/visualizations/fooviz.c index f05689592..d4d671749 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.21 2004/04/17 19:54:32 mroi Exp $ + * $Id: fooviz.c,v 1.22 2004/05/18 03:17:03 miguelfreitas Exp $ * */ @@ -116,6 +116,7 @@ static int fooviz_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, port->bits = bits; port->rate = rate; port->mode = mode; + port->open_count++; this->ratio = (double)FOO_WIDTH/(double)FOO_HEIGHT; this->channels = _x_ao_mode2channels(mode); @@ -140,6 +141,8 @@ static void fooviz_port_close(xine_audio_port_t *port_gen, xine_stream_t *stream port->original_port->close(port->original_port, stream ); + port->open_count--; + _x_post_dec_usage(port); } diff --git a/src/post/visualizations/oscope.c b/src/post/visualizations/oscope.c index ab9cf7396..44204a0b3 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.17 2004/02/12 18:25:08 mroi Exp $ + * $Id: oscope.c,v 1.18 2004/05/18 03:17:03 miguelfreitas Exp $ * */ @@ -186,6 +186,7 @@ static int oscope_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, port->bits = bits; port->rate = rate; port->mode = mode; + port->open_count++; this->ratio = (double)OSCOPE_WIDTH/(double)OSCOPE_HEIGHT; @@ -214,6 +215,8 @@ static void oscope_port_close(xine_audio_port_t *port_gen, xine_stream_t *stream port->original_port->close(port->original_port, stream ); + port->open_count--; + _x_post_dec_usage(port); } diff --git a/src/xine-engine/post.c b/src/xine-engine/post.c index 88dc4bdc3..7fc7a8f91 100644 --- a/src/xine-engine/post.c +++ b/src/xine-engine/post.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: post.c,v 1.24 2004/05/18 02:01:39 miguelfreitas Exp $ + * $Id: post.c,v 1.25 2004/05/18 03:16:12 miguelfreitas Exp $ */ /* @@ -619,6 +619,7 @@ static int post_audio_open(xine_audio_port_t *port_gen, xine_stream_t *stream, port->bits = bits; port->rate = rate; port->mode = mode; + port->open_count++; return result; } @@ -649,6 +650,7 @@ static void post_audio_close(xine_audio_port_t *port_gen, xine_stream_t *stream) port->original_port->close(port->original_port, stream); if (port->port_lock) pthread_mutex_unlock(port->port_lock); port->stream = NULL; + port->open_count--; _x_post_dec_usage(port); } @@ -707,10 +709,12 @@ static int post_audio_rewire(xine_post_out_t *output_gen, void *data) { this->running_ticket->revoke(this->running_ticket, 1); - new_port->open(new_port, (input_port->stream == POST_NULL_STREAM) ? NULL : input_port->stream, - input_port->bits, input_port->rate, input_port->mode); - input_port->original_port->close(input_port->original_port, - (input_port->stream == POST_NULL_STREAM) ? NULL : input_port->stream); + if( input_port->open_count ) { + new_port->open(new_port, (input_port->stream == POST_NULL_STREAM) ? NULL : input_port->stream, + input_port->bits, input_port->rate, input_port->mode); + input_port->original_port->close(input_port->original_port, + (input_port->stream == POST_NULL_STREAM) ? NULL : input_port->stream); + } input_port->original_port = new_port; this->running_ticket->issue(this->running_ticket, 1); @@ -764,7 +768,7 @@ post_audio_port_t *_x_post_intercept_audio_port(post_plugin_t *post, xine_audio_ xine_list_append_content(post->output, *output); } - original->status(original, port->stream, &port->bits, &port->rate, &port->mode); + port->open_count = 0; return port; } diff --git a/src/xine-engine/post.h b/src/xine-engine/post.h index 2823ad11b..e5cc9acf2 100644 --- a/src/xine-engine/post.h +++ b/src/xine-engine/post.h @@ -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: post.h,v 1.19 2004/04/17 19:54:31 mroi Exp $ + * $Id: post.h,v 1.20 2004/05/18 03:16:12 miguelfreitas Exp $ * * post plugin definitions * @@ -306,6 +306,9 @@ struct post_audio_port_s { uint32_t rate; uint32_t mode; + /* ++ for every open, -- for every close */ + int open_count; + /* point to a mutex here, if you need some synchronization */ pthread_mutex_t *port_lock; -- cgit v1.2.3