From: Gildas Bazin Date: Tue, 31 Jul 2001 21:13:30 +0000 (+0000) Subject: * Fixed a segfault in PSEnd in input_ps.c X-Git-Tag: 0.2.83~30 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=dbfcf9f6e233bb4dd109cebccb32e194c6ddb838;p=vlc * Fixed a segfault in PSEnd in input_ps.c * The video decoder thread is now also reniced to a lower priority on Win32 (as in the linux version). This slightly increases the responsiveness of vlc. --- diff --git a/include/threads.h b/include/threads.h index 0b1b090be0..1ddfde8670 100644 --- a/include/threads.h +++ b/include/threads.h @@ -3,7 +3,7 @@ * This header provides a portable threads implementation. ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: threads.h,v 1.21 2001/07/25 08:41:21 gbazin Exp $ + * $Id: threads.h,v 1.22 2001/07/31 21:13:30 gbazin Exp $ * * Authors: Jean-Marc Dressler * Samuel Hocevar @@ -512,10 +512,12 @@ static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar ) /* Release one waiting thread if one is available. */ /* For this trick to work properly, the vlc_cond_signal must be surrounded * by a mutex. This will prevent another thread from stealing the signal */ - while( p_condvar->i_waiting_threads ) + int i_waiting_threads = p_condvar->i_waiting_threads; + while( p_condvar->i_waiting_threads + && p_condvar->i_waiting_threads == i_waiting_threads ) { PulseEvent( p_condvar->signal ); - Sleep( 0 ); /* deschedule the current thread */ + Sleep( 1 ); /* deschedule the current thread */ } return 0; @@ -589,7 +591,7 @@ static __inline__ int vlc_cond_broadcast( vlc_cond_t *p_condvar ) while( p_condvar->i_waiting_threads ) { PulseEvent( p_condvar->signal ); - Sleep( 0 ); /* deschedule the current thread */ + Sleep( 1 ); /* deschedule the current thread */ } return 0; diff --git a/plugins/mpeg/input_ps.c b/plugins/mpeg/input_ps.c index 8eca5227d5..1f87afdf67 100644 --- a/plugins/mpeg/input_ps.c +++ b/plugins/mpeg/input_ps.c @@ -2,7 +2,7 @@ * input_ps.c: PS demux and packet management ***************************************************************************** * Copyright (C) 1998, 1999, 2000 VideoLAN - * $Id: input_ps.c,v 1.30 2001/07/17 09:48:07 massiot Exp $ + * $Id: input_ps.c,v 1.31 2001/07/31 21:13:30 gbazin Exp $ * * Authors: Christophe Massiot * Cyril Deguet @@ -387,7 +387,22 @@ static void PSInit( input_thread_t * p_input ) *****************************************************************************/ static void PSEnd( input_thread_t * p_input ) { - vlc_mutex_destroy( &((packet_cache_t *)p_input->p_plugin_data)->lock ); +#define p_packet_cache ((packet_cache_t *)p_input->p_method_data) + + vlc_mutex_destroy( &p_packet_cache->lock ); + + if( p_packet_cache->data.p_stack ) + free( p_packet_cache->data.p_stack ); + if( p_packet_cache->pes.p_stack ) + free( p_packet_cache->pes.p_stack ); + if( p_packet_cache->smallbuffer.p_stack ) + free( p_packet_cache->smallbuffer.p_stack ); + if( p_packet_cache->largebuffer.p_stack ) + free( p_packet_cache->largebuffer.p_stack ); + +#undef p_packet_cache + + free( p_input->p_method_data ); free( p_input->p_plugin_data ); } diff --git a/src/video_decoder/video_decoder.c b/src/video_decoder/video_decoder.c index 731edca35e..2323aaaf72 100644 --- a/src/video_decoder/video_decoder.c +++ b/src/video_decoder/video_decoder.c @@ -2,7 +2,7 @@ * video_decoder.c : video decoder thread ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: video_decoder.c,v 1.55 2001/07/18 17:05:39 massiot Exp $ + * $Id: video_decoder.c,v 1.56 2001/07/31 21:13:30 gbazin Exp $ * * Authors: Christophe Massiot * Gaƫl Hendryckx @@ -130,11 +130,16 @@ void vdec_InitThread( vdec_thread_t *p_vdec ) { intf_DbgMsg("vdec debug: initializing video decoder thread %p", p_vdec); -#if !defined(SYS_BEOS) && !defined(WIN32) +#if !defined(SYS_BEOS) # if VDEC_NICE /* Re-nice ourself - otherwise we would steal CPU time from the video * output, which would make a poor display. */ +#if !defined(WIN32) if( nice(VDEC_NICE) == -1 ) +#else + if( !SetThreadPriority( GetCurrentThread(), + THREAD_PRIORITY_BELOW_NORMAL ) ) +#endif { intf_WarnMsg( 2, "vpar warning : couldn't nice() (%s)", strerror(errno) );