From 9c7fc92c6c391b037393721dbe8742ddd260b1d1 Mon Sep 17 00:00:00 2001 From: Guenter Bartsch Date: Sun, 12 Aug 2001 15:12:54 +0000 Subject: cancel demux thread on xine_stop instead of pthread_join to prevent hang CVS patchset: 415 CVS date: 2001/08/12 15:12:54 --- src/demuxers/demux_avi.c | 6 +++--- src/demuxers/demux_elem.c | 5 ++--- src/demuxers/demux_mpeg.c | 9 +++++---- src/demuxers/demux_mpeg_block.c | 7 +++---- src/demuxers/demux_mpgaudio.c | 8 ++++---- src/demuxers/demux_pes.c | 6 +++--- src/demuxers/demux_ts.c | 8 +++----- src/xine-engine/buffer.c | 24 ++++++++++++++++++++++-- src/xine-engine/xine.c | 6 +++--- 9 files changed, 48 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index c1edff642..4cb826ded 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.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: demux_avi.c,v 1.23 2001/07/14 12:50:34 guenter Exp $ + * $Id: demux_avi.c,v 1.24 2001/08/12 15:12:54 guenter Exp $ * * demultiplexer for avi streams * @@ -853,7 +853,7 @@ static void *demux_avi_loop (void *this_gen) { } static void demux_avi_stop (demux_plugin_t *this_gen) { - void *p; + demux_avi_t *this = (demux_avi_t *) this_gen; buf_element_t *buf; @@ -865,7 +865,7 @@ static void demux_avi_stop (demux_plugin_t *this_gen) { this->send_end_buffers = 0; this->status = DEMUX_FINISHED; - pthread_join (this->thread, &p); + pthread_cancel (this->thread); AVI_close (this->avi); this->avi = NULL; diff --git a/src/demuxers/demux_elem.c b/src/demuxers/demux_elem.c index a1022be17..bfd2a9092 100644 --- a/src/demuxers/demux_elem.c +++ b/src/demuxers/demux_elem.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: demux_elem.c,v 1.14 2001/07/14 12:50:34 guenter Exp $ + * $Id: demux_elem.c,v 1.15 2001/08/12 15:12:54 guenter Exp $ * * demultiplexer for elementary mpeg streams * @@ -134,14 +134,13 @@ static void *demux_mpeg_elem_loop (void *this_gen) { static void demux_mpeg_elem_stop (demux_plugin_t *this_gen) { demux_mpeg_elem_t *this = (demux_mpeg_elem_t *) this_gen; - void *p; buf_element_t *buf = NULL; this->send_end_buffers = 0; this->status = DEMUX_FINISHED; - pthread_join (this->thread, &p); + pthread_cancel (this->thread); this->video_fifo->clear(this->video_fifo); if (this->audio_fifo) diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c index 0835ccede..a33419515 100644 --- a/src/demuxers/demux_mpeg.c +++ b/src/demuxers/demux_mpeg.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 the xine project + * 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: demux_mpeg.c,v 1.28 2001/08/10 19:49:57 guenter Exp $ + * $Id: demux_mpeg.c,v 1.29 2001/08/12 15:12:54 guenter Exp $ * * demultiplexer for mpeg 1/2 program streams * reads streams of variable blocksizes @@ -548,7 +548,7 @@ static void *demux_mpeg_loop (void *this_gen) { } static void demux_mpeg_stop (demux_plugin_t *this_gen) { - void *p; + demux_mpeg_t *this = (demux_mpeg_t *) this_gen; buf_element_t *buf; @@ -566,7 +566,8 @@ static void demux_mpeg_stop (demux_plugin_t *this_gen) { this->send_end_buffers = 0; this->status = DEMUX_FINISHED; - pthread_join (this->thread, &p); + pthread_cancel (this->thread); + /*pthread_join (this->thread, &p);*/ this->video_fifo->clear(this->video_fifo); if(this->audio_fifo) diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index adffae3fa..8b1f022fa 100644 --- a/src/demuxers/demux_mpeg_block.c +++ b/src/demuxers/demux_mpeg_block.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 the xine project + * 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: demux_mpeg_block.c,v 1.28 2001/08/05 00:59:50 ehasenle Exp $ + * $Id: demux_mpeg_block.c,v 1.29 2001/08/12 15:12:54 guenter Exp $ * * demultiplexer for mpeg 1/2 program streams * @@ -415,7 +415,6 @@ static void *demux_mpeg_block_loop (void *this_gen) { static void demux_mpeg_block_stop (demux_plugin_t *this_gen) { demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen; - void *p; buf_element_t *buf; if (this->status != DEMUX_OK) { @@ -426,7 +425,7 @@ static void demux_mpeg_block_stop (demux_plugin_t *this_gen) { this->send_end_buffers = 0; this->status = DEMUX_FINISHED; - pthread_join (this->thread, &p); + pthread_cancel (this->thread); this->video_fifo->clear(this->video_fifo); if (this->audio_fifo) diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index 7da1e26cf..9f2a8c9c9 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 the xine project + * 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: demux_mpgaudio.c,v 1.15 2001/07/14 12:50:34 guenter Exp $ + * $Id: demux_mpgaudio.c,v 1.16 2001/08/12 15:12:54 guenter Exp $ * * demultiplexer for mpeg audio (i.e. mp3) streams * @@ -139,8 +139,8 @@ static void *demux_mpgaudio_loop (void *this_gen) { } static void demux_mpgaudio_stop (demux_plugin_t *this_gen) { + demux_mpgaudio_t *this = (demux_mpgaudio_t *) this_gen; - void *p; buf_element_t *buf; if (this->status != DEMUX_OK) { @@ -151,7 +151,7 @@ static void demux_mpgaudio_stop (demux_plugin_t *this_gen) { this->send_end_buffers = 0; this->status = DEMUX_FINISHED; - pthread_join (this->thread, &p); + pthread_cancel (this->thread); this->video_fifo->clear(this->video_fifo); if (this->audio_fifo) diff --git a/src/demuxers/demux_pes.c b/src/demuxers/demux_pes.c index a1569fe74..c67e15442 100644 --- a/src/demuxers/demux_pes.c +++ b/src/demuxers/demux_pes.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 the xine project + * 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: demux_pes.c,v 1.2 2001/08/10 19:49:57 guenter Exp $ + * $Id: demux_pes.c,v 1.3 2001/08/12 15:12:54 guenter Exp $ * * demultiplexer for mpeg 2 PES (Packetized Elementary Streams) * reads streams of variable blocksizes @@ -371,7 +371,7 @@ static void demux_mpeg_stop (demux_plugin_t *this_gen) { this->send_end_buffers = 0; this->status = DEMUX_FINISHED; - pthread_join (this->thread, &p); + pthread_cancel (this->thread); this->video_fifo->clear(this->video_fifo); if(this->audio_fifo) diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index 1607823e3..86a0f7eab 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 the xine project + * 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: demux_ts.c,v 1.4 2001/08/02 20:38:42 jcdutton Exp $ + * $Id: demux_ts.c,v 1.5 2001/08/12 15:12:54 guenter Exp $ * * Demultiplexer for MPEG2 Transport Streams. * @@ -605,7 +605,6 @@ static void demux_ts_parse_ts( unsigned int continuity_counter; unsigned int data_offset; unsigned int data_len; - int n; /* @@ -1010,7 +1009,6 @@ static void demux_ts_stop( demux_plugin_t *this_gen) { demux_ts *this = (demux_ts *)this_gen; - void *p; buf_element_t *buf; printf ("demux_ts: stop...\n"); @@ -1025,7 +1023,7 @@ static void demux_ts_stop( this->status = DEMUX_FINISHED; - pthread_join (this->thread, &p); + pthread_cancel (this->thread); this->fifoVideo->clear(this->fifoVideo); if(this->fifoAudio) diff --git a/src/xine-engine/buffer.c b/src/xine-engine/buffer.c index a05660fb2..fff308399 100644 --- a/src/xine-engine/buffer.c +++ b/src/xine-engine/buffer.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: buffer.c,v 1.5 2001/07/03 21:25:04 guenter Exp $ + * $Id: buffer.c,v 1.6 2001/08/12 15:12:54 guenter Exp $ * * * contents: @@ -59,13 +59,31 @@ static void buffer_pool_free (buf_element_t *element) { pthread_mutex_unlock (&this->buffer_pool_mutex); } +/* + * helper function to release buffer pool lock + * in case demux thread is cancelled + */ + +void pool_release_lock (void *arg) { + + pthread_mutex_t *mutex = (pthread_mutex_t *) arg; + + /* printf ("pool release lock\n"); */ + + pthread_mutex_unlock (mutex); + +} + /* - * check if there are no more free elements + * allocate a buffer from buffer pool */ + static buf_element_t *buffer_pool_alloc (fifo_buffer_t *this) { buf_element_t *buf; + pthread_cleanup_push( pool_release_lock, &this->buffer_pool_mutex); + pthread_mutex_lock (&this->buffer_pool_mutex); while (!this->buffer_pool_top) { @@ -76,6 +94,8 @@ static buf_element_t *buffer_pool_alloc (fifo_buffer_t *this) { this->buffer_pool_top = this->buffer_pool_top->next; this->buffer_pool_num_free--; + pthread_cleanup_pop (0); + pthread_mutex_unlock (&this->buffer_pool_mutex); return buf; diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 4659fb993..864641e6d 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.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.c,v 1.38 2001/07/27 21:46:59 f1rmb Exp $ + * $Id: xine.c,v 1.39 2001/08/12 15:12:54 guenter Exp $ * * top-level xine functions * @@ -205,7 +205,6 @@ static void xine_play_internal (xine_t *this, char *mrl, if (!this->cur_input_plugin) { perror ("open input source"); this->cur_demuxer_plugin = NULL; - this->status = XINE_STOP; return; } @@ -224,7 +223,6 @@ static void xine_play_internal (xine_t *this, char *mrl, if(!find_demuxer(this, mrl)) { printf ("xine: couldn't find demuxer for >%s<\n", mrl); - this->status = XINE_STOP; return; } @@ -251,6 +249,8 @@ static void xine_play_internal (xine_t *this, char *mrl, this->status = XINE_PLAY; strncpy (this->cur_mrl, mrl, 1024); + printf ("xine: demuxer started\n"); + } void xine_play (xine_t *this, char *MRL, int spos) { -- cgit v1.2.3