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 /src/xine-engine | |
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
Diffstat (limited to 'src/xine-engine')
-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 |
7 files changed, 57 insertions, 62 deletions
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) /* |