X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Finterface%2Finterface.c;h=f729444aa25cf77899c1675777ee8e57fad742e3;hb=bf680e8fb64910e8d968addce71139d135a9b33f;hp=4972cec3ee62118878e19e96c708eb92ea3d34cc;hpb=41e10a98a09a8f08a2c0223feeace16086304612;p=vlc diff --git a/src/interface/interface.c b/src/interface/interface.c index 4972cec3ee..f729444aa2 100644 --- a/src/interface/interface.c +++ b/src/interface/interface.c @@ -37,17 +37,18 @@ #include /* strerror() */ #include - -#include "stream_control.h" -#include "input_ext-intf.h" +#include #include "audio_output.h" #include "vlc_interface.h" - #include "vlc_video.h" #include "video_output.h" +#ifdef SYS_DARWIN +# include "Cocoa/Cocoa.h" +#endif /* SYS_DARWIN */ + /***************************************************************************** * Local prototypes *****************************************************************************/ @@ -129,8 +130,10 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module ) */ int intf_RunThread( intf_thread_t *p_intf ) { +#ifdef SYS_DARWIN if( p_intf->b_block ) { + /* This is the primary intf */ /* Run a manager thread, launch the interface, kill the manager */ if( vlc_thread_create( p_intf, "manager", Manager, VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) ) @@ -138,15 +141,49 @@ int intf_RunThread( intf_thread_t *p_intf ) msg_Err( p_intf, "cannot spawn manager thread" ); return VLC_EGENERIC; } + } - RunInterface( p_intf ); + if( p_intf->b_block && !strncmp( p_intf->p_module->psz_shortname, "macosx" , 6 ) ) + { + /* this is OSX, we are cheating :) + This is NOT I REPEAT NOT blocking since [NSApp run] is */ + p_intf->b_block = VLC_FALSE; + RunInterface( p_intf ); + p_intf->b_block = VLC_TRUE; + } + else if( p_intf->b_block && !strncmp( p_intf->p_vlc->psz_object_name, "clivlc", 6 ) ) + { + /* VLC OS X in cli mode ( no blocking [NSApp run] ) + this is equal to running in normal non-OSX primary intf mode */ + RunInterface( p_intf ); p_intf->b_die = VLC_TRUE; + } + else + { + /* If anything else is the primary intf and we are not in cli mode, + then don't make it blocking ([NSApp run] will be blocking) + but run it in a seperate thread. */ + p_intf->b_block = VLC_FALSE; +#else + if( p_intf->b_block ) + { + /* Run a manager thread, launch the interface, kill the manager */ + if( vlc_thread_create( p_intf, "manager", Manager, + VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) ) + { + msg_Err( p_intf, "cannot spawn manager thread" ); + return VLC_EGENERIC; + } + RunInterface( p_intf ); + + p_intf->b_die = VLC_TRUE; /* Do not join the thread... intf_StopThread will do it for us */ } else { +#endif /* Run the interface in a separate thread */ if( vlc_thread_create( p_intf, "interface", RunInterface, VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) ) @@ -230,6 +267,12 @@ static void Manager( intf_thread_t *p_intf ) if( p_intf->p_vlc->b_die ) { p_intf->b_die = VLC_TRUE; +#ifdef SYS_DARWIN + if( strncmp( p_intf->p_vlc->psz_object_name, "clivlc", 6 ) ) + { + [NSApp stop: NULL]; + } +#endif return; } } @@ -240,6 +283,17 @@ static void Manager( intf_thread_t *p_intf ) *****************************************************************************/ static void RunInterface( intf_thread_t *p_intf ) { + static char *ppsz_interfaces[] = + { + "skins", "Skins", + "skins2", "Skins 2", + "wxwindows", "wxWindows", + NULL, NULL + }; + char **ppsz_parser; + + vlc_list_t *p_list; + int i; vlc_value_t val, text; char *psz_intf; @@ -250,12 +304,24 @@ static void RunInterface( intf_thread_t *p_intf ) text.psz_string = _("Switch interface"); var_Change( p_intf, "intf-switch", VLC_VAR_SETTEXT, &text, NULL ); - val.psz_string = "skins"; text.psz_string = "Skins"; - var_Change( p_intf, "intf-switch", VLC_VAR_ADDCHOICE, &val, &text ); - val.psz_string = "skins2"; text.psz_string = "Skins 2"; - var_Change( p_intf, "intf-switch", VLC_VAR_ADDCHOICE, &val, &text ); - val.psz_string = "wxwin"; text.psz_string = "wxWindows"; - var_Change( p_intf, "intf-switch", VLC_VAR_ADDCHOICE, &val, &text ); + /* Only fill the list with available modules */ + p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE ); + for( ppsz_parser = ppsz_interfaces; *ppsz_parser; ppsz_parser += 2 ) + { + for( i = 0; i < p_list->i_count; i++ ) + { + module_t *p_module = (module_t *)p_list->p_values[i].p_object; + if( !strcmp( p_module->psz_object_name, ppsz_parser[0] ) ) + { + val.psz_string = ppsz_parser[0]; + text.psz_string = ppsz_parser[1]; + var_Change( p_intf, "intf-switch", VLC_VAR_ADDCHOICE, + &val, &text ); + break; + } + } + } + vlc_list_release( p_list ); var_AddCallback( p_intf, "intf-switch", SwitchIntfCallback, NULL ); @@ -293,13 +359,17 @@ static void RunInterface( intf_thread_t *p_intf ) break; } + /* Make sure the old interface is completely uninitialized */ + module_Unneed( p_intf, p_intf->p_module ); + /* Provide ability to switch the main interface on the fly */ psz_intf = p_intf->psz_switch_intf; p_intf->psz_switch_intf = NULL; - p_intf->b_die = VLC_FALSE; - /* Make sure the old interface is completely uninitialized */ - module_Unneed( p_intf, p_intf->p_module ); + vlc_mutex_lock( &p_intf->object_lock ); + p_intf->b_die = VLC_FALSE; + p_intf->b_dead = VLC_FALSE; + vlc_mutex_unlock( &p_intf->object_lock ); p_intf->p_module = module_Need( p_intf, "interface", psz_intf, 0 ); free( psz_intf );