diff options
author | Michael Roitzsch <mroi@users.sourceforge.net> | 2004-05-29 14:45:25 +0000 |
---|---|---|
committer | Michael Roitzsch <mroi@users.sourceforge.net> | 2004-05-29 14:45:25 +0000 |
commit | a74413f06efef91496b3f5b9f749b328ede19ac8 (patch) | |
tree | 4077995d8ad8c0fc3784d9c7d91a40e1b15e731c | |
parent | cd2b6b26d53a8d879250cd28f0dfbb1cf2b04355 (diff) | |
download | xine-lib-a74413f06efef91496b3f5b9f749b328ede19ac8.tar.gz xine-lib-a74413f06efef91496b3f5b9f749b328ede19ac8.tar.bz2 |
separate the two semantics of querying a port's status with a NULL stream;
before, NULL could mean two things: no stream at all or a stream that does not
want to be addressed; now the latter is represented by the new XINE_ANON_STREAM
resulting changes:
* the status() functions now behave differently for NULL and XINE_ANON_STREAM
(as the commentary always implied, but this was not the case, so post
plugin rewiring went wrong, because it relies on the status() function)
* the NULL_STREAM defines in audio_out and video_out are obsolete
* update the function comments in the headers
* update the post plugin rewire functions to use the status() functions to
check, if the old port was opened and handle the new one accordingly;
this makes open_count obsolete
* change all post plugins accordingly (mostly using XINE_ANON_STREAM instead
of NULL)
additional change:
* the status() function of audio port now returns the bits/rate/mode values
of the input and not the output; this is more likely to be what a post plugin
wants
* the reimplementation of status() in the upmix plugin is obsolete
CVS patchset: 6603
CVS date: 2004/05/29 14:45:25
-rw-r--r-- | src/post/audio/upmix.c | 29 | ||||
-rw-r--r-- | src/post/deinterlace/xine_plugin.c | 7 | ||||
-rw-r--r-- | src/post/goom/xine_goom.c | 22 | ||||
-rw-r--r-- | src/post/mosaico/mosaico.c | 4 | ||||
-rw-r--r-- | src/post/mosaico/switch.c | 4 | ||||
-rw-r--r-- | src/post/visualizations/fftgraph.c | 20 | ||||
-rw-r--r-- | src/post/visualizations/fftscope.c | 20 | ||||
-rw-r--r-- | src/post/visualizations/fooviz.c | 20 | ||||
-rw-r--r-- | src/post/visualizations/oscope.c | 20 | ||||
-rw-r--r-- | src/xine-engine/audio_out.c | 15 | ||||
-rw-r--r-- | src/xine-engine/audio_out.h | 9 | ||||
-rw-r--r-- | src/xine-engine/post.c | 40 | ||||
-rw-r--r-- | src/xine-engine/post.h | 15 | ||||
-rw-r--r-- | src/xine-engine/video_out.c | 23 | ||||
-rw-r--r-- | src/xine-engine/video_out.h | 12 | ||||
-rw-r--r-- | src/xine-engine/xine_internal.h | 5 |
16 files changed, 106 insertions, 159 deletions
diff --git a/src/post/audio/upmix.c b/src/post/audio/upmix.c index 091a39b0c..e08174995 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.13 2004/05/23 16:20:56 mroi Exp $ + * $Id: upmix.c,v 1.14 2004/05/29 14:45:25 mroi Exp $ * */ @@ -177,14 +177,10 @@ static int upmix_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, _x_post_rewire(&this->post); _x_post_inc_usage(port); - if (stream) - port->stream = stream; - else - port->stream = POST_NULL_STREAM; + port->stream = 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; @@ -223,15 +219,16 @@ static int upmix_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, return port->original_port->open(port->original_port, stream, bits, rate, mode ); } +#if 0 static void upmix_port_close(xine_audio_port_t *port_gen, xine_stream_t *stream ) { post_audio_port_t *port = (post_audio_port_t *)port_gen; port->stream = NULL; port->original_port->close(port->original_port, stream ); - port->open_count--; _x_post_dec_usage(port); } +#endif static int upmix_frames_2to51_any_to_float( uint8_t *dst8, uint8_t *src8, int num_frames, int step_channel_in, af_sub_t *sub) { float *dst=(float *)dst8; @@ -383,19 +380,6 @@ static void upmix_port_put_buffer (xine_audio_port_t *port_gen, return; } -static int upmix_port_audio_status(xine_audio_port_t *port_gen, xine_stream_t *stream, - uint32_t *bits, uint32_t *rate, int *mode) { - post_audio_port_t *port = (post_audio_port_t *)port_gen; - - if (port->port_lock) pthread_mutex_lock(port->port_lock); - *bits = port->bits; - *rate = port->rate; - *mode = port->mode; - if (port->port_lock) pthread_mutex_unlock(port->port_lock); - return 1; -} - - static void upmix_dispose(post_plugin_t *this_gen) { post_plugin_upmix_t *this = (post_plugin_upmix_t *)this_gen; @@ -414,7 +398,7 @@ static post_plugin_t *upmix_open_plugin(post_class_t *class_gen, int inputs, post_plugin_upmix_t *this = (post_plugin_upmix_t *)xine_xmalloc(sizeof(post_plugin_upmix_t)); post_in_t *input; post_out_t *output; - xine_post_in_t *input_api; + xine_post_in_t *input_api; post_audio_port_t *port; if (!this || !audio_target || !audio_target[0] ) { @@ -428,9 +412,10 @@ static post_plugin_t *upmix_open_plugin(post_class_t *class_gen, int inputs, port = _x_post_intercept_audio_port(&this->post, audio_target[0], &input, &output); port->new_port.open = upmix_port_open; +#if 0 port->new_port.close = upmix_port_close; +#endif port->new_port.put_buffer = upmix_port_put_buffer; - port->new_port.status = upmix_port_audio_status; input_api = &this->params_input; input_api->name = "parameters"; diff --git a/src/post/deinterlace/xine_plugin.c b/src/post/deinterlace/xine_plugin.c index f44a7a213..21ffd0634 100644 --- a/src/post/deinterlace/xine_plugin.c +++ b/src/post/deinterlace/xine_plugin.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_plugin.c,v 1.31 2004/04/17 19:54:31 mroi Exp $ + * $Id: xine_plugin.c,v 1.32 2004/05/29 14:45:25 mroi Exp $ * * advanced video deinterlacer plugin * Jun/2003 by Miguel Freitas @@ -468,10 +468,7 @@ static void deinterlace_open(xine_video_port_t *port_gen, xine_stream_t *stream) _x_post_rewire(&this->post); _x_post_inc_usage(port); - if (stream) - port->stream = stream; - else - port->stream = POST_NULL_STREAM; + port->stream = stream; port->original_port->open(port->original_port, stream); port->original_port->set_property(port->original_port, XINE_PARAM_VO_DEINTERLACE, diff --git a/src/post/goom/xine_goom.c b/src/post/goom/xine_goom.c index 4575e0078..45f90925d 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.52 2004/05/18 03:17:02 miguelfreitas Exp $ + * $Id: xine_goom.c,v 1.53 2004/05/29 14:45:26 mroi Exp $ * * GOOM post plugin. * @@ -341,8 +341,8 @@ static int goom_rewire_video(xine_post_out_t *output_gen, void *data) if (!data) return 0; /* register our stream at the new output port */ - old_port->close(old_port, NULL); - new_port->open(new_port, NULL); + old_port->close(old_port, XINE_ANON_STREAM); + new_port->open(new_port, XINE_ANON_STREAM); /* reconnect ourselves */ this->vo_port = new_port; return 1; @@ -357,14 +357,10 @@ static int goom_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, _x_post_rewire(&this->post); _x_post_inc_usage(port); - if (stream) - port->stream = stream; - else - port->stream = POST_NULL_STREAM; + port->stream = stream; port->bits = bits; port->rate = rate; port->mode = mode; - port->open_count++; this->channels = _x_ao_mode2channels(mode); this->sample_rate = rate; @@ -373,7 +369,7 @@ static int goom_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, init_yuv_planes(&this->yuv, this->width, this->height); this->skip_frame = 0; - this->vo_port->open(this->vo_port, NULL); + this->vo_port->open(this->vo_port, XINE_ANON_STREAM); this->metronom->set_master(this->metronom, stream->metronom); return port->original_port->open(port->original_port, stream, bits, rate, mode ); @@ -388,13 +384,11 @@ static void goom_port_close(xine_audio_port_t *port_gen, xine_stream_t *stream ) port->stream = NULL; - this->vo_port->close(this->vo_port, NULL); + this->vo_port->close(this->vo_port, XINE_ANON_STREAM); this->metronom->set_master(this->metronom, NULL); port->original_port->close(port->original_port, stream ); - port->open_count--; - _x_post_dec_usage(port); } @@ -535,10 +529,10 @@ static void goom_port_put_buffer (xine_audio_port_t *port_gen, } } - this->skip_frame = frame->draw(frame, NULL); + this->skip_frame = frame->draw(frame, XINE_ANON_STREAM); } else { frame->bad_frame = 1; - frame->draw(frame, NULL); + frame->draw(frame, XINE_ANON_STREAM); this->skip_frame--; } frame->free(frame); diff --git a/src/post/mosaico/mosaico.c b/src/post/mosaico/mosaico.c index 31a55dc99..67b9e3e5d 100644 --- a/src/post/mosaico/mosaico.c +++ b/src/post/mosaico/mosaico.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: mosaico.c,v 1.23 2004/04/17 19:54:31 mroi Exp $ + * $Id: mosaico.c,v 1.24 2004/05/29 14:45:26 mroi Exp $ */ /* @@ -294,7 +294,7 @@ static void mosaico_close(xine_video_port_t *port_gen, xine_stream_t *stream) pthread_mutex_lock(&this->mutex); free_frame = this->pip[pip_num].frame; this->pip[pip_num].frame = NULL; - port->original_port->close(port->original_port, NULL); + port->original_port->close(port->original_port, port->stream); pthread_mutex_unlock(&this->mutex); if (free_frame) diff --git a/src/post/mosaico/switch.c b/src/post/mosaico/switch.c index ce4a8cd85..e63275d06 100644 --- a/src/post/mosaico/switch.c +++ b/src/post/mosaico/switch.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: switch.c,v 1.13 2004/04/17 19:54:31 mroi Exp $ + * $Id: switch.c,v 1.14 2004/05/29 14:45:26 mroi Exp $ */ /* @@ -253,7 +253,7 @@ static int switch_draw(vo_frame_t *frame, xine_stream_t *stream) pthread_cond_wait(&this->display_condition_changed, &this->mutex); if (this->selected_source == source_num) { _x_post_frame_copy_down(frame, frame->next); - skip = frame->next->draw(frame->next, NULL); + skip = frame->next->draw(frame->next, XINE_ANON_STREAM); _x_post_frame_copy_up(frame, frame->next); this->vpts_limit = frame->vpts + frame->duration; if (skip) { diff --git a/src/post/visualizations/fftgraph.c b/src/post/visualizations/fftgraph.c index eeb0f246e..1b88b4521 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.11 2004/05/18 03:17:03 miguelfreitas Exp $ + * $Id: fftgraph.c,v 1.12 2004/05/29 14:45:26 mroi Exp $ * */ @@ -196,8 +196,8 @@ static int fftgraph_rewire_video(xine_post_out_t *output_gen, void *data) if (!data) return 0; /* register our stream at the new output port */ - old_port->close(old_port, NULL); - new_port->open(new_port, NULL); + old_port->close(old_port, XINE_ANON_STREAM); + new_port->open(new_port, XINE_ANON_STREAM); /* reconnect ourselves */ this->vo_port = new_port; return 1; @@ -217,14 +217,10 @@ static int fftgraph_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream _x_post_rewire(&this->post); _x_post_inc_usage(port); - if (stream) - port->stream = stream; - else - port->stream = POST_NULL_STREAM; + port->stream = stream; port->bits = bits; port->rate = rate; port->mode = mode; - port->open_count++; this->ratio = (double)FFTGRAPH_WIDTH / (double)FFTGRAPH_HEIGHT; @@ -235,7 +231,7 @@ static int fftgraph_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream this->samples_per_frame = rate / FPS; this->data_idx = 0; - this->vo_port->open(this->vo_port, NULL); + this->vo_port->open(this->vo_port, XINE_ANON_STREAM); this->metronom->set_master(this->metronom, stream->metronom); this->fft = fft_new(FFT_BITS); @@ -300,13 +296,11 @@ static void fftgraph_port_close(xine_audio_port_t *port_gen, xine_stream_t *stre fft_dispose(this->fft); this->fft = NULL; - this->vo_port->close(this->vo_port, NULL); + this->vo_port->close(this->vo_port, XINE_ANON_STREAM); this->metronom->set_master(this->metronom, NULL); port->original_port->close(port->original_port, stream ); - port->open_count--; - _x_post_dec_usage(port); } @@ -387,7 +381,7 @@ static void fftgraph_port_put_buffer (xine_audio_port_t *port_gen, draw_fftgraph(this, frame); - frame->draw(frame, NULL); + frame->draw(frame, XINE_ANON_STREAM); frame->free(frame); } } while( this->sample_counter >= this->samples_per_frame ); diff --git a/src/post/visualizations/fftscope.c b/src/post/visualizations/fftscope.c index d2a98bb9f..95ed6969e 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.26 2004/05/18 03:17:03 miguelfreitas Exp $ + * $Id: fftscope.c,v 1.27 2004/05/29 14:45:26 mroi Exp $ * */ @@ -260,8 +260,8 @@ static int fftscope_rewire_video(xine_post_out_t *output_gen, void *data) if (!data) return 0; /* register our stream at the new output port */ - old_port->close(old_port, NULL); - new_port->open(new_port, NULL); + old_port->close(old_port, XINE_ANON_STREAM); + new_port->open(new_port, XINE_ANON_STREAM); /* reconnect ourselves */ this->vo_port = new_port; return 1; @@ -277,14 +277,10 @@ static int fftscope_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream _x_post_rewire(&this->post); _x_post_inc_usage(port); - if (stream) - port->stream = stream; - else - port->stream = POST_NULL_STREAM; + port->stream = stream; port->bits = bits; port->rate = rate; port->mode = mode; - port->open_count++; this->ratio = (double)FFT_WIDTH/(double)FFT_HEIGHT; @@ -295,7 +291,7 @@ static int fftscope_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream this->data_idx = 0; this->fft = fft_new(FFT_BITS); - this->vo_port->open(this->vo_port, NULL); + this->vo_port->open(this->vo_port, XINE_ANON_STREAM); this->metronom->set_master(this->metronom, stream->metronom); for (c = 0; c < this->channels; c++) { @@ -321,13 +317,11 @@ static void fftscope_port_close(xine_audio_port_t *port_gen, xine_stream_t *stre fft_dispose(this->fft); this->fft = NULL; - this->vo_port->close(this->vo_port, NULL); + this->vo_port->close(this->vo_port, XINE_ANON_STREAM); this->metronom->set_master(this->metronom, NULL); port->original_port->close(port->original_port, stream ); - port->open_count--; - _x_post_dec_usage(port); } @@ -408,7 +402,7 @@ static void fftscope_port_put_buffer (xine_audio_port_t *port_gen, draw_fftscope(this, frame); - frame->draw(frame, NULL); + frame->draw(frame, XINE_ANON_STREAM); frame->free(frame); } } while( this->sample_counter >= this->samples_per_frame ); diff --git a/src/post/visualizations/fooviz.c b/src/post/visualizations/fooviz.c index d4d671749..08fa83c4f 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.22 2004/05/18 03:17:03 miguelfreitas Exp $ + * $Id: fooviz.c,v 1.23 2004/05/29 14:45:26 mroi Exp $ * */ @@ -93,8 +93,8 @@ static int fooviz_rewire_video(xine_post_out_t *output_gen, void *data) if (!data) return 0; /* register our stream at the new output port */ - old_port->close(old_port, NULL); - new_port->open(new_port, NULL); + old_port->close(old_port, XINE_ANON_STREAM); + new_port->open(new_port, XINE_ANON_STREAM); /* reconnect ourselves */ this->vo_port = new_port; return 1; @@ -109,21 +109,17 @@ static int fooviz_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, _x_post_rewire(&this->post); _x_post_inc_usage(port); - if (stream) - port->stream = stream; - else - port->stream = POST_NULL_STREAM; + port->stream = 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); this->samples_per_frame = rate / FPS; this->data_idx = 0; - this->vo_port->open(this->vo_port, NULL); + this->vo_port->open(this->vo_port, XINE_ANON_STREAM); this->metronom->set_master(this->metronom, stream->metronom); return port->original_port->open(port->original_port, stream, bits, rate, mode ); @@ -136,13 +132,11 @@ static void fooviz_port_close(xine_audio_port_t *port_gen, xine_stream_t *stream port->stream = NULL; - this->vo_port->close(this->vo_port, NULL); + this->vo_port->close(this->vo_port, XINE_ANON_STREAM); this->metronom->set_master(this->metronom, NULL); port->original_port->close(port->original_port, stream ); - port->open_count--; - _x_post_dec_usage(port); } @@ -222,7 +216,7 @@ static void fooviz_port_put_buffer (xine_audio_port_t *port_gen, memset(frame->base[0], this->current_yuv_byte, FOO_WIDTH * FOO_HEIGHT * 2); this->current_yuv_byte += 3; - frame->draw(frame, NULL); + frame->draw(frame, XINE_ANON_STREAM); frame->free(frame); } } while( this->sample_counter >= this->samples_per_frame ); diff --git a/src/post/visualizations/oscope.c b/src/post/visualizations/oscope.c index 44204a0b3..93041e393 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.18 2004/05/18 03:17:03 miguelfreitas Exp $ + * $Id: oscope.c,v 1.19 2004/05/29 14:45:26 mroi Exp $ * */ @@ -163,8 +163,8 @@ static int oscope_rewire_video(xine_post_out_t *output_gen, void *data) if (!data) return 0; - old_port->close(old_port, NULL); - new_port->open(new_port, NULL); + old_port->close(old_port, XINE_ANON_STREAM); + new_port->open(new_port, XINE_ANON_STREAM); /* reconnect ourselves */ this->vo_port = new_port; return 1; @@ -179,14 +179,10 @@ static int oscope_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, _x_post_rewire(&this->post); _x_post_inc_usage(port); - if (stream) - port->stream = stream; - else - port->stream = POST_NULL_STREAM; + port->stream = stream; port->bits = bits; port->rate = rate; port->mode = mode; - port->open_count++; this->ratio = (double)OSCOPE_WIDTH/(double)OSCOPE_HEIGHT; @@ -197,7 +193,7 @@ static int oscope_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, this->data_idx = 0; init_yuv_planes(&this->yuv, OSCOPE_WIDTH, OSCOPE_HEIGHT); - this->vo_port->open(this->vo_port, NULL); + this->vo_port->open(this->vo_port, XINE_ANON_STREAM); this->metronom->set_master(this->metronom, stream->metronom); return port->original_port->open(port->original_port, stream, bits, rate, mode ); @@ -210,13 +206,11 @@ static void oscope_port_close(xine_audio_port_t *port_gen, xine_stream_t *stream port->stream = NULL; - this->vo_port->close(this->vo_port, NULL); + this->vo_port->close(this->vo_port, XINE_ANON_STREAM); this->metronom->set_master(this->metronom, NULL); port->original_port->close(port->original_port, stream ); - port->open_count--; - _x_post_dec_usage(port); } @@ -292,7 +286,7 @@ static void oscope_port_put_buffer (xine_audio_port_t *port_gen, draw_oscope_dots(this); yuv444_to_yuy2(&this->yuv, frame->base[0], frame->pitches[0]); - frame->draw(frame, NULL); + frame->draw(frame, XINE_ANON_STREAM); frame->free(frame); } diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index ea0a1642a..adf87b658 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -17,7 +17,7 @@ * along with self program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_out.c,v 1.177 2004/05/21 13:41:02 tmattern Exp $ + * $Id: audio_out.c,v 1.178 2004/05/29 14:45:25 mroi Exp $ * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe <andy@alsaplayer.org> @@ -100,8 +100,6 @@ #define ZERO_BUF_SIZE 5000 -#define NULL_STREAM (xine_stream_t *)-1 - /* By adding gap errors (difference between reported and expected * sound card clock) into metronom's vpts_offset we can use its * smoothing algorithms to correct sound card clock drifts. @@ -1092,7 +1090,7 @@ static void *ao_loop (void *this_gen) { pthread_mutex_lock(&this->streams_lock); for (stream = xine_list_first_content(this->streams); stream; stream = xine_list_next_content(this->streams)) { - if (stream == NULL_STREAM) continue; + if (stream == XINE_ANON_STREAM) continue; stream->metronom->set_option(stream->metronom, METRONOM_ADJ_VPTS_OFFSET, -gap/SYNC_GAP_RATE ); last_sync_time = cur_time; @@ -1190,7 +1188,7 @@ int xine_get_next_audio_frame (xine_audio_port_t *this_gen, in_buf = this->out_fifo->first; if (!in_buf) { pthread_mutex_unlock(&this->out_fifo->mutex); - if (stream != NULL_STREAM && stream->audio_fifo->fifo_size == 0 && + if (stream != XINE_ANON_STREAM && stream->audio_fifo->fifo_size == 0 && stream->demux_plugin->get_status(stream->demux_plugin) !=DEMUX_OK) /* no further data can be expected here */ return 0; @@ -1370,7 +1368,6 @@ static int ao_open(xine_audio_port_t *this_gen, xine_stream_t *stream, stream->metronom->set_audio_rate(stream->metronom, this->audio_step); } - if (stream == NULL) stream = NULL_STREAM; pthread_mutex_lock(&this->streams_lock); xine_list_append_content(this->streams, stream); pthread_mutex_unlock(&this->streams_lock); @@ -1403,6 +1400,9 @@ static void ao_put_buffer (xine_audio_port_t *this_gen, return; } + /* handle anonymous streams like NULL for easy checking */ + if (stream == XINE_ANON_STREAM) stream = NULL; + buf->stream = stream; pts = buf->vpts; @@ -1438,7 +1438,6 @@ static void ao_close(xine_audio_port_t *this_gen, xine_stream_t *stream) { xprintf (this->xine, XINE_VERBOSITY_DEBUG, "ao_close\n"); /* unregister stream */ - if (stream == NULL) stream = NULL_STREAM; pthread_mutex_lock(&this->streams_lock); for (cur = xine_list_first_content(this->streams); cur; cur = xine_list_next_content(this->streams)) @@ -1808,7 +1807,7 @@ static int ao_status (xine_audio_port_t *this_gen, xine_stream_t *stream, *bits = this->input.bits; *rate = this->input.rate; *mode = this->input.mode; - ret = 1; + ret = !!stream; /* return false for a NULL stream, true otherwise */ break; } pthread_mutex_unlock(&this->streams_lock); diff --git a/src/xine-engine/audio_out.h b/src/xine-engine/audio_out.h index 810b37c9f..fe51d4475 100644 --- a/src/xine-engine/audio_out.h +++ b/src/xine-engine/audio_out.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: audio_out.h,v 1.69 2004/05/23 16:20:56 mroi Exp $ + * $Id: audio_out.h,v 1.70 2004/05/29 14:45:25 mroi Exp $ */ #ifndef HAVE_AUDIO_OUT_H #define HAVE_AUDIO_OUT_H @@ -186,7 +186,7 @@ struct xine_audio_port_s { * return value: 0:failure, >0:output sample rate */ /* when you are not a full-blown stream, but still need to open the port - * (e.g. you are a post plugin) it is legal to pass a NULL stream */ + * (e.g. you are a post plugin) it is legal to pass an anonymous stream */ int (*open) (xine_audio_port_t *, xine_stream_t *stream, uint32_t bits, uint32_t rate, int mode); @@ -199,12 +199,12 @@ struct xine_audio_port_s { * append a buffer filled with audio data to the audio fifo * for output */ - /* when the frame does not originate from a stream, it is legal to pass a NULL stream */ + /* when the frame does not originate from a stream, it is legal to pass an anonymous stream */ void (*put_buffer) (xine_audio_port_t *, audio_buffer_t *buf, xine_stream_t *stream); /* audio driver is no longer used by decoder => close */ /* when you are not a full-blown stream, but still need to close the port - * (e.g. you are a post plugin) it is legal to pass a NULL stream */ + * (e.g. you are a post plugin) it is legal to pass an anonymous stream */ void (*close) (xine_audio_port_t *self, xine_stream_t *stream); /* called on xine exit */ @@ -224,6 +224,7 @@ struct xine_audio_port_s { /* * Check if port is opened for this stream and get parameters. + * The stream can be anonymous. */ int (*status) (xine_audio_port_t *, xine_stream_t *stream, uint32_t *bits, uint32_t *rate, int *mode); diff --git a/src/xine-engine/post.c b/src/xine-engine/post.c index 7fc7a8f91..9f49b2115 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.25 2004/05/18 03:16:12 miguelfreitas Exp $ + * $Id: post.c,v 1.26 2004/05/29 14:45:25 mroi Exp $ */ /* @@ -61,10 +61,7 @@ static void post_video_open(xine_video_port_t *port_gen, xine_stream_t *stream) if (port->port_lock) pthread_mutex_lock(port->port_lock); port->original_port->open(port->original_port, stream); if (port->port_lock) pthread_mutex_unlock(port->port_lock); - if (stream) - port->stream = stream; - else - port->stream = POST_NULL_STREAM; + port->stream = stream; } static vo_frame_t *post_video_get_frame(xine_video_port_t *port_gen, uint32_t width, @@ -189,15 +186,19 @@ static int post_video_rewire(xine_post_out_t *output_gen, void *data) { xine_video_port_t *new_port = (xine_video_port_t *)data; post_video_port_t *input_port = (post_video_port_t *)output->user_data; post_plugin_t *this = output->post; + int64_t img_duration; + int width, height; if (!new_port) return 0; 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->original_port->close(input_port->original_port, - (input_port->stream == POST_NULL_STREAM) ? NULL : input_port->stream); + if (input_port->original_port->status(input_port->original_port, input_port->stream, + &width, &height, &img_duration)) { + new_port->open(new_port, input_port->stream); + input_port->original_port->close(input_port->original_port, input_port->stream); + } input_port->original_port = new_port; this->running_ticket->issue(this->running_ticket, 1); @@ -612,14 +613,10 @@ static int post_audio_open(xine_audio_port_t *port_gen, xine_stream_t *stream, if (port->port_lock) pthread_mutex_lock(port->port_lock); result = port->original_port->open(port->original_port, stream, bits, rate, mode); if (port->port_lock) pthread_mutex_unlock(port->port_lock); - if (stream) - port->stream = stream; - else - port->stream = POST_NULL_STREAM; + port->stream = stream; port->bits = bits; port->rate = rate; port->mode = mode; - port->open_count++; return result; } @@ -650,7 +647,6 @@ 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); } @@ -693,6 +689,9 @@ static int post_audio_status(xine_audio_port_t *port_gen, xine_stream_t *stream, if (port->port_lock) pthread_mutex_lock(port->port_lock); result = port->original_port->status(port->original_port, stream, bits, rate, mode); + *bits = port->bits; + *rate = port->rate; + *mode = port->mode; if (port->port_lock) pthread_mutex_unlock(port->port_lock); return result; } @@ -703,17 +702,18 @@ static int post_audio_rewire(xine_post_out_t *output_gen, void *data) { xine_audio_port_t *new_port = (xine_audio_port_t *)data; post_audio_port_t *input_port = (post_audio_port_t *)output->user_data; post_plugin_t *this = output->post; + uint32_t bits, rate; + int mode; if (!new_port) return 0; this->running_ticket->revoke(this->running_ticket, 1); - 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); + if (input_port->original_port->status(input_port->original_port, input_port->stream, + &bits, &rate, &mode)) { + new_port->open(new_port, input_port->stream, bits, rate, mode); + input_port->original_port->close(input_port->original_port, input_port->stream); } input_port->original_port = new_port; @@ -767,8 +767,6 @@ post_audio_port_t *_x_post_intercept_audio_port(post_plugin_t *post, xine_audio_ (*output)->user_data = port; xine_list_append_content(post->output, *output); } - - port->open_count = 0; return port; } diff --git a/src/xine-engine/post.h b/src/xine-engine/post.h index e5cc9acf2..d30539c60 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.20 2004/05/18 03:16:12 miguelfreitas Exp $ + * $Id: post.h,v 1.21 2004/05/29 14:45:25 mroi Exp $ * * post plugin definitions * @@ -42,8 +42,6 @@ #define POST_PLUGIN_IFACE_VERSION 9 -#define POST_NULL_STREAM (xine_stream_t *)-1 - typedef struct post_class_s post_class_t; typedef struct post_plugin_s post_plugin_t; @@ -199,8 +197,8 @@ struct post_video_port_s { int usage_count; pthread_mutex_t usage_lock; - /* the stream we are being fed by; NULL means no stream is connected, - * POST_NULL_STREAM means a NULL stream is connected */ + /* the stream we are being fed by; NULL means no stream is connected; + * this may be an anonymous stream */ xine_stream_t *stream; /* point to a mutex here, if you need some synchronization */ @@ -297,8 +295,8 @@ struct post_audio_port_s { int usage_count; pthread_mutex_t usage_lock; - /* the stream we are being fed by; NULL means no stream is connected, - * POST_NULL_STREAM means a NULL stream is connected */ + /* the stream we are being fed by; NULL means no stream is connected; + * this may be an anonymous stream */ xine_stream_t *stream; /* some values remembered by port->open() */ @@ -306,9 +304,6 @@ 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; diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index c52b04ad8..0e8b7a7b5 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.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: video_out.c,v 1.194 2004/05/23 21:30:26 tmattern Exp $ + * $Id: video_out.c,v 1.195 2004/05/29 14:45:25 mroi Exp $ * * frame allocation / queuing / scheduling / output functions */ @@ -59,8 +59,6 @@ #define FIRST_FRAME_POLL_DELAY 3000 #define FIRST_FRAME_MAX_POLL 10 /* poll n times at most */ -#define NULL_STREAM (xine_stream_t *)-1 - typedef struct { vo_frame_t *first; vo_frame_t *last; @@ -356,6 +354,9 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { int frames_to_skip; int duration; + /* handle anonymous streams like NULL for easy checking */ + if (stream == XINE_ANON_STREAM) stream = NULL; + img->stream = stream; this->current_width = img->width; this->current_height = img->height; @@ -441,7 +442,7 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { pthread_mutex_lock(&this->streams_lock); for (stream = xine_list_first_content(this->streams); stream; stream = xine_list_next_content(this->streams)) { - if (stream == NULL_STREAM) continue; + if (stream == XINE_ANON_STREAM) continue; pthread_mutex_lock (&stream->first_frame_lock); if (stream->first_frame_flag == 2) { stream->first_frame_flag = (this->grab_only) ? 0 : 1; @@ -493,7 +494,7 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { pthread_mutex_lock(&this->streams_lock); for (stream = xine_list_first_content(this->streams); stream; stream = xine_list_next_content(this->streams)) { - if (stream == NULL_STREAM) continue; + if (stream == XINE_ANON_STREAM) continue; _x_stream_info_set(stream, XINE_STREAM_INFO_SKIPPED_FRAMES, 1000 * this->num_frames_skipped / this->num_frames_delivered); _x_stream_info_set(stream, XINE_STREAM_INFO_DISCARDED_FRAMES, @@ -884,7 +885,7 @@ static void overlay_and_display_frame (vos_t *this, pthread_mutex_lock(&this->streams_lock); for (stream = xine_list_first_content(this->streams); stream; stream = xine_list_next_content(this->streams)) { - if (stream == NULL_STREAM) continue; + if (stream == XINE_ANON_STREAM) continue; pthread_mutex_lock (&stream->first_frame_lock); if (stream->first_frame_flag) { stream->first_frame_flag = 0; @@ -1030,7 +1031,7 @@ static void *video_out_loop (void *this_gen) { pthread_mutex_lock(&this->streams_lock); for (stream = xine_list_first_content(this->streams); stream; stream = xine_list_next_content(this->streams)) { - if (stream == NULL_STREAM) continue; + if (stream == XINE_ANON_STREAM) continue; if (stream->video_decoder_plugin && stream->video_fifo) { buf_element_t *buf; @@ -1144,7 +1145,7 @@ int xine_get_next_video_frame (xine_video_port_t *this_gen, img = this->display_img_buf_queue->first; if (!img) { pthread_mutex_unlock(&this->display_img_buf_queue->mutex); - if (stream != NULL_STREAM && stream->video_fifo->fifo_size == 0 && + if (stream != XINE_ANON_STREAM && stream->video_fifo->fifo_size == 0 && stream->demux_plugin->get_status(stream->demux_plugin) != DEMUX_OK) /* no further data can be expected here */ return 0; @@ -1201,7 +1202,6 @@ static void vo_open (xine_video_port_t *this_gen, xine_stream_t *stream) { if (!this->overlay_enabled && (stream == NULL || stream->spu_channel_user > -2)) /* enable overlays if our new stream might want to show some */ this->overlay_enabled = 1; - if (stream == NULL) stream = NULL_STREAM; pthread_mutex_lock(&this->streams_lock); xine_list_append_content(this->streams, stream); pthread_mutex_unlock(&this->streams_lock); @@ -1219,7 +1219,6 @@ static void vo_close (xine_video_port_t *this_gen, xine_stream_t *stream) { this->video_opened = 0; /* unregister stream */ - if (stream == NULL) stream = NULL_STREAM; pthread_mutex_lock(&this->streams_lock); for (cur = xine_list_first_content(this->streams); cur; cur = xine_list_next_content(this->streams)) @@ -1363,7 +1362,7 @@ static int vo_status (xine_video_port_t *this_gen, xine_stream_t *stream, *width = this->current_width; *height = this->current_height; *img_duration = this->current_duration; - ret = 1; + ret = !!stream; /* return false for a NULL stream, true otherwise */ break; } pthread_mutex_unlock(&this->streams_lock); @@ -1448,7 +1447,7 @@ static void vo_enable_overlay (xine_video_port_t *this_gen, int overlay_enabled) pthread_mutex_lock(&this->streams_lock); for (stream = xine_list_first_content(this->streams) ; stream ; stream = xine_list_next_content(this->streams)) { - if (stream == NULL_STREAM || stream->spu_channel_user > -2) { + if (stream == XINE_ANON_STREAM || stream->spu_channel_user > -2) { pthread_mutex_unlock(&this->streams_lock); return; } diff --git a/src/xine-engine/video_out.h b/src/xine-engine/video_out.h index 3a7db490d..8ad3773fa 100644 --- a/src/xine-engine/video_out.h +++ b/src/xine-engine/video_out.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: video_out.h,v 1.105 2004/01/07 19:52:43 mroi Exp $ + * $Id: video_out.h,v 1.106 2004/05/29 14:45:25 mroi Exp $ * * * xine version of video_out.h @@ -87,7 +87,7 @@ struct vo_frame_s { /* at least one of proc_frame() and proc_slice() MUST set the variable proc_called to 1 */ void (*proc_slice) (vo_frame_t *vo_img, uint8_t **src); - /* XvMC routine for rendering macroblocks */ + /* XvMC routine for rendering macroblocks, may be NULL */ void (*proc_macro_block)(int x, int y, int mb_type, @@ -109,7 +109,7 @@ struct vo_frame_s { /* append this frame to the display queue, returns number of frames to skip if decoder is late */ - /* when the frame does not originate from a stream, it is legal to pass a NULL stream */ + /* when the frame does not originate from a stream, it is legal to pass an anonymous stream */ int (*draw) (vo_frame_t *vo_img, xine_stream_t *stream); /* lock frame as reference, must be paired with free. @@ -191,7 +191,7 @@ struct xine_video_port_s { /* open display driver for video output */ /* when you are not a full-blown stream, but still need to open the port - * (e.g. you are a post plugin) it is legal to pass a NULL stream */ + * (e.g. you are a post plugin) it is legal to pass an anonymous stream */ void (*open) (xine_video_port_t *self, xine_stream_t *stream); /* @@ -226,13 +226,13 @@ struct xine_video_port_s { int (*get_property) (xine_video_port_t *self, int property); int (*set_property) (xine_video_port_t *self, int property, int value); - /* return true if port is opened for this stream, stream can be NULL */ + /* return true if port is opened for this stream, stream can be anonymous */ int (*status) (xine_video_port_t *self, xine_stream_t *stream, int *width, int *height, int64_t *img_duration); /* video driver is no longer used by decoder => close */ /* when you are not a full-blown stream, but still need to close the port - * (e.g. you are a post plugin) it is legal to pass a NULL stream */ + * (e.g. you are a post plugin) it is legal to pass an anonymous stream */ void (*close) (xine_video_port_t *self, xine_stream_t *stream); /* called on xine exit */ diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index 081baf9c9..01f5bf5ad 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.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: xine_internal.h,v 1.156 2004/04/16 16:34:22 hadess Exp $ + * $Id: xine_internal.h,v 1.157 2004/05/29 14:45:25 mroi Exp $ * */ @@ -327,6 +327,9 @@ struct xine_stream_s { #endif }; +/* when explicitly noted, some functions accept an anonymous stream, + * which is a valid stream that does not want to be addressed. */ +#define XINE_ANON_STREAM ((xine_stream_t *)-1) /* |