/*****************************************************************************
- * libvlc-common.c: libvlc instances creation and deletion
+ * libvlc-common.c: libvlc instances creation and deletion, interfaces handling
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
* $Id$
#ifdef WIN32
static void ShowConsole ( vlc_bool_t );
static void PauseConsole ( void );
+extern void __wgetmainargs(int *argc, wchar_t ***wargv, wchar_t ***wenviron,
+ int expand_wildcards, int *startupinfo);
#endif
static int ConsoleWidth ( void );
int i_ret;
libvlc_int_t * p_libvlc = NULL;
vlc_value_t lockval;
+ char *psz_env;
/* &libvlc_global never changes,
* so we can safely call this multiple times. */
if( !libvlc_global.b_ready )
{
- char *psz_env;
-
/* Guess what CPU we have */
libvlc_global.i_cpu = CPUCapabilities();
-
- /* Find verbosity from VLC_VERBOSE environment variable */
- psz_env = getenv( "VLC_VERBOSE" );
- libvlc_global.i_verbose = psz_env ? atoi( psz_env ) : -1;
-
-#if defined( HAVE_ISATTY ) && !defined( WIN32 )
- libvlc_global.b_color = isatty( 2 ); /* 2 is for stderr */
-#else
- libvlc_global.b_color = VLC_FALSE;
-#endif
-
- /* Initialize message queue */
- msg_Create( p_libvlc_global );
-
- /* Announce who we are */
- msg_Dbg( p_libvlc_global, COPYRIGHT_MESSAGE );
- msg_Dbg( p_libvlc_global, "libvlc was configured with %s",
- CONFIGURE_LINE );
-
- /* The module bank will be initialized later */
+ /* The module bank will be initialized later */
libvlc_global.p_module_bank = NULL;
libvlc_global.b_ready = VLC_TRUE;
p_libvlc->p_playlist = NULL;
p_libvlc->psz_object_name = "libvlc";
+ /* Initialize message queue */
+ msg_Create( p_libvlc );
+ /* Announce who we are - Do it only for first instance ? */
+ msg_Dbg( p_libvlc, COPYRIGHT_MESSAGE );
+ msg_Dbg( p_libvlc, "libvlc was configured with %s", CONFIGURE_LINE );
+
+ /* Find verbosity from VLC_VERBOSE environment variable */
+ psz_env = getenv( "VLC_VERBOSE" );
+ p_libvlc->i_verbose = psz_env ? atoi( psz_env ) : -1;
+
+#if defined( HAVE_ISATTY ) && !defined( WIN32 )
+ p_libvlc->b_color = isatty( 2 ); /* 2 is for stderr */
+#else
+ p_libvlc->b_color = VLC_FALSE;
+#endif
+
/* Initialize mutexes */
vlc_mutex_init( p_libvlc, &p_libvlc->config_lock );
#ifdef __APPLE__
/* End hack */
/* Will be re-done properly later on */
- p_libvlc->p_libvlc_global->i_verbose = config_GetInt( p_libvlc, "verbose" );
+ p_libvlc->i_verbose = config_GetInt( p_libvlc, "verbose" );
/* Check for daemon mode */
#ifndef WIN32
var_AddCallback( p_libvlc, "verbose", VerboseCallback, NULL );
var_Change( p_libvlc, "verbose", VLC_VAR_TRIGGER_CALLBACKS, NULL, NULL );
- libvlc_global.b_color = libvlc_global.b_color &&
- config_GetInt( p_libvlc, "color" );
+ p_libvlc->b_color = p_libvlc->b_color && config_GetInt( p_libvlc, "color" );
/*
* Output messages that may still be in the queue
/* System specific cleaning code */
system_End( p_libvlc );
- /* Free message queue. Nobody shall use msg_* afterward. */
- msg_Flush( p_libvlc );
- msg_Destroy( p_libvlc_global );
-
- /* Destroy global iconv */
+ /* Destroy global iconv */
LocaleDeinit();
}
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_libvlc_global, "libvlc" );
+ msg_Flush( p_libvlc );
+ msg_Destroy( p_libvlc );
+
/* Destroy mutexes */
vlc_mutex_destroy( &p_libvlc->config_lock );
{
int i_opt, i_options;
+#ifdef WIN32
+ wchar_t **wargv, **wenvp;
+ int si = { 0 };
+
+ if( GetVersion() < 0x80000000 )
+ {
+ /* fetch unicode argv[] for Windows NT and above */
+ __wgetmainargs(&i_opt, &wargv, &wenvp, 0, &si);
+ }
+#endif
+
/* We assume that the remaining parameters are filenames
* and their input options */
for( i_opt = i_argc - 1; i_opt >= optind; i_opt-- )
/* TODO: write an internal function of this one, to avoid
* unnecessary lookups. */
/* FIXME: should we convert options to UTF-8 as well ?? */
- psz_target = FromLocale( ppsz_argv[ i_opt ] );
- VLC_AddTarget( p_vlc->i_object_id, psz_target,
+
+#ifdef WIN32
+ if( GetVersion() < 0x80000000 )
+ {
+ psz_target = FromWide( wargv[ i_opt ] );
+ VLC_AddTarget( p_vlc->i_object_id, psz_target,
(char const **)( i_options ? &ppsz_argv[i_opt + 1] :
NULL ), i_options,
PLAYLIST_INSERT, 0 );
- LocaleFree( psz_target );
+ free( psz_target );
+ }
+ else
+#endif
+ {
+ psz_target = FromLocale( ppsz_argv[ i_opt ] );
+ VLC_AddTarget( p_vlc->i_object_id, psz_target,
+ (char const **)( i_options ? &ppsz_argv[i_opt + 1] :
+ NULL ), i_options,
+ PLAYLIST_INSERT, 0 );
+ LocaleFree( psz_target );
+ }
}
return VLC_SUCCESS;
static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
{
#define FORMAT_STRING " %s --%s%s%s%s%s%s%s "
- /* short option ------' | | | | | | |
- * option name ------------' | | | | | |
- * <bra -------------------------' | | | | |
- * option type or "" --------------' | | | |
- * ket> -----------------------------' | | |
- * padding spaces ---------------------' | |
- * comment -------------------------------' |
- * comment suffix --------------------------'
+ /* short option ------' | | | | | | |
+ * option name ------------' | | | | | |
+ * <bra ---------------------' | | | | |
+ * option type or "" ----------' | | | |
+ * ket> -------------------------' | | |
+ * padding spaces -----------------' | |
+ * comment --------------------------' |
+ * comment suffix ---------------------'
*
* The purpose of having bra and ket is that we might i18n them as well.
*/
static int VerboseCallback( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param)
{
- libvlc_int_t *p_vlc = (libvlc_int_t *)p_this;
+ libvlc_int_t *p_libvlc = (libvlc_int_t *)p_this;
if( new_val.i_int >= -1 )
{
- p_vlc->p_libvlc_global->i_verbose = __MIN( new_val.i_int, 2 );
+ p_libvlc->i_verbose = __MIN( new_val.i_int, 2 );
}
return VLC_SUCCESS;
}