]> git.sesse.net Git - vlc/blobdiff - src/libvlc-common.c
vlc_global_object: return the global (process-wide) LibVLC object
[vlc] / src / libvlc-common.c
index 9f78e0b2729afce243da00810309c6e28a5c0b22..b6efb7cc51ead4e046e9eef1e5c67b0852277817 100644 (file)
@@ -94,7 +94,7 @@
  * The evil global variable. We handle it with care, don't worry.
  *****************************************************************************/
 static libvlc_global_data_t   libvlc_global;
-static libvlc_global_data_t * p_libvlc_global = NULL;
+#define p_libvlc_global (&libvlc_global)
 static libvlc_int_t *    p_static_vlc = NULL;
 static volatile unsigned int i_instances = 0;
 
@@ -122,8 +122,10 @@ static int  VerboseCallback( vlc_object_t *, char const *,
 
 static void InitDeviceValues( libvlc_int_t * );
 
-/* Refs misc/cpu.c */
-uint32_t CPUCapabilities( void );
+vlc_object_t * vlc_global_object( void )
+{
+    return VLC_OBJECT( &libvlc_global );
+}
 
 /*****************************************************************************
  * vlc_current_object: return the current object.
@@ -153,9 +155,11 @@ libvlc_int_t * libvlc_InternalCreate( void )
     vlc_value_t lockval;
     char *psz_env = NULL;
 
+#if 0
     /* &libvlc_global never changes,
      * so we can safely call this multiple times. */
     p_libvlc_global = &libvlc_global;
+#endif
 
     /* vlc_threads_init *must* be the first internal call! No other call is
      * allowed before the thread system has been initialized. */
@@ -606,13 +610,13 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
         }
         else
         {
-            /* check if a Media Player is available
+            /* 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.freedesktop.MediaPlayer", "/",
+                    "org.mpris.vlc", "/",
                     "org.freedesktop.MediaPlayer", "Identity" );
             /* block until a reply arrives */
             p_test_reply = dbus_connection_send_with_reply_and_block(
@@ -641,7 +645,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
                             ppsz_argv[i_input] );
 
                     p_dbus_msg = dbus_message_new_method_call(
-                            "org.freedesktop.MediaPlayer", "/TrackList",
+                            "org.mpris.vlc", "/TrackList",
                             "org.freedesktop.MediaPlayer", "AddTrack" );
 
                     if ( NULL == p_dbus_msg )
@@ -1196,7 +1200,7 @@ static inline int LoadMessages (void)
 #else
     char psz_path[1024];
     if (snprintf (psz_path, sizeof (psz_path), "%s/%s",
-                  vlc_global( &libvlc_global )->psz_vlcpath, "locale")
+                  libvlc_global.psz_vlcpath, "locale")
                      >= (int)sizeof (psz_path))
         return -1;
 
@@ -1377,15 +1381,13 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
         if( psz_module_name && strcmp( psz_module_name,
                                        p_parser->psz_object_name ) )
         {
-            const char **pp_shortcut = p_parser->pp_shortcuts;
+            const char *const *pp_shortcut = p_parser->pp_shortcuts;
             while( *pp_shortcut )
             {
                 if( !strcmp( psz_module_name, *pp_shortcut ) )
                     break;
                 pp_shortcut ++;
             }
-            if( !*pp_shortcut )
-                continue;
         }
 
         /* Ignore modules without config options */
@@ -1771,7 +1773,7 @@ static void ListModules( libvlc_int_t *p_this, vlc_bool_t b_verbose )
         if( b_verbose )
         {
             const char **pp_shortcut = p_parser->pp_shortcuts;
-            while( pp_shortcut && *pp_shortcut )
+            while( *pp_shortcut )
             {
                 if( strcmp( *pp_shortcut, p_parser->psz_object_name ) )
                 {