X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fwin32%2Fspecific.c;h=531e29271a6fc4dcecab4de3654ad79ddc9c2935;hb=12ade3e3bc975d5426ba4af155b7372c31093b31;hp=c896be5ab11daa0f22b5a15c6432203d9a85c8ce;hpb=57fc7b4e8b328c9761bee17eaac163e0adfdcfa7;p=vlc diff --git a/src/win32/specific.c b/src/win32/specific.c index c896be5ab1..531e29271a 100644 --- a/src/win32/specific.c +++ b/src/win32/specific.c @@ -1,7 +1,7 @@ /***************************************************************************** * specific.c: Win32 specific initilization ***************************************************************************** - * Copyright (C) 2001-2004 the VideoLAN team + * Copyright (C) 2001-2004, 2010 the VideoLAN team * * Authors: Samuel Hocevar * Gildas Bazin @@ -29,9 +29,9 @@ #include #include "../libvlc.h" #include -#include +#include -#include "../extras/getopt.h" +#include "../config/vlc_getopt.h" #if !defined( UNDER_CE ) # include @@ -48,33 +48,35 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] ) { VLC_UNUSED( p_this ); VLC_UNUSED( pi_argc ); VLC_UNUSED( ppsz_argv ); WSADATA Data; + MEMORY_BASIC_INFORMATION mbi; /* Get our full path */ char psz_path[MAX_PATH]; char *psz_vlc; wchar_t psz_wpath[MAX_PATH]; - if( GetModuleFileName( NULL, psz_wpath, MAX_PATH ) ) + if( VirtualQuery(system_Init, &mbi, sizeof(mbi) ) ) { - WideCharToMultiByte( CP_UTF8, 0, psz_wpath, -1, - psz_path, MAX_PATH, NULL, NULL ); + HMODULE hMod = (HMODULE) mbi.AllocationBase; + if( GetModuleFileName( hMod, psz_wpath, MAX_PATH ) ) + { + WideCharToMultiByte( CP_UTF8, 0, psz_wpath, -1, + psz_path, MAX_PATH, NULL, NULL ); + } + else psz_path[0] = '\0'; } - else psz_path[0] = '\0'; - if( (psz_vlc = strrchr( psz_path, '\\' )) ) *psz_vlc = '\0'; + psz_vlc = strrchr( psz_path, '\\' ); + if( psz_vlc ) + *psz_vlc = '\0'; -#ifndef HAVE_RELEASE { /* remove trailing \.libs from executable dir path if seen, we assume we are running vlc through libtool wrapper in build dir */ - int offset = strlen(psz_path)-sizeof("\\.libs")+1; - if( offset > 0 ) - { - psz_vlc = psz_path+offset; - if( ! strcmp(psz_vlc, "\\.libs") ) *psz_vlc = '\0'; - } + size_t len = strlen(psz_path); + if( len >= 5 && !stricmp(psz_path + len - 5, "\\.libs" ) ) + psz_path[len - 5] = '\0'; } -#endif psz_vlcpath = strdup( psz_path ); @@ -133,7 +135,7 @@ typedef struct char data[]; } vlc_ipc_data_t; -void system_Configure( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] ) +void system_Configure( libvlc_int_t *p_this, int i_argc, const char *const ppsz_argv[] ) { #if !defined( UNDER_CE ) /* Raise default priority of the current process */ @@ -153,7 +155,7 @@ void system_Configure( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv } } - if( varInheritBool( p_this, "one-instance" ) + if( var_InheritBool( p_this, "one-instance" ) || ( var_InheritBool( p_this, "one-instance-when-started-from-file" ) && var_InheritBool( p_this, "started-from-file" ) ) ) { @@ -220,24 +222,24 @@ void system_Configure( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv /* We assume that the remaining parameters are filenames * and their input options */ - if( *pi_argc - 1 >= optind ) + if( i_argc > 0 ) { COPYDATASTRUCT wm_data; int i_opt; vlc_ipc_data_t *p_data; size_t i_data = sizeof (*p_data); - for( i_opt = optind; i_opt < *pi_argc; i_opt++ ) + for( i_opt = 0; i_opt < i_argc; i_opt++ ) { i_data += sizeof (size_t); i_data += strlen( ppsz_argv[ i_opt ] ) + 1; } p_data = malloc( i_data ); - p_data->argc = *pi_argc - optind; + p_data->argc = i_argc; p_data->enqueue = var_InheritBool( p_this, "playlist-enqueue" ); i_data = 0; - for( i_opt = optind; i_opt < *pi_argc; i_opt++ ) + for( i_opt = 0; i_opt < i_argc; i_opt++ ) { size_t i_len = strlen( ppsz_argv[ i_opt ] ) + 1; /* Windows will never switch to an architecture @@ -305,7 +307,11 @@ static unsigned __stdcall IPCHelperThread( void *data ) LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { - if( uMsg == WM_COPYDATA ) + if( uMsg == WM_QUIT ) + { + PostQuitMessage( 0 ); + } + else if( uMsg == WM_COPYDATA ) { COPYDATASTRUCT *pwm_data = (COPYDATASTRUCT*)lParam; vlc_object_t *p_this; @@ -317,8 +323,7 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam, if( !p_this ) return 0; /* Add files to the playlist */ - p_playlist = pl_Hold( p_this ); - if( !p_playlist ) return 0; + p_playlist = pl_Get( p_this ); if( pwm_data->lpData ) { @@ -340,26 +345,27 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam, /* Count the input options */ while( i_opt + i_options + 1 < i_argc && - *ppsz_argv[ i_opt + i_options + 1 ] == ':' ) + *ppsz_argv[ i_opt + i_options + 1 ] == ':' ) { i_options++; } - playlist_AddExt( p_playlist, ppsz_argv[i_opt], - NULL, PLAYLIST_APPEND | + + char *psz_URI = make_URI( ppsz_argv[i_opt], NULL ); + playlist_AddExt( p_playlist, psz_URI, + NULL, PLAYLIST_APPEND | ( ( i_opt || p_data->enqueue ) ? 0 : PLAYLIST_GO ), - PLAYLIST_END, -1, - i_options, - (char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ), - VLC_INPUT_OPTION_TRUSTED, - true, pl_Unlocked ); + PLAYLIST_END, -1, + i_options, + (char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ), + VLC_INPUT_OPTION_TRUSTED, + true, pl_Unlocked ); i_opt += i_options; + free( psz_URI ); } free( ppsz_argv ); } - - vlc_object_release( p_playlist ); } return DefWindowProc( hwnd, uMsg, wParam, lParam ); @@ -377,15 +383,17 @@ void system_End( libvlc_int_t *p_this ) psz_vlcpath = NULL; } - if( ( ipcwindow = FindWindow( 0, L"VLC ipc "VERSION ) ) != 0 ) - { - SendMessage( ipcwindow, WM_QUIT, 0, 0 ); - } - if (p_helper && p_helper->p_parent == VLC_OBJECT(p_this) ) { + /* this is the first instance (in a one-instance system) + * it is the owner of the helper thread + */ + if( ( ipcwindow = FindWindow( 0, L"VLC ipc "VERSION ) ) != 0 ) + { + SendMessage( ipcwindow, WM_QUIT, 0, 0 ); + } + /* FIXME: thread-safety... */ - vlc_object_detach (p_helper); vlc_object_release (p_helper); p_helper = NULL; }