#include "config/vlc_getopt.h"
-#ifdef HAVE_LOCALE_H
-# include <locale.h>
-#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h> /* isatty() */
#endif
#include <vlc_playlist.h>
#include <vlc_interface.h>
-#include <vlc_aout.h>
-#include "audio_output/aout_internal.h"
-
#include <vlc_charset.h>
#include <vlc_fs.h>
#include <vlc_cpu.h>
#include <vlc_url.h>
-#include <vlc_atomic.h>
#include <vlc_modules.h>
#include "libvlc.h"
static bool b_daemon = false;
#endif
-#undef vlc_gc_init
-#undef vlc_hold
-#undef vlc_release
-
-/**
- * Atomically set the reference count to 1.
- * @param p_gc reference counted object
- * @param pf_destruct destruction calback
- * @return p_gc.
- */
-void *vlc_gc_init (gc_object_t *p_gc, void (*pf_destruct) (gc_object_t *))
-{
- /* There is no point in using the GC if there is no destructor... */
- assert (pf_destruct);
- p_gc->pf_destructor = pf_destruct;
-
- vlc_atomic_set (&p_gc->refs, 1);
- return p_gc;
-}
-
-/**
- * Atomically increment the reference count.
- * @param p_gc reference counted object
- * @return p_gc.
- */
-void *vlc_hold (gc_object_t * p_gc)
-{
- uintptr_t refs;
-
- assert( p_gc );
- refs = vlc_atomic_inc (&p_gc->refs);
- assert (refs != 1); /* there had to be a reference already */
- return p_gc;
-}
-
-/**
- * Atomically decrement the reference count and, if it reaches zero, destroy.
- * @param p_gc reference counted object.
- */
-void vlc_release (gc_object_t *p_gc)
-{
- uintptr_t refs;
-
- assert( p_gc );
- refs = vlc_atomic_dec (&p_gc->refs);
- assert (refs != (uintptr_t)(-1)); /* reference underflow?! */
- if (refs == 0)
- p_gc->pf_destructor (p_gc);
-}
-
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-#if defined( ENABLE_NLS ) && (defined (__APPLE__) || defined (WIN32)) && \
- ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) )
-static void SetLanguage ( char const * );
-#endif
static void GetFilenames ( libvlc_int_t *, unsigned, const char *const [] );
/**
{
libvlc_int_t *p_libvlc;
libvlc_priv_t *priv;
- char *psz_env = NULL;
/* Now that the thread system is initialized, we don't have much, but
* at least we have variables */
priv->p_ml = NULL;
priv->p_dialog_provider = NULL;
priv->p_vlm = NULL;
-
- /* Find verbosity from VLC_VERBOSE environment variable */
- psz_env = getenv( "VLC_VERBOSE" );
- if( psz_env != NULL )
- priv->i_verbose = atoi( psz_env );
- else
- priv->i_verbose = 3;
+ priv->i_verbose = 3; /* initial value until config is loaded */
#if defined( HAVE_ISATTY ) && !defined( WIN32 )
- priv->b_color = isatty( 2 ); /* 2 is for stderr */
+ priv->b_color = isatty( STDERR_FILENO ); /* 2 is for stderr */
#else
priv->b_color = false;
#endif
}
priv->i_verbose = var_InheritInteger( p_libvlc, "verbose" );
+ /* Find verbosity from VLC_VERBOSE environment variable */
+ {
+ char *env = getenv( "VLC_VERBOSE" );
+ if( env != NULL )
+ priv->i_verbose = atoi( env );
+ }
+
/* Announce who we are (TODO: only first instance?) */
msg_Dbg( p_libvlc, "VLC media player - %s", VERSION_MESSAGE );
msg_Dbg( p_libvlc, "%s", COPYRIGHT_MESSAGE );
*/
#if defined( ENABLE_NLS ) \
&& ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) )
-# if defined (WIN32) || defined (__APPLE__)
- /* Check if the user specified a custom language */
- char *lang = var_InheritString (p_libvlc, "language");
- if (lang != NULL && strcmp (lang, "auto"))
- SetLanguage (lang);
- free (lang);
-# endif
vlc_bindtextdomain (PACKAGE_NAME);
#endif
/*xgettext: Translate "C" to the language code: "fr", "en_GB", "nl", "ru"... */
/* FIXME: could be replaced by using Unix sockets */
#ifdef HAVE_DBUS
+
+#define MPRIS_APPEND "/org/mpris/MediaPlayer2/TrackList/Append"
+#define MPRIS_BUS_NAME "org.mpris.MediaPlayer2.vlc"
+#define MPRIS_OBJECT_PATH "/org/mpris/MediaPlayer2"
+#define MPRIS_TRACKLIST_INTERFACE "org.mpris.MediaPlayer2.TrackList"
+
dbus_threads_init_default();
if( var_InheritBool( p_libvlc, "one-instance" )
/* check if VLC is available on the bus
* if not: D-Bus control is not enabled on the other
* instance and we can't pass MRLs to it */
- DBusMessage *p_test_msg = NULL;
- DBusMessage *p_test_reply = NULL;
-
- p_test_msg = dbus_message_new_method_call(
- "org.mpris.MediaPlayer2.vlc", "/org/mpris/MediaPlayer2",
- "org.freedesktop.DBus.Introspectable", "Introspect" );
-
- /* block until a reply arrives */
- p_test_reply = dbus_connection_send_with_reply_and_block(
- p_conn, p_test_msg, -1, &dbus_error );
- dbus_message_unref( p_test_msg );
- if( p_test_reply == NULL )
+ if( !dbus_bus_name_has_owner( p_conn, MPRIS_BUS_NAME, &dbus_error ) )
{
- dbus_error_free( &dbus_error );
- msg_Dbg( p_libvlc, "No Media Player is running. "
- "Continuing normally." );
+ if( dbus_error_is_set( &dbus_error ) )
+ {
+ msg_Err( p_libvlc, "D-Bus error: %s", dbus_error.message );
+ dbus_error_free( &dbus_error );
+ }
+ else
+ msg_Dbg( p_libvlc, "No Media Player is running. "
+ "Continuing normally." );
}
else
{
DBusPendingCall* p_dbus_pending = NULL;
dbus_bool_t b_play;
- dbus_message_unref( p_test_reply );
msg_Warn( p_libvlc, "Another Media Player is running. Exiting");
for( i_input = vlc_optind; i_input < i_argc;i_input++ )
}
/* We need to resolve relative paths in this instance */
- char *psz_mrl = make_URI( ppsz_argv[i_input], NULL );
- const char *psz_after_track = "/";
+ char *psz_mrl;
+ if( strstr( psz_mrl, "://" ) )
+ psz_mrl = strdup( ppsz_argv[i_input] );
+ else
+ psz_mrl = vlc_path2uri( ppsz_argv[i_input], NULL );
+ const char *psz_after_track = MPRIS_APPEND;
if( psz_mrl == NULL )
continue;
psz_mrl );
p_dbus_msg = dbus_message_new_method_call(
- "org.mpris.MediaPlayer2.vlc", "/org/mpris/MediaPlayer2",
- "org.mpris.MediaPlayer2.TrackList", "AddTrack" );
+ MPRIS_BUS_NAME, MPRIS_OBJECT_PATH,
+ MPRIS_TRACKLIST_INTERFACE, "AddTrack" );
if ( NULL == p_dbus_msg )
{
/* we unreference the connection when we've finished with it */
if( p_conn ) dbus_connection_unref( p_conn );
}
-#endif
+
+#undef MPRIS_APPEND
+#undef MPRIS_BUS_NAME
+#undef MPRIS_OBJECT_PATH
+#undef MPRIS_TRACKLIST_INTERFACE
+
+#endif // HAVE_DBUS
/*
* Message queue options
*/
intf_Create( 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( var_InheritBool( p_libvlc, "one-instance" )
- || ( var_InheritBool( p_libvlc, "one-instance-when-started-from-file" )
- && var_InheritBool( p_libvlc, "started-from-file" ) ) )
- intf_Create( p_libvlc, "dbus,none" );
-
-# if !defined (HAVE_MAEMO)
- /* Prevents the power management daemon from suspending the system
- * when VLC is active */
- if( var_InheritBool( p_libvlc, "inhibit" ) > 0 )
- intf_Create( p_libvlc, "inhibit,none" );
-# endif
+ if( var_InheritBool( p_libvlc, "file-logging" )
+#ifdef HAVE_SYSLOG_H
+ && !var_InheritBool( p_libvlc, "syslog" )
#endif
-
- if( var_InheritBool( p_libvlc, "file-logging" ) &&
- !var_InheritBool( p_libvlc, "syslog" ) )
+ )
{
intf_Create( p_libvlc, "logger,none" );
}
return ret;
}
-#if defined( ENABLE_NLS ) && (defined (__APPLE__) || defined (WIN32)) && \
- ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) )
-/*****************************************************************************
- * SetLanguage: set the interface language.
- *****************************************************************************
- * We set the LC_MESSAGES locale category for interface messages and buttons,
- * as well as the LC_CTYPE category for string sorting and possible wide
- * character support.
- *****************************************************************************/
-static void SetLanguage ( const char *psz_lang )
-{
-#ifdef __APPLE__
- /* I need that under Darwin, please check it doesn't disturb
- * other platforms. --Meuuh */
- setenv( "LANG", psz_lang, 1 );
-
-#else
- /* We set LC_ALL manually because it is the only way to set
- * the language at runtime under eg. Windows. Beware that this
- * makes the environment unconsistent when libvlc is unloaded and
- * should probably be moved to a safer place like vlc.c. */
- setenv( "LC_ALL", psz_lang, 1 );
-
-#endif
-
- setlocale( LC_ALL, psz_lang );
-}
-#endif
-
/*****************************************************************************
* GetFilenames: parse command line options which are not flags
*****************************************************************************
}
}
- char *mrl = make_URI( args[n], NULL );
- if( !mrl )
- continue;
+ char *mrl = NULL;
+ if( strstr( args[n], "://" ) == NULL )
+ {
+ mrl = vlc_path2uri( args[n], NULL );
+ if( !mrl )
+ continue;
+ }
- playlist_AddExt( pl_Get( p_vlc ), mrl, NULL, PLAYLIST_INSERT,
- 0, -1, i_options, ( i_options ? &args[n + 1] : NULL ),
- VLC_INPUT_OPTION_TRUSTED, true, pl_Unlocked );
+ playlist_AddExt( pl_Get( p_vlc ), (mrl != NULL) ? mrl : args[n], NULL,
+ PLAYLIST_INSERT, 0, -1, i_options,
+ ( i_options ? &args[n + 1] : NULL ),
+ VLC_INPUT_OPTION_TRUSTED, true, pl_Unlocked );
free( mrl );
}
}