+ var_Create( p_libvlc, "verbose", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+ if( config_GetInt( p_libvlc, "quiet" ) > 0 )
+ {
+ val.i_int = -1;
+ var_Set( p_libvlc, "verbose", val );
+ }
+ var_AddCallback( p_libvlc, "verbose", VerboseCallback, NULL );
+ var_Change( p_libvlc, "verbose", VLC_VAR_TRIGGER_CALLBACKS, NULL, NULL );
+
+ if( priv->b_color )
+ priv->b_color = config_GetInt( p_libvlc, "color" ) > 0;
+
+ /*
+ * Output messages that may still be in the queue
+ */
+ msg_Flush( p_libvlc );
+
+ if( !config_GetInt( p_libvlc, "fpu" ) )
+ cpu_flags &= ~CPU_CAPABILITY_FPU;
+
+#if defined( __i386__ ) || defined( __x86_64__ )
+ if( !config_GetInt( p_libvlc, "mmx" ) )
+ cpu_flags &= ~CPU_CAPABILITY_MMX;
+ if( !config_GetInt( p_libvlc, "3dn" ) )
+ cpu_flags &= ~CPU_CAPABILITY_3DNOW;
+ if( !config_GetInt( p_libvlc, "mmxext" ) )
+ cpu_flags &= ~CPU_CAPABILITY_MMXEXT;
+ if( !config_GetInt( p_libvlc, "sse" ) )
+ cpu_flags &= ~CPU_CAPABILITY_SSE;
+ if( !config_GetInt( p_libvlc, "sse2" ) )
+ cpu_flags &= ~CPU_CAPABILITY_SSE2;
+#endif
+#if defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
+ if( !config_GetInt( p_libvlc, "altivec" ) )
+ cpu_flags &= ~CPU_CAPABILITY_ALTIVEC;
+#endif
+
+#define PRINT_CAPABILITY( capability, string ) \
+ if( vlc_CPU() & capability ) \
+ { \
+ strncat( p_capabilities, string " ", \
+ sizeof(p_capabilities) - strlen(p_capabilities) ); \
+ p_capabilities[sizeof(p_capabilities) - 1] = '\0'; \
+ }
+
+ p_capabilities[0] = '\0';
+ PRINT_CAPABILITY( CPU_CAPABILITY_486, "486" );
+ PRINT_CAPABILITY( CPU_CAPABILITY_586, "586" );
+ PRINT_CAPABILITY( CPU_CAPABILITY_PPRO, "Pentium Pro" );
+ PRINT_CAPABILITY( CPU_CAPABILITY_MMX, "MMX" );
+ PRINT_CAPABILITY( CPU_CAPABILITY_3DNOW, "3DNow!" );
+ PRINT_CAPABILITY( CPU_CAPABILITY_MMXEXT, "MMXEXT" );
+ PRINT_CAPABILITY( CPU_CAPABILITY_SSE, "SSE" );
+ PRINT_CAPABILITY( CPU_CAPABILITY_SSE2, "SSE2" );
+ PRINT_CAPABILITY( CPU_CAPABILITY_ALTIVEC, "AltiVec" );
+ PRINT_CAPABILITY( CPU_CAPABILITY_FPU, "FPU" );
+ msg_Dbg( p_libvlc, "CPU has capabilities %s", p_capabilities );
+
+ /*
+ * Choose the best memcpy module
+ */
+ priv->p_memcpy_module = module_Need( p_libvlc, "memcpy", "$memcpy", 0 );
+
+ priv->b_stats = config_GetInt( p_libvlc, "stats" ) > 0;
+ priv->i_timers = 0;
+ priv->pp_timers = NULL;
+
+ /* Init stats */
+ p_libvlc->p_stats = (global_stats_t *)malloc( sizeof( global_stats_t ) );
+ if( !p_libvlc->p_stats )
+ {
+ vlc_object_release( p_libvlc );
+ return VLC_ENOMEM;
+ }
+ vlc_mutex_init( &p_libvlc->p_stats->lock );
+ priv->p_stats_computer = NULL;
+
+ /* Init the array that holds every input item */
+ ARRAY_INIT( priv->input_items );
+ priv->i_last_input_id = 0;
+
+ /*
+ * Initialize hotkey handling
+ */
+ var_Create( p_libvlc, "key-pressed", VLC_VAR_INTEGER );
+ var_Create( p_libvlc, "key-action", VLC_VAR_INTEGER );
+ p_libvlc->p_hotkeys = malloc( libvlc_hotkeys_size );
+ /* Do a copy (we don't need to modify the strings) */
+ memcpy( p_libvlc->p_hotkeys, libvlc_hotkeys, libvlc_hotkeys_size );
+ var_AddCallback( p_libvlc, "key-pressed", vlc_key_to_action,
+ p_libvlc->p_hotkeys );
+
+ /* Initialize interaction */
+ priv->p_interaction = interaction_Init( p_libvlc );
+
+ /* Initialize playlist and get commandline files */
+ playlist_ThreadCreate( p_libvlc );
+ if( !priv->p_playlist )
+ {
+ msg_Err( p_libvlc, "playlist initialization failed" );
+ if( priv->p_memcpy_module != NULL )
+ {
+ module_Unneed( p_libvlc, priv->p_memcpy_module );
+ }
+ module_EndBank( p_libvlc );
+ return VLC_EGENERIC;
+ }
+ p_playlist = priv->p_playlist;
+
+ psz_modules = config_GetPsz( p_playlist, "services-discovery" );
+ if( psz_modules && *psz_modules )
+ {
+ /* Add service discovery modules */
+ playlist_ServicesDiscoveryAdd( p_playlist, psz_modules );
+ }
+ free( psz_modules );
+
+#ifdef ENABLE_VLM
+ /* Initialize VLM if vlm-conf is specified */
+ psz_parser = config_GetPsz( p_libvlc, "vlm-conf" );
+ if( psz_parser && *psz_parser )
+ {
+ priv->p_vlm = vlm_New( p_libvlc );
+ if( !priv->p_vlm )
+ msg_Err( p_libvlc, "VLM initialization failed" );
+ }
+ free( psz_parser );
+#endif
+
+ /*
+ * Load background interfaces
+ */
+ psz_modules = config_GetPsz( p_libvlc, "extraintf" );
+ psz_control = config_GetPsz( p_libvlc, "control" );
+
+ if( psz_modules && *psz_modules && psz_control && *psz_control )
+ {
+ psz_modules = (char *)realloc( psz_modules, strlen( psz_modules ) +
+ strlen( psz_control ) + 1 );
+ sprintf( psz_modules, "%s:%s", psz_modules, psz_control );
+ }
+ else if( psz_control && *psz_control )
+ {
+ free( psz_modules );
+ psz_modules = strdup( psz_control );
+ }
+
+ psz_parser = psz_modules;
+ while ( psz_parser && *psz_parser )
+ {
+ char *psz_module, *psz_temp;
+ psz_module = psz_parser;
+ psz_parser = strchr( psz_module, ':' );
+ if ( psz_parser )
+ {
+ *psz_parser = '\0';
+ psz_parser++;
+ }
+ psz_temp = (char *)malloc( strlen(psz_module) + sizeof(",none") );
+ if( psz_temp )
+ {
+ sprintf( psz_temp, "%s,none", psz_module );
+ libvlc_InternalAddIntf( p_libvlc, psz_temp );
+ free( psz_temp );
+ }
+ }
+ free( psz_modules );
+ free( psz_control );
+
+ /*
+ * Always load the hotkeys interface if it exists
+ */
+ libvlc_InternalAddIntf( p_libvlc, "hotkeys,none" );
+
+#ifdef HAVE_DBUS
+ /* loads dbus control interface if in one-instance mode
+ * we do it only when playlist exists, because dbus module needs it */
+ if( config_GetInt( p_libvlc, "one-instance" ) > 0 )
+ libvlc_InternalAddIntf( p_libvlc, "dbus,none" );
+
+ /* Prevents the power management daemon from suspending the system
+ * when VLC is active */
+ if( config_GetInt( p_libvlc, "inhibit" ) > 0 )
+ libvlc_InternalAddIntf( p_libvlc, "inhibit,none" );
+#endif
+
+ /*
+ * If needed, load the Xscreensaver interface
+ * Currently, only for X
+ */
+#ifdef HAVE_X11_XLIB_H
+ if( config_GetInt( p_libvlc, "disable-screensaver" ) )
+ {
+ libvlc_InternalAddIntf( p_libvlc, "screensaver,none" );
+ }
+#endif
+
+ if( config_GetInt( p_libvlc, "file-logging" ) > 0 )
+ {
+ libvlc_InternalAddIntf( p_libvlc, "logger,none" );
+ }
+#ifdef HAVE_SYSLOG_H
+ if( config_GetInt( p_libvlc, "syslog" ) > 0 )
+ {
+ char *logmode = var_CreateGetString( p_libvlc, "logmode" );
+ var_SetString( p_libvlc, "logmode", "syslog" );
+ libvlc_InternalAddIntf( p_libvlc, "logger,none" );
+
+ if( logmode )
+ {
+ var_SetString( p_libvlc, "logmode", logmode );
+ free( logmode );
+ }
+ else
+ var_Destroy( p_libvlc, "logmode" );
+ }
+#endif
+
+ if( config_GetInt( p_libvlc, "show-intf" ) > 0 )
+ {
+ libvlc_InternalAddIntf( p_libvlc, "showintf,none" );
+ }
+
+ if( config_GetInt( p_libvlc, "network-synchronisation") > 0 )
+ {
+ libvlc_InternalAddIntf( p_libvlc, "netsync,none" );
+ }
+
+#ifdef WIN32
+ if( config_GetInt( p_libvlc, "prefer-system-codecs") > 0 )
+ {
+ char *psz_codecs = config_GetPsz( p_playlist, "codec" );
+ if( psz_codecs )
+ {
+ char *psz_morecodecs;
+ asprintf(&psz_morecodecs, "%s,dmo,quicktime", psz_codecs);
+ if( psz_morecodecs )
+ {
+ config_PutPsz( p_libvlc, "codec", psz_morecodecs);
+ free( psz_morecodecs );
+ }
+ }
+ else
+ config_PutPsz( p_libvlc, "codec", "dmo,quicktime");
+ free( psz_codecs );
+ }
+#endif
+
+ /*
+ * FIXME: kludge to use a p_libvlc-local variable for the Mozilla plugin
+ */
+ var_Create( p_libvlc, "drawable", VLC_VAR_INTEGER );
+ var_Create( p_libvlc, "drawable-view-top", VLC_VAR_INTEGER );
+ var_Create( p_libvlc, "drawable-view-left", VLC_VAR_INTEGER );
+ var_Create( p_libvlc, "drawable-view-bottom", VLC_VAR_INTEGER );
+ var_Create( p_libvlc, "drawable-view-right", VLC_VAR_INTEGER );
+ var_Create( p_libvlc, "drawable-clip-top", VLC_VAR_INTEGER );
+ var_Create( p_libvlc, "drawable-clip-left", VLC_VAR_INTEGER );
+ var_Create( p_libvlc, "drawable-clip-bottom", VLC_VAR_INTEGER );
+ var_Create( p_libvlc, "drawable-clip-right", VLC_VAR_INTEGER );
+
+ /* Create volume callback system. */
+ var_Create( p_libvlc, "volume-change", VLC_VAR_BOOL );
+
+ /* Create a variable for showing the interface (moved from playlist). */
+ var_Create( p_libvlc, "intf-show", VLC_VAR_BOOL );
+ var_SetBool( p_libvlc, "intf-show", true );
+
+ var_Create( p_libvlc, "intf-popupmenu", VLC_VAR_BOOL );
+
+ /*
+ * Get input filenames given as commandline arguments
+ */
+ GetFilenames( p_libvlc, i_argc, ppsz_argv );
+
+ /*
+ * Get --open argument
+ */
+ var_Create( p_libvlc, "open", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+ var_Get( p_libvlc, "open", &val );
+ if ( val.psz_string != NULL && *val.psz_string )
+ {
+ playlist_t *p_playlist = pl_Yield( p_libvlc );
+ playlist_AddExt( p_playlist, val.psz_string, NULL, PLAYLIST_INSERT, 0,
+ -1, NULL, 0, true, pl_Unlocked );
+ pl_Release( p_libvlc );
+ }
+ free( val.psz_string );
+
+ return VLC_SUCCESS;