]> git.sesse.net Git - vlc/commitdiff
* Fixed a segfault in PSEnd in input_ps.c
authorGildas Bazin <gbazin@videolan.org>
Tue, 31 Jul 2001 21:13:30 +0000 (21:13 +0000)
committerGildas Bazin <gbazin@videolan.org>
Tue, 31 Jul 2001 21:13:30 +0000 (21:13 +0000)
* 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.

include/threads.h
plugins/mpeg/input_ps.c
src/video_decoder/video_decoder.c

index 0b1b090be04ee1be4c2021e3e03c6c829c8f879d..1ddfde86704d4a14fee5debf5649025ba9574864 100644 (file)
@@ -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 <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@via.ecp.fr>
@@ -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;
 
index 8eca5227d5493d9bb0df70253bd00f24ef2fb959..1f87afdf677173438efc7d3c04931d17212bb8a5 100644 (file)
@@ -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 <massiot@via.ecp.fr>
  *          Cyril Deguet <asmax@via.ecp.fr>
@@ -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 );
 }
 
index 731edca35e2e9eadd44cba8914422087b98f33f5..2323aaaf724c36e5661a90397a8e9cd77244f6b3 100644 (file)
@@ -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 <massiot@via.ecp.fr>
  *          GaĆ«l Hendryckx <jimmy@via.ecp.fr>
@@ -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) );