From 4be4c9d1bbf057f7117e286bede19f599138030d Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Sun, 6 Mar 2005 11:08:40 +0000 Subject: Fixed pthread leak, the demuxer thread was not joined in all cases. See this thread for more info: http://thread.gmane.org/gmane.comp.video.xine.devel/12377 CVS patchset: 7432 CVS date: 2005/03/06 11:08:40 --- src/xine-engine/demux.c | 11 +++++++---- src/xine-engine/xine.c | 27 ++++++++++++--------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c index ff0b78a1d..b7a3f4dbc 100644 --- a/src/xine-engine/demux.c +++ b/src/xine-engine/demux.c @@ -20,7 +20,7 @@ * Demuxer helper functions * hide some xine engine details from demuxers and reduce code duplication * - * $Id: demux.c,v 1.55 2005/02/10 11:33:31 mroi Exp $ + * $Id: demux.c,v 1.56 2005/03/06 11:08:40 tmattern Exp $ */ @@ -317,7 +317,6 @@ static void *demux_loop (void *stream_gen) { pthread_mutex_unlock (&stream->counter_lock); _x_handle_stream_end(stream, non_user); - stream->demux_thread = 0; return NULL; } @@ -332,7 +331,9 @@ int _x_demux_start_thread (xine_stream_t *stream) { stream->demux_action_pending = 0; if( !stream->demux_thread_running ) { - + + _x_assert(stream->demux_thread == 0); + stream->demux_thread_running = 1; if ((err = pthread_create (&stream->demux_thread, NULL, demux_loop, (void *)stream)) != 0) { @@ -364,8 +365,10 @@ int _x_demux_stop_thread (xine_stream_t *stream) { lprintf ("joining thread %ld\n", stream->demux_thread ); - if( stream->demux_thread ) + if( stream->demux_thread ) { pthread_join (stream->demux_thread, &p); + stream->demux_thread = 0; + } /* * Wake up xine_play if it's waiting for a frame diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 0ac89b2c7..f9639e89e 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.311 2005/02/19 13:11:52 valtri Exp $ + * $Id: xine.c,v 1.312 2005/03/06 11:08:40 tmattern Exp $ */ /* @@ -276,26 +276,23 @@ static void stop_internal (xine_stream_t *stream) { if ( stream->status == XINE_STATUS_IDLE || stream->status == XINE_STATUS_STOP ) { _x_demux_control_end(stream, 0); - lprintf ("ignored\n"); - return; - } - - /* make sure we're not in "paused" state */ - set_speed_internal (stream, XINE_FINE_SPEED_NORMAL); - - /* Don't change status if we're quitting */ - if (stream->status != XINE_STATUS_QUIT) - stream->status = XINE_STATUS_STOP; + lprintf("ignored"); + } else { + /* make sure we're not in "paused" state */ + set_speed_internal (stream, XINE_FINE_SPEED_NORMAL); + /* Don't change status if we're quitting */ + if (stream->status != XINE_STATUS_QUIT) + stream->status = XINE_STATUS_STOP; + } /* * stop demux */ - lprintf ("stopping demux\n"); - if (stream->demux_plugin) { + if (stream->demux_plugin && stream->demux_thread) { + lprintf ("stopping demux\n"); _x_demux_stop_thread( stream ); - lprintf ("stop thread done\n"); + lprintf ("demux stopped\n"); } - lprintf ("demux stopped\n"); lprintf ("done\n"); } -- cgit v1.2.3