diff options
author | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2004-07-06 22:53:22 +0000 |
---|---|---|
committer | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2004-07-06 22:53:22 +0000 |
commit | 40aab85f00b16aedeb638bd4ff7693d908ad5d60 (patch) | |
tree | d32ac09a4fe0ec1092ed575dcc38e1572f6c4e42 | |
parent | 4bf855750a173f0c002a231cc6307c47719867d1 (diff) | |
download | xine-lib-40aab85f00b16aedeb638bd4ff7693d908ad5d60.tar.gz xine-lib-40aab85f00b16aedeb638bd4ff7693d908ad5d60.tar.bz2 |
fix a long standing bug: streams were not played till their very end, because
finished event was sent to frontend before the output fifos were empty.
add a test for the number of streams attached to the output port. this will
prevent deadlocking on multi-streams scenarios where fifos don't ever get empty.
CVS patchset: 6777
CVS date: 2004/07/06 22:53:22
-rw-r--r-- | src/xine-engine/audio_decoder.c | 21 | ||||
-rw-r--r-- | src/xine-engine/audio_out.c | 12 | ||||
-rw-r--r-- | src/xine-engine/audio_out.h | 5 | ||||
-rw-r--r-- | src/xine-engine/video_decoder.c | 27 | ||||
-rw-r--r-- | src/xine-engine/video_out.c | 12 | ||||
-rw-r--r-- | src/xine-engine/video_out.h | 5 |
6 files changed, 71 insertions, 11 deletions
diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index 1b4c68457..b69908384 100644 --- a/src/xine-engine/audio_decoder.c +++ b/src/xine-engine/audio_decoder.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: audio_decoder.c,v 1.128 2004/04/26 17:50:12 mroi Exp $ + * $Id: audio_decoder.c,v 1.129 2004/07/06 22:53:22 miguelfreitas Exp $ * * * functions that implement audio decoding @@ -119,6 +119,25 @@ static void *audio_decoder_loop (void *stream_gen) { } first_header = last_header = NULL; } + + /* + * wait the output fifos to run dry before sending the notification event + * to the frontend. this test is only valid if there is only a single + * stream attached to the current output port. + */ + while(1) { + int num_bufs, num_streams; + + running_ticket->acquire(running_ticket, 0); + num_bufs = stream->audio_out->get_property(stream->audio_out, AO_PROP_BUFS_IN_FIFO); + num_streams = stream->audio_out->get_property(stream->audio_out, AO_PROP_NUM_STREAMS); + running_ticket->release(running_ticket, 0); + + if( num_bufs > 0 && num_streams == 1 ) + xine_usec_sleep (10000); + else + break; + } /* wait for video to reach this marker, if necessary */ pthread_mutex_lock (&stream->counter_lock); diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 83401599b..49838df1a 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.181 2004/06/27 13:33:57 mroi Exp $ + * $Id: audio_out.c,v 1.182 2004/07/06 22:53:22 miguelfreitas Exp $ * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe <andy@alsaplayer.org> @@ -1582,6 +1582,7 @@ static uint32_t ao_get_capabilities (xine_audio_port_t *this_gen) { static int ao_get_property (xine_audio_port_t *this_gen, int property) { aos_t *this = (aos_t *) this_gen; + xine_stream_t *cur; int ret; switch (property) { @@ -1593,6 +1594,15 @@ static int ao_get_property (xine_audio_port_t *this_gen, int property) { ret = this->audio_loop_running ? this->out_fifo->num_buffers : -1; break; + case AO_PROP_NUM_STREAMS: + ret = 0; + pthread_mutex_lock(&this->streams_lock); + for (cur = xine_list_first_content(this->streams); cur; + cur = xine_list_next_content(this->streams)) + ret++; + pthread_mutex_unlock(&this->streams_lock); + break; + case AO_PROP_AMP: ret = this->amp_factor*100; break; diff --git a/src/xine-engine/audio_out.h b/src/xine-engine/audio_out.h index 55a8dfe3d..0d75c92ea 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.71 2004/06/19 20:07:15 mroi Exp $ + * $Id: audio_out.h,v 1.72 2004/07/06 22:53:23 miguelfreitas Exp $ */ #ifndef HAVE_AUDIO_OUT_H #define HAVE_AUDIO_OUT_H @@ -323,7 +323,8 @@ int _x_ao_mode2channels( int mode ); #define AO_PROP_EQ_16000HZ 16 /* equalizer */ #define AO_PROP_CLOSE_DEVICE 17 /* force closing audio device */ #define AO_PROP_AMP_MUTE 18 /* amplifier mute */ -#define AO_NUM_PROPERTIES 19 +#define AO_PROP_NUM_STREAMS 19 /* read-only */ +#define AO_NUM_PROPERTIES 20 /* audio device control ops */ #define AO_CTRL_PLAY_PAUSE 0 diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c index c0c4af95c..9e2fa3af1 100644 --- a/src/xine-engine/video_decoder.c +++ b/src/xine-engine/video_decoder.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_decoder.c,v 1.149 2004/04/26 17:50:12 mroi Exp $ + * $Id: video_decoder.c,v 1.150 2004/07/06 22:53:23 miguelfreitas Exp $ * */ @@ -181,6 +181,25 @@ static void *video_decoder_loop (void *stream_gen) { break; case BUF_CONTROL_END: + + /* + * wait the output fifos to run dry before sending the notification event + * to the frontend. this test is only valid if there is only a single + * stream attached to the current output port. + */ + while(1) { + int num_bufs, num_streams; + + running_ticket->acquire(running_ticket, 0); + num_bufs = stream->video_out->get_property(stream->video_out, VO_PROP_BUFS_IN_FIFO); + num_streams = stream->video_out->get_property(stream->video_out, VO_PROP_NUM_STREAMS); + running_ticket->release(running_ticket, 0); + + if( num_bufs > 0 && num_streams == 1 ) + xine_usec_sleep (10000); + else + break; + } /* wait for audio to reach this marker, if necessary */ @@ -208,9 +227,6 @@ static void *video_decoder_loop (void *stream_gen) { pthread_mutex_unlock (&stream->counter_lock); - /* set engine status, send frontend notification event */ - _x_handle_stream_end (stream, buf->decoder_flags & BUF_FLAG_END_STREAM); - /* Wake up xine_play if it's waiting for a frame */ pthread_mutex_lock (&stream->first_frame_lock); if (stream->first_frame_flag) { @@ -218,6 +234,9 @@ static void *video_decoder_loop (void *stream_gen) { pthread_cond_broadcast(&stream->first_frame_reached); } pthread_mutex_unlock (&stream->first_frame_lock); + + /* set engine status, send frontend notification event */ + _x_handle_stream_end (stream, buf->decoder_flags & BUF_FLAG_END_STREAM); break; case BUF_CONTROL_QUIT: diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index 672e1cb11..a72ce0943 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.202 2004/07/05 17:13:37 mroi Exp $ + * $Id: video_out.c,v 1.203 2004/07/06 22:53:23 miguelfreitas Exp $ * * frame allocation / queuing / scheduling / output functions */ @@ -1239,6 +1239,7 @@ static void vo_close (xine_video_port_t *this_gen, xine_stream_t *stream) { static int vo_get_property (xine_video_port_t *this_gen, int property) { vos_t *this = (vos_t *) this_gen; + xine_stream_t *cur; int ret; switch (property) { @@ -1250,6 +1251,15 @@ static int vo_get_property (xine_video_port_t *this_gen, int property) { ret = this->video_loop_running ? this->display_img_buf_queue->num_buffers : -1; break; + case VO_PROP_NUM_STREAMS: + ret = 0; + pthread_mutex_lock(&this->streams_lock); + for (cur = xine_list_first_content(this->streams); cur; + cur = xine_list_next_content(this->streams)) + ret++; + pthread_mutex_unlock(&this->streams_lock); + break; + /* * handle XINE_PARAM_xxx properties (convert from driver's range) */ diff --git a/src/xine-engine/video_out.h b/src/xine-engine/video_out.h index fa64344c0..fa4600c5d 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.107 2004/06/19 20:07:15 mroi Exp $ + * $Id: video_out.h,v 1.108 2004/07/06 22:53:23 miguelfreitas Exp $ * * * xine version of video_out.h @@ -261,7 +261,8 @@ struct xine_video_port_s { #define VO_PROP_WINDOW_WIDTH 15 /* read-only */ #define VO_PROP_WINDOW_HEIGHT 16 /* read-only */ #define VO_PROP_BUFS_IN_FIFO 17 /* read-only */ -#define VO_NUM_PROPERTIES 18 +#define VO_PROP_NUM_STREAMS 18 /* read-only */ +#define VO_NUM_PROPERTIES 19 /* number of colors in the overlay palette. Currently limited to 256 at most, because some alphablend functions use an 8-bit index into |