diff options
-rw-r--r-- | src/xine-engine/audio_decoder.c | 27 | ||||
-rw-r--r-- | src/xine-engine/video_decoder.c | 31 | ||||
-rw-r--r-- | src/xine-engine/xine.c | 32 | ||||
-rw-r--r-- | src/xine-engine/xine_internal.h | 7 |
4 files changed, 50 insertions, 47 deletions
diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index 0235ba7fc..4aa1f0c96 100644 --- a/src/xine-engine/audio_decoder.c +++ b/src/xine-engine/audio_decoder.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2000-2001 the xine project * * This file is part of xine, a unix video player. @@ -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.43 2001/10/03 17:15:43 jkeil Exp $ + * $Id: audio_decoder.c,v 1.44 2001/10/05 01:56:57 miguelfreitas Exp $ * * * functions that implement audio decoding @@ -83,9 +83,9 @@ void *audio_decoder_loop (void *this_gen) { this->cur_audio_decoder_plugin = NULL; } - pthread_mutex_lock (&this->xine_lock); + pthread_mutex_lock (&this->finished_lock); this->audio_finished = 0; - pthread_mutex_unlock (&this->xine_lock); + pthread_mutex_unlock (&this->finished_lock); for (i=0 ; i<50; i++) this->audio_track_map[0] = 0; @@ -105,18 +105,17 @@ void *audio_decoder_loop (void *this_gen) { this->cur_audio_decoder_plugin = NULL; } - pthread_mutex_lock (&this->xine_lock); + pthread_mutex_lock (&this->finished_lock); if (!this->audio_finished && (buf->decoder_info[0]==0)) { - this->audio_finished = 1; - - if (this->video_finished) { - pthread_mutex_unlock (&this->xine_lock); - xine_notify_stream_finished (this); - } else - pthread_mutex_unlock (&this->xine_lock); - } else - pthread_mutex_unlock (&this->xine_lock); + this->audio_finished = 1; + + if (this->video_finished) { + xine_notify_stream_finished (this); + } + } + + pthread_mutex_unlock (&this->finished_lock); break; diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c index 5611964ed..d454aae3a 100644 --- a/src/xine-engine/video_decoder.c +++ b/src/xine-engine/video_decoder.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2001 the xine project - * + * * This file is part of xine, a unix video player. * * xine is free software; you can redistribute it and/or modify @@ -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.53 2001/10/03 17:15:44 jkeil Exp $ + * $Id: video_decoder.c,v 1.54 2001/10/05 01:56:57 miguelfreitas Exp $ * */ @@ -91,11 +91,11 @@ void *video_decoder_loop (void *this_gen) { this->cur_spu_decoder_plugin = NULL; } - pthread_mutex_lock (&this->xine_lock); + pthread_mutex_lock (&this->finished_lock); this->video_finished = 0; this->spu_finished = 0; - pthread_mutex_unlock (&this->xine_lock); + pthread_mutex_unlock (&this->finished_lock); this->metronom->video_stream_start (this->metronom); @@ -144,20 +144,19 @@ void *video_decoder_loop (void *this_gen) { this->cur_spu_decoder_plugin->close (this->cur_spu_decoder_plugin); this->cur_spu_decoder_plugin = NULL; } + pthread_mutex_lock (&this->finished_lock); this->spu_finished = 1; - pthread_mutex_lock (&this->xine_lock); - + if (!this->video_finished && (buf->decoder_info[0]==0)) { - this->video_finished = 1; - - if (this->audio_finished) { - pthread_mutex_unlock (&this->xine_lock); - xine_notify_stream_finished (this); - } else - pthread_mutex_unlock (&this->xine_lock); - } else - pthread_mutex_unlock (&this->xine_lock); + this->video_finished = 1; + + if (this->audio_finished) { + xine_notify_stream_finished (this); + } + } + + pthread_mutex_unlock (&this->finished_lock); break; @@ -170,7 +169,7 @@ void *video_decoder_loop (void *this_gen) { this->cur_spu_decoder_plugin->close (this->cur_spu_decoder_plugin); this->cur_spu_decoder_plugin = NULL; } - + running = 0; break; diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index d836444e4..eeccd704a 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2000-2001 the xine project * * This file is part of xine, a unix video player. @@ -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.c,v 1.62 2001/10/03 15:16:02 jkeil Exp $ + * $Id: xine.c,v 1.63 2001/10/05 01:56:57 miguelfreitas Exp $ * * top-level xine functions * @@ -60,12 +60,12 @@ uint32_t xine_debug; void xine_notify_stream_finished (xine_t *this) { - + xine_stop (this); if (this->stream_end_cb) this->stream_end_cb (this->status); - + } void xine_stop (xine_t *this) { @@ -87,7 +87,7 @@ void xine_stop (xine_t *this) { this->status = XINE_STOP; printf ("xine_stop: stopping demuxer\n"); - + if(this->cur_demuxer_plugin) { this->cur_demuxer_plugin->stop (this->cur_demuxer_plugin); this->cur_demuxer_plugin = NULL; @@ -98,13 +98,13 @@ void xine_stop (xine_t *this) { /* * If we set it to NULL, xine_eject() will not work after * a xine_stop() call. - * + * * this->cur_input_plugin = NULL; */ } printf ("xine_stop: done\n"); - + pthread_mutex_unlock (&this->xine_lock); } @@ -135,7 +135,7 @@ static int try_demux_with_stages(xine_t *this, const char *MRL, stages[s]) == DEMUX_CAN_HANDLE) { this->cur_demuxer_plugin = this->demuxer_plugins[i]; - + return 1; } } @@ -286,7 +286,7 @@ void xine_play (xine_t *this, char *mrl, this->metronom->set_speed (this->metronom, SPEED_NORMAL); this->audio_mute = 0; this->speed = SPEED_NORMAL; - } + } pthread_mutex_unlock (&this->xine_lock); } @@ -315,7 +315,7 @@ void xine_exit (xine_t *this) { printf ("xine_exit: try to get lock...\n"); pthread_mutex_lock (&this->xine_lock); - + this->metronom->set_speed (this->metronom, SPEED_NORMAL); this->speed = SPEED_NORMAL; this->status = XINE_STOP; @@ -405,16 +405,18 @@ xine_t *xine_init (vo_driver_t *vo, this->stream_end_cb = stream_end_cb; this->get_next_mrl_cb = get_next_mrl_cb; - this->branched_cb = branched_cb; + this->branched_cb = branched_cb; this->config = config; xine_debug = config->lookup_int (config, "xine_debug", 0); /* - * init lock + * init locks */ pthread_mutex_init (&this->xine_lock, NULL); + pthread_mutex_init (&this->finished_lock, NULL); + /* * create a metronom */ @@ -424,9 +426,9 @@ xine_t *xine_init (vo_driver_t *vo, /* * load input and demuxer plugins */ - + load_input_plugins (this, config, INPUT_PLUGIN_IFACE_VERSION); - + this->demux_strategy = config->lookup_int (config, "demux_strategy", 0); load_demux_plugins(this, config, DEMUXER_PLUGIN_IFACE_VERSION); @@ -617,7 +619,7 @@ int xine_get_current_time (xine_t *this) { int xine_get_stream_length (xine_t *this) { - if(this->cur_demuxer_plugin) + if(this->cur_demuxer_plugin) return this->cur_demuxer_plugin->get_stream_length (this->cur_demuxer_plugin); return 0; diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index 9adeb26f5..ebc659d32 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2000-2001 the xine project * * This file is part of xine, a unix video player. @@ -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.45 2001/09/26 01:18:19 guenter Exp $ + * $Id: xine_internal.h,v 1.46 2001/10/05 01:56:57 miguelfreitas Exp $ * */ @@ -192,6 +192,9 @@ struct xine_s { /* Lock for xine player functions */ pthread_mutex_t xine_lock; + /* Lock for xxx_finished variables */ + pthread_mutex_t finished_lock; + /* Array of event handlers. */ event_listener_t event_listeners[XINE_MAX_EVENT_LISTENERS]; uint16_t num_event_listeners; |