]> git.sesse.net Git - vlc/commitdiff
* src/misc/threads.c: Implementation of real-time priorities for UNIX-like
authorChristophe Massiot <massiot@videolan.org>
Fri, 7 Nov 2003 19:30:28 +0000 (19:30 +0000)
committerChristophe Massiot <massiot@videolan.org>
Fri, 7 Nov 2003 19:30:28 +0000 (19:30 +0000)
  pthread systems (activate with --rt-priority)
* modules/access_output/udp.c: Only discard packets which are _very_ late

include/vlc_threads.h
modules/access_output/udp.c
src/libvlc.h
src/misc/threads.c

index 903deeee5f2d4412405c3f4c1bb5b2ee37c8a104..3b6c9d7abfcf369b3a98e559c5dff7180be3d1eb 100644 (file)
@@ -3,7 +3,7 @@
  * This header provides portable declarations for mutexes & conditions
  *****************************************************************************
  * Copyright (C) 1999, 2002 VideoLAN
- * $Id: vlc_threads.h,v 1.34 2003/10/25 00:49:13 sam Exp $
+ * $Id: vlc_threads.h,v 1.35 2003/11/07 19:30:28 massiot Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@via.ecp.fr>
 #   define VLC_THREAD_PRIORITY_VIDEO (-47)
 #   define VLC_THREAD_PRIORITY_OUTPUT 37
 
+#elif defined(PTHREAD_COND_T_IN_PTHREAD_H)
+#   define VLC_THREAD_PRIORITY_LOW 0
+#   define VLC_THREAD_PRIORITY_INPUT 20
+#   define VLC_THREAD_PRIORITY_AUDIO 10
+#   define VLC_THREAD_PRIORITY_VIDEO 0
+#   define VLC_THREAD_PRIORITY_OUTPUT 30
+
 #elif defined(WIN32) || defined(UNDER_CE)
 /* Define different priorities for WinNT/2K/XP and Win9x/Me */
 #   define VLC_THREAD_PRIORITY_LOW 0
index 3120852cba7476c69918c099efdb334f139dcea7..ddc705d573388234611b213da55fa7e495f96928 100644 (file)
@@ -2,7 +2,7 @@
  * udp.c
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: udp.c,v 1.14 2003/11/01 00:11:31 fenrir Exp $
+ * $Id: udp.c,v 1.15 2003/11/07 19:30:28 massiot Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Eric Petit <titer@videolan.org>
@@ -428,7 +428,7 @@ static void ThreadWrite( vlc_object_t *p_this )
                 i_date_last = i_date;
                 continue;
             }
-            else if( i_date - i_date_last < 0 )
+            else if( i_date - i_date_last < -100000 )
             {
                 msg_Dbg( p_thread, "mmh, paquets in the past -> drop" );
 
index 483140ea7c7089cc045802a14898194e4873f217..a2613c47610e72d927a8e2cf1a1f3b12af4e58c7 100644 (file)
@@ -2,7 +2,7 @@
  * libvlc.h: main libvlc header
  *****************************************************************************
  * Copyright (C) 1998-2002 VideoLAN
- * $Id: libvlc.h,v 1.101 2003/11/05 00:39:17 gbazin Exp $
+ * $Id: libvlc.h,v 1.102 2003/11/07 19:30:28 massiot Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -469,6 +469,14 @@ static char *ppsz_language_text[] =
 #define DEMUX_LONGTEXT N_( \
     "This is a legacy entry to let you configure demux modules")
 
+#define RT_PRIORITY_TEXT N_("Allow VLC to run with a real-time priority")
+#define RT_PRIORITY_LONGTEXT N_( \
+    "Running VLC in real-time priority will allow for much more precise " \
+    "scheduling and yield better, especially when streaming content. " \
+    "It can however lock up your whole machine, or make it very very " \
+    "slow. You should only activate this if you know what you're " \
+    "doing.")
+
 #define ONEINSTANCE_TEXT N_("Allow only one running instance of VLC")
 #define ONEINSTANCE_LONGTEXT N_( \
     "Allowing only one running instance of VLC can sometimes be useful, " \
@@ -747,6 +755,10 @@ vlc_module_begin();
     add_module( "access", "access", NULL, NULL, ACCESS_TEXT, ACCESS_LONGTEXT, VLC_TRUE );
     add_module( "demux", "demux", NULL, NULL, DEMUX_TEXT, DEMUX_LONGTEXT, VLC_TRUE );
 
+#if !defined(SYS_DARWIN) && defined(PTHREAD_COND_T_IN_PTHREAD_H)
+    add_bool( "rt-priority", 0, NULL, RT_PRIORITY_TEXT, RT_PRIORITY_LONGTEXT, VLC_TRUE );
+#endif
+
 #if defined(WIN32)
     add_bool( "one-instance", 0, NULL, ONEINSTANCE_TEXT, ONEINSTANCE_LONGTEXT, VLC_TRUE );
     add_bool( "high-priority", 1, NULL, HPRIORITY_TEXT, HPRIORITY_LONGTEXT, VLC_TRUE );
index d214c93899243dcbb32ba9804dc7ed1b8d4ef473..7205237362fc5636a8d0bea93c437f1e889d66a1 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * threads.c : threads implementation for the VideoLAN client
  *****************************************************************************
- * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
- * $Id: threads.c,v 1.42 2003/10/25 00:49:14 sam Exp $
+ * Copyright (C) 1999, 2000, 2001, 2002, 2003 VideoLAN
+ * $Id: threads.c,v 1.43 2003/11/07 19:30:28 massiot Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -552,8 +552,11 @@ int __vlc_thread_create( vlc_object_t *p_this, char * psz_file, int i_line,
 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
     i_ret = pthread_create( &p_this->thread_id, NULL, func, p_data );
 
-#ifdef SYS_DARWIN
-    if ( i_priority )
+    if ( i_priority
+#ifndef SYS_DARWIN
+            && config_GetInt( p_this, "rt-priority" )
+#endif
+       )
     {
         int i_error, i_policy;
         struct sched_param param;
@@ -576,7 +579,10 @@ int __vlc_thread_create( vlc_object_t *p_this, char * psz_file, int i_line,
             i_priority = 0;
         }
     }
-#endif
+    else
+    {
+        i_priority = 0;
+    }
 
 #elif defined( HAVE_CTHREADS_H )
     p_this->thread_id = cthread_fork( (cthread_fn_t)func, (any_t)p_data );