]> git.sesse.net Git - vlc/blobdiff - src/interface/main.c
* Borrowed MPlayer's fast memcpy() routines. Best is autodetected, choose
[vlc] / src / interface / main.c
index 55c9e42a395b1198ed7d5c651a220ebc0783bc29..bb24a2885da8ac8b3b8fa69af0898cd62da02375 100644 (file)
@@ -3,8 +3,8 @@
  * Includes the main() function for vlc. Parses command line, start interface
  * and spawn threads.
  *****************************************************************************
- * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: main.c,v 1.122 2001/11/12 12:54:16 massiot Exp $
+ * Copyright (C) 1998-2001 VideoLAN
+ * $Id: main.c,v 1.128 2001/12/03 16:18:37 sam Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -67,6 +67,7 @@
 #include "config.h"
 #include "common.h"
 #include "debug.h"
+#include "intf_msg.h"
 #include "threads.h"
 #include "mtime.h"
 #include "tests.h"                                              /* TestCPU() */
@@ -75,7 +76,6 @@
 #include "stream_control.h"
 #include "input_ext-intf.h"
 
-#include "intf_msg.h"
 #include "intf_playlist.h"
 #include "interface.h"
 
 #   include "darwin_specific.h"
 #endif
 
+#ifdef WIN32
+#   include "win32_specific.h"
+#endif
+
 #include "netutils.h"                                 /* network_ChannelJoin */
 
 #include "main.h"
 #define OPT_YUV                 183
 #define OPT_DOWNMIX             184
 #define OPT_IMDCT               185
-#define OPT_DVDCSS              186
+#define OPT_MEMCPY              186
+#define OPT_DVDCSS_METHOD       187
+#define OPT_DVDCSS_VERBOSE      188
 
 #define OPT_SYNCHRO             190
 #define OPT_WARNING             191
@@ -203,18 +209,17 @@ static const struct option longopts[] =
     {   "dvdaudio",         1,          0,      'a' },
     {   "dvdchannel",       1,          0,      'c' },
     {   "dvdsubtitle",      1,          0,      's' },
-    {   "dvdcss_method",    1,          0,      OPT_DVDCSS },
+    {   "dvdcss-method",    1,          0,      OPT_DVDCSS_METHOD },
+    {   "dvdcss-verbose",   1,          0,      OPT_DVDCSS_VERBOSE },
     
     /* Input options */
     {   "input",            1,          0,      OPT_INPUT },
-    {   "server",           1,          0,      OPT_SERVER },
-    {   "port",             1,          0,      OPT_PORT },
-    {   "broadcast",        1,          0,      OPT_BROADCAST },
     {   "channels",         0,          0,      OPT_CHANNELS },
     {   "channelserver",    1,          0,      OPT_CHANNELSERVER },
 
-    /* Synchro options */
+    /* Misc options */
     {   "synchro",          1,          0,      OPT_SYNCHRO },
+    {   "memcpy",           1,          0,      OPT_MEMCPY },
     {   0,                  0,          0,      0 }
 };
 
@@ -222,13 +227,13 @@ static const struct option longopts[] =
 static const char *psz_shortopts = "hHvgt:T:u:a:s:c:I:A:V:";
 
 /*****************************************************************************
- * Global variable program_data - these are the only ones, see main.h and
- * modules.h
+ * Global variables - these are the only ones, see main.h and modules.h
  *****************************************************************************/
 main_t        *p_main;
 module_bank_t *p_module_bank;
 aout_bank_t   *p_aout_bank;
 vout_bank_t   *p_vout_bank;
+void*       ( *pf_fast_memcpy ) ( void *, const void *, size_t );
 
 /*****************************************************************************
  * Local prototypes
@@ -286,12 +291,9 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
     /*
      * System specific initialization code
      */
-#if defined( SYS_BEOS ) || defined( SYS_DARWIN )
+#if defined( SYS_BEOS ) || defined( SYS_DARWIN ) || defined( WIN32 )
     system_Init( &i_argc, ppsz_argv, ppsz_env );
 
-#elif defined( WIN32 )
-    _fmode = _O_BINARY;   /* sets the default file-translation mode on Win32 */
-
 #elif defined( SYS_LINUX )
 #   ifdef DEBUG
     /* Activate malloc checking routines to detect heap corruptions. */
@@ -375,6 +377,24 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
     aout_InitBank();
     vout_InitBank();
 
+    /*
+     * Choose the best memcpy module
+     */
+    p_main->p_memcpy_module = module_Need( MODULE_CAPABILITY_MEMCPY, NULL );
+
+    if( p_main->p_memcpy_module == NULL )
+    {
+        intf_ErrMsg( "intf error: no suitable memcpy module, "
+                     "using libc default" );
+        pf_fast_memcpy = memcpy;
+    }
+    else
+    {
+#define f p_main->p_memcpy_module->p_functions->memcpy.functions.memcpy
+        pf_fast_memcpy = f.pf_fast_memcpy;
+#undef f
+    }
+
     /*
      * Initialize shared resources and libraries
      */
@@ -423,6 +443,11 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
         }
     }
 
+    /*
+     * Free memcpy module
+     */
+    module_Unneed( p_main->p_memcpy_module );
+
     /*
      * Free module, aout and vout banks
      */
@@ -438,7 +463,7 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
     /*
      * System specific cleaning code
      */
-#if defined( SYS_BEOS ) || defined( SYS_DARWIN )
+#if defined( SYS_BEOS ) || defined( SYS_DARWIN ) || defined( WIN32 )
     system_End();
 #endif
 
@@ -772,8 +797,11 @@ static int GetConfiguration( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] )
         case 's':                                           /* --dvdsubtitle */
             main_PutIntVariable( INPUT_SUBTITLE_VAR, atoi(optarg) );
             break;
-        case OPT_DVDCSS:                                         /* --dvdcss */
-                main_PutPszVariable( INPUT_DVDCSS_VAR, optarg );
+        case OPT_DVDCSS_METHOD:                           /* --dvdcss-method */
+            main_PutPszVariable( "DVDCSS_METHOD", optarg );
+            break;
+        case OPT_DVDCSS_VERBOSE:                         /* --dvdcss-verbose */
+            main_PutPszVariable( "DVDCSS_VERBOSE", optarg );
             break;
 
         /* Input options */
@@ -786,21 +814,14 @@ static int GetConfiguration( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] )
         case OPT_CHANNELSERVER:                           /* --channelserver */
             main_PutPszVariable( INPUT_CHANNEL_SERVER_VAR, optarg );
             break;
-        case OPT_SERVER:                                         /* --server */
-            main_PutPszVariable( INPUT_SERVER_VAR, optarg );
-            break;
-        case OPT_PORT:                                             /* --port */
-            main_PutPszVariable( INPUT_PORT_VAR, optarg );
-            break;
-        case OPT_BROADCAST:                                   /* --broadcast */
-            main_PutIntVariable( INPUT_BROADCAST_VAR, 1 );
-            main_PutPszVariable( INPUT_BCAST_ADDR_VAR, optarg );
-            break;
 
-        /* Synchro options */
+        /* Misc options */
         case OPT_SYNCHRO:                                      
             main_PutPszVariable( VPAR_SYNCHRO_VAR, optarg );
             break;
+        case OPT_MEMCPY:                                      
+            main_PutPszVariable( MEMCPY_METHOD_VAR, optarg );
+            break;
             
         /* Internal error: unknown option */
         case '?':
@@ -874,6 +895,7 @@ static void Usage( int i_fashion )
           "\n  -I, --intf <module>            \tinterface method"
           "\n  -v, --verbose                  \tverbose mode (cumulative)"
           "\n      --stdout <filename>        \tredirect console stdout"
+          "\n      --memcpy <module>          \tmemcpy method"
           "\n"
           "\n      --noaudio                  \tdisable audio"
           "\n  -A, --aout <module>            \taudio output method"
@@ -904,14 +926,12 @@ static void Usage( int i_fashion )
           "\n  -a, --dvdaudio <type>          \tchoose DVD audio type"
           "\n  -c, --dvdchannel <channel>     \tchoose DVD audio channel"
           "\n  -s, --dvdsubtitle <channel>    \tchoose DVD subtitle channel"
-          "\n    , --dvdcss <method>          \tselect DVDCSS decryption method"
+          "\n      --dvdcss-method <method>   \tselect dvdcss decryption method"
+          "\n      --dvdcss-verbose <level>   \tselect dvdcss verbose level"
           "\n"
           "\n      --input                    \tinput method"
           "\n      --channels                 \tenable channels"
           "\n      --channelserver <host>     \tchannel server address"
-          "\n      --server <host>            \tvideo server address"
-          "\n      --port <port>              \tvideo server port"
-          "\n      --broadcast                \tlisten to a broadcast"
           "\n"
           "\n  -h, --help                     \tprint help and exit"
           "\n  -H, --longhelp                 \tprint long help and exit"
@@ -925,7 +945,8 @@ static void Usage( int i_fashion )
         "\n  " INTF_METHOD_VAR "=<method name>        \tinterface method"
         "\n  " INTF_INIT_SCRIPT_VAR "=<filename>              \tinitialization script"
         "\n  " INTF_CHANNELS_VAR "=<filename>         \tchannels list"
-        "\n  " INTF_STDOUT_VAR "=<filename>           \tredirect console stdout" );
+        "\n  " INTF_STDOUT_VAR "=<filename>           \tredirect console stdout"
+        "\n  " MEMCPY_METHOD_VAR "=<method name>      \tmemcpy method" );
 
     /* Audio parameters */
     intf_MsgImm( "\nAudio parameters:"
@@ -936,7 +957,7 @@ static void Usage( int i_fashion )
         "\n  " DOWNMIX_METHOD_VAR "=<method name>     \tAC3 downmix method"
         "\n  " IMDCT_METHOD_VAR "=<method name>       \tAC3 IMDCT method"
         "\n  " AOUT_VOLUME_VAR "=[0..1024]            \tVLC output volume"
-        "\n  " AOUT_RATE_VAR "=<rate>                 \toutput rate" );
+        "\n  " AOUT_RATE_VAR "=<rate>             \toutput rate" );
 
     /* Video parameters */
     intf_MsgImm( "\nVideo parameters:"
@@ -963,15 +984,11 @@ static void Usage( int i_fashion )
         "\n  " INPUT_ANGLE_VAR "=<angle>              \tangle number"
         "\n  " INPUT_AUDIO_VAR "={ac3|lpcm|mpeg|off}  \taudio type"
         "\n  " INPUT_CHANNEL_VAR "=[0-15]             \taudio channel"
-        "\n  " INPUT_SUBTITLE_VAR "=[0-31]            \tsubtitle channel"
-        "\n  " INPUT_DVDCSS_VAR "={csskey|disc|title} \tdvdcss method" );
+        "\n  " INPUT_SUBTITLE_VAR "=[0-31]            \tsubtitle channel" );
 
     /* Input parameters */
     intf_MsgImm( "\nInput parameters:"
-        "\n  " INPUT_SERVER_VAR "=<hostname>          \tvideo server"
-        "\n  " INPUT_PORT_VAR "=<port>                \tvideo server port"
         "\n  " INPUT_IFACE_VAR "=<interface>          \tnetwork interface"
-        "\n  " INPUT_BCAST_ADDR_VAR "=<addr>          \tbroadcast mode"
         "\n  " INPUT_CHANNEL_SERVER_VAR "=<hostname>  \tchannel server"
         "\n  " INPUT_CHANNEL_PORT_VAR "=<port>        \tchannel server port" );
 
@@ -1177,7 +1194,7 @@ static int CPUCapabilities( void )
     {
         i_capabilities |= CPU_CAPABILITY_MMXEXT;
 
-#ifdef HAVE_SSE
+#ifdef CAN_COMPILE_SSE
         /* We test if OS support the SSE instructions */
         i_illegal = 0;
         if( setjmp( env ) == 0 )
@@ -1214,7 +1231,7 @@ static int CPUCapabilities( void )
     /* list these additional capabilities */
     cpuid( 0x80000001 );
 
-#ifdef HAVE_3DNOW
+#ifdef CAN_COMPILE_3DNOW
     if( i_edx & 0x80000000 )
     {
         i_illegal = 0;
@@ -1244,7 +1261,7 @@ static int CPUCapabilities( void )
     /* Test for Altivec */
     signal( SIGILL, InstructionSignalHandler );
 
-#ifdef HAVE_ALTIVEC
+#ifdef CAN_COMPILE_ALTIVEC
     i_illegal = 0;
     if( setjmp( env ) == 0 )
     {