]> git.sesse.net Git - vlc/commitdiff
* UDP access plug-in can now receive MPTS (Multiple Program TS) and switch
authorChristophe Massiot <massiot@videolan.org>
Wed, 27 Mar 2002 22:15:40 +0000 (22:15 +0000)
committerChristophe Massiot <massiot@videolan.org>
Wed, 27 Mar 2002 22:15:40 +0000 (22:15 +0000)
programs
* Audio and video output go to time-constrained scheduling [OS X port]

configure
plugins/access/udp.c
plugins/macosx/aout_macosx.c
plugins/macosx/vout_macosx.c

index 6e5ac1ebb469cb35209ed0a5b7f23d9106b05062..60663e3ce20f8b2665889a435c47a018773ad862 100755 (executable)
--- a/configure
+++ b/configure
@@ -1235,7 +1235,7 @@ else
   VLC_MAKE="gmake"
 fi
 
-ALL_LINGUAS="de fr no ru"
+ALL_LINGUAS="de fr no ru nl"
 
 cat >> confdefs.h <<EOF
 #define PACKAGE "vlc"
index d771a6d6c77ad2152877ac12b5aefb320ecc49a1..1bf4c0873b056a2c3ab7d4f48cf0c1e0cbca2410 100644 (file)
@@ -2,7 +2,7 @@
  * udp.c: raw UDP access plug-in
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: udp.c,v 1.5 2002/03/26 23:39:43 massiot Exp $
+ * $Id: udp.c,v 1.6 2002/03/27 22:15:40 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -266,11 +266,57 @@ static int UDPOpen( input_thread_t * p_input )
 }
 
 /*****************************************************************************
- * UDPSetProgram: Do nothing
+ * UDPSetProgram: Selects another program
  *****************************************************************************/
-static int UDPSetProgram( input_thread_t * p_input,
-                           pgrm_descriptor_t * p_program )
+int UDPSetProgram( input_thread_t    * p_input,
+                   pgrm_descriptor_t * p_new_prg )
 {
+    int                 i_es_index;
+
+    if ( p_input->stream.p_selected_program )
+    {
+        for ( i_es_index = 1 ; /* 0 should be the PMT */
+                i_es_index < p_input->stream.p_selected_program->
+                    i_es_number ;
+                i_es_index ++ )
+        {
+#define p_es p_input->stream.p_selected_program->pp_es[i_es_index]
+            if ( p_es->p_decoder_fifo )
+            {
+                input_UnselectES( p_input , p_es );
+                p_es->p_pes = NULL; /* FIXME */
+            }
+#undef p_es
+        }
+    }
+
+    for (i_es_index = 1 ; i_es_index < p_new_prg->i_es_number ; i_es_index ++ )
+    {
+#define p_es p_new_prg->pp_es[i_es_index]
+        switch( p_es->i_cat )
+        {
+            case MPEG1_VIDEO_ES:
+            case MPEG2_VIDEO_ES:
+                if ( p_main->b_video )
+                {
+                    input_SelectES( p_input , p_es );
+                }
+                break;
+            case MPEG1_AUDIO_ES:
+            case MPEG2_AUDIO_ES:
+                if ( p_main->b_audio )
+                {
+                    input_SelectES( p_input , p_es );
+                }
+                break;
+            default:
+                input_SelectES( p_input , p_es );
+                break;
+#undef p_es
+        }
+    }
+
+    p_input->stream.p_selected_program = p_new_prg;
+
     return( 0 );
 }
-
index 37c72759ac4b9d54d17a734dcda5582401ce03b6..ece80443dd43f899c9492963f54865664ce23ed8 100644 (file)
@@ -2,7 +2,7 @@
  * aout_macosx.c : CoreAudio output plugin
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: aout_macosx.c,v 1.16 2002/03/22 00:47:47 jlj Exp $
+ * $Id: aout_macosx.c,v 1.17 2002/03/27 22:15:40 massiot Exp $
  *
  * Authors: Colin Delacroix <colin@zoy.org>
  *          Jon Lech Johansen <jon-vl@nanocrew.net>
  * Preamble
  *****************************************************************************/
 #include <string.h>
+#include <mach/mach_init.h>
+#include <mach/task_policy.h>
+#include <mach/thread_act.h>
+#include <mach/thread_policy.h>
+#include <sys/sysctl.h>
 
 #include <videolan/vlc.h>
 
@@ -99,6 +104,12 @@ static int aout_Open( aout_thread_t *p_aout )
     OSStatus err;
     UInt32 ui_param_size;
 
+    struct thread_time_constraint_policy ttcpolicy;
+    int mib[2];
+    unsigned int miblen;
+    int i_busspeed;
+    size_t len;
+
     /* allocate instance */
     p_aout->p_sys = malloc( sizeof( aout_sys_t ) );
     if( p_aout->p_sys == NULL )
@@ -169,6 +180,40 @@ static int aout_Open( aout_thread_t *p_aout )
         return( -1 );
     }
 
+    /* Go to time-constrained thread policy */
+
+    /* Get bus speed */
+    mib[0] = CTL_HW;
+    mib[1] = HW_BUS_FREQ;
+    miblen = 2;
+    len = 4;
+    if( sysctl(mib, miblen, &i_busspeed, &len, NULL, 0) == -1 )
+    {
+        intf_ErrMsg("vout error: couldn't go to time-constrained policy (bus speed)");
+    }
+    else
+    {
+        /* This is in AbsoluteTime units, which are equal to
+         * 1/4 the bus speed on most machines. */
+        /* FIXME : these are random numbers ! */
+        /* hard-coded numbers are approximations for 100 MHz bus speed.
+         * assume that app deals in frame-sized chunks, e.g. 30 per second.
+         * ttcpolicy.period = 833333; */
+        ttcpolicy.period = i_busspeed / 120;
+        /* ttcpolicy.computation = 60000; */
+        ttcpolicy.computation = i_busspeed / 1440;
+        /* ttcpolicy.constraint = 120000; */
+        ttcpolicy.constraint = i_busspeed / 720;
+        ttcpolicy.preemptible = 1;
+
+        if (thread_policy_set(mach_thread_self(),
+                  THREAD_TIME_CONSTRAINT_POLICY, (int *)&ttcpolicy,
+                  THREAD_TIME_CONSTRAINT_POLICY_COUNT) != KERN_SUCCESS)
+        {
+            intf_ErrMsg("vout error: couldn't go to time-constrained policy (thread_policy_set)");
+        }
+    }
+
     return( 0 );
 }
 
index f65a5fd5e5d12559fe8dc61468769cbe4afa7ed8..de71a56e217b9bdb78dc0098487512e0292a32d1 100644 (file)
 #include <errno.h>                                                 /* ENOMEM */
 #include <stdlib.h>                                                /* free() */
 #include <string.h>                                            /* strerror() */
+#include <mach/mach_init.h>
+#include <mach/task_policy.h>
+#include <mach/thread_act.h>
+#include <mach/thread_policy.h>
+#include <sys/sysctl.h>
 
 #include <videolan/vlc.h>
 
@@ -179,6 +184,12 @@ static int vout_Init( vout_thread_t *p_vout )
     int i_index;
     picture_t *p_pic;
 
+    struct thread_time_constraint_policy ttcpolicy;
+    int mib[2];
+    unsigned int miblen;
+    int i_busspeed;
+    size_t len;
+
     I_OUTPUTPICTURES = 0;
 
     /* Initialize the output structure; we already found a codec,
@@ -226,6 +237,40 @@ static int vout_Init( vout_thread_t *p_vout )
         I_OUTPUTPICTURES++;
     }
 
+    /* Go to time-constrained thread policy */
+
+    /* Get bus speed */
+    mib[0] = CTL_HW;
+    mib[1] = HW_BUS_FREQ;
+    miblen = 2;
+    len = 4;
+    if( sysctl(mib, miblen, &i_busspeed, &len, NULL, 0) == -1 )
+    {
+        intf_ErrMsg("vout error: couldn't go to time-constrained policy (bus speed)");
+    }
+    else
+    {
+        /* This is in AbsoluteTime units, which are equal to
+         * 1/4 the bus speed on most machines. */
+
+        /* hard-coded numbers are approximations for 100 MHz bus speed.
+         * assume that app deals in frame-sized chunks, e.g. 30 per second.
+         * ttcpolicy.period = 833333; */
+        ttcpolicy.period = i_busspeed / 120;
+        /* ttcpolicy.computation = 60000; */
+        ttcpolicy.computation = i_busspeed / 1440;
+        /* ttcpolicy.constraint = 120000; */
+        ttcpolicy.constraint = i_busspeed / 720;
+        ttcpolicy.preemptible = 1;
+
+        if (thread_policy_set(mach_thread_self(),
+                  THREAD_TIME_CONSTRAINT_POLICY, (int *)&ttcpolicy,
+                  THREAD_TIME_CONSTRAINT_POLICY_COUNT) != KERN_SUCCESS)
+        {
+            intf_ErrMsg("vout error: couldn't go to time-constrained policy (thread_policy_set)");
+        }
+    }
+
     return( 0 );
 }