Commit f0b9adc7 authored by Gildas Bazin's avatar Gildas Bazin

* src/libvlc.c:

   + start daemon mode before modules are loaded.
   + dummy interface is the default interface when in daemon mode.
parent 0f0a3ee3
......@@ -339,6 +339,39 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
vlc_object_detach( p_help_module );
/* End hack */
/* Will be re-done properly later on */
p_vlc->p_libvlc->i_verbose = config_GetInt( p_vlc, "verbose" );
/* Check for daemon mode */
#ifndef WIN32
if( config_GetInt( p_vlc, "daemon" ) )
{
pid_t i_pid = 0;
if( ( i_pid = fork() ) < 0 )
{
msg_Err( p_vlc, "Unable to fork vlc to daemon mode" );
b_exit = VLC_TRUE;
}
else if( i_pid )
{
/* This is the parent, exit right now */
msg_Dbg( p_vlc, "closing parent process" );
b_exit = VLC_TRUE;
}
else
{
/* We are the child */
msg_Dbg( p_vlc, "daemon spawned" );
close( 0 );
close( 1 );
close( 2 );
p_vlc->p_libvlc->b_daemon = VLC_TRUE;
}
}
#endif
if( b_exit )
{
config_Free( p_help_module );
......@@ -570,36 +603,6 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
{
p_vlc->pf_memset = memset;
}
/* Check for daemon mode */
if( config_GetInt( p_vlc, "daemon" ) )
{
pid_t i_pid = 0;
if( ( i_pid = fork() ) < 0 )
{
msg_Err( p_vlc, "Unable to fork vlc to daemon mode" );
exit(1);
}
else if( i_pid )
{
/* This is the parent, exit right now */
msg_Dbg( p_vlc, "closing parent process" );
exit(0);
}
else
{
/* we are the child */
msg_Dbg( p_vlc, "we are the child !!!" );
close( 0 );
close( 1 );
close( 2 );
p_vlc->p_libvlc->b_daemon = VLC_TRUE;
var_Create( p_vlc, "interface", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_SetString( p_vlc, "interface", "dummy" );
VLC_AddIntf( 0, "logger,none", VLC_FALSE, VLC_FALSE );
}
}
/*
* Initialize hotkey handling
......@@ -704,6 +707,17 @@ int VLC_AddIntf( int i_object, char const *psz_module,
return VLC_ENOOBJ;
}
#ifndef WIN32
if( p_vlc->p_libvlc->b_daemon && b_block && !psz_module )
{
/* Daemon mode hack.
* We prefer the dummy interface if none is specified. */
char *psz_interface = config_GetPsz( p_vlc, "intf" );
if( !psz_interface || !*psz_interface ) psz_module = "dummy";
if( psz_interface ) free( psz_interface );
}
#endif
/* Try to create the interface */
p_intf = intf_Create( p_vlc, psz_module ? psz_module : "$intf" );
......
......@@ -593,9 +593,9 @@ static char *ppsz_align_descriptions[] =
"This option allows you to use a plugins cache which will greatly " \
"improve the start time of VLC.")
#define DAEMON_TEXT N_("Run as daemon proces")
#define DAEMON_TEXT N_("Run as daemon process")
#define DAEMON_LONGTEXT N_( \
"Runs VLC as a background daemon proces.")
"Runs VLC as a background daemon process.")
#define ONEINSTANCE_TEXT N_("Allow only one running instance")
#define ONEINSTANCE_LONGTEXT N_( \
......@@ -976,8 +976,7 @@ vlc_module_begin();
PLUGIN_PATH_LONGTEXT, VLC_TRUE );
#if !defined(WIN32)
add_bool( "daemon", 0, NULL, DAEMON_TEXT,
DAEMON_LONGTEXT, VLC_TRUE );
add_bool( "daemon", 0, NULL, DAEMON_TEXT, DAEMON_LONGTEXT, VLC_TRUE );
change_short('d');
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment