]> git.sesse.net Git - vlc/blobdiff - src/libvlc.c
real demux: use VLC_FOURCC
[vlc] / src / libvlc.c
index dc3f48f267b17d05285f0d4c004d7949034eab36..7c053fc21423c9943c03a2ffa9cbf285d499152a 100644 (file)
@@ -145,7 +145,7 @@ void *vlc_hold (gc_object_t * p_gc)
  */
 void vlc_release (gc_object_t *p_gc)
 {
-    unsigned refs;
+    uintptr_t refs;
 
     assert( p_gc );
     refs = vlc_atomic_dec (&p_gc->refs);
@@ -198,7 +198,7 @@ libvlc_int_t * libvlc_InternalCreate( void )
 
     /* Allocate a libvlc instance object */
     p_libvlc = vlc_custom_create( (vlc_object_t *)NULL, sizeof (*priv),
-                                  VLC_OBJECT_GENERIC, "libvlc" );
+                                  "libvlc" );
     if( p_libvlc != NULL )
         i_instances++;
     vlc_mutex_unlock( &global_lock );
@@ -249,7 +249,7 @@ error:
  *  - configuration and commandline parsing
  */
 int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
-                         const char *ppsz_argv[], const void **builtins_module )
+                         const char *ppsz_argv[] )
 {
     libvlc_priv_t *priv = libvlc_priv (p_libvlc);
     char *       p_tmp = NULL;
@@ -268,7 +268,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 #endif
 
     /* System specific initialization code */
-    system_Init( p_libvlc, &i_argc, ppsz_argv );
+    system_Init();
 
     /*
      * Support for gettext
@@ -410,7 +410,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
      * list of configuration options exported by each module and loads their
      * default values.
      */
-    module_LoadPlugins( p_libvlc, builtins_module );
+    module_LoadPlugins( p_libvlc );
     if( p_libvlc->b_die )
     {
         b_exit = true;
@@ -461,16 +461,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         i_ret = VLC_EEXITSUCCESS;
     }
 
-    /* Check for config file options */
-    if( !var_InheritBool( p_libvlc, "ignore-config" ) )
-    {
-        if( var_InheritBool( p_libvlc, "reset-config" ) )
-        {
-            config_ResetAll( p_libvlc );
-            config_SaveConfigFile( p_libvlc, NULL );
-        }
-    }
-
     if( module_count <= 1 )
     {
         msg_Err( p_libvlc, "No plugins found! Check your VLC installation.");
@@ -488,7 +478,15 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
      * Override default configuration with config file settings
      */
     if( !var_InheritBool( p_libvlc, "ignore-config" ) )
-        config_LoadConfigFile( p_libvlc );
+    {
+        if( var_InheritBool( p_libvlc, "reset-config" ) )
+        {
+            config_ResetAll( p_libvlc );
+            config_SaveConfigFile( p_libvlc );
+        }
+        else
+            config_LoadConfigFile( p_libvlc );
+    }
 
     /*
      * Override configuration with command line settings
@@ -535,11 +533,13 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
             /* 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_msg   = NULL;
             DBusMessage *p_test_reply = NULL;
+
             p_test_msg =  dbus_message_new_method_call(
-                    "org.mpris.vlc", "/",
-                    "org.freedesktop.MediaPlayer", "Identity" );
+                    "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 );
@@ -573,14 +573,16 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 
                     /* We need to resolve relative paths in this instance */
                     char *psz_mrl = make_URI( ppsz_argv[i_input], NULL );
+                    const char *psz_after_track = "/";
+
                     if( psz_mrl == NULL )
                         continue;
                     msg_Dbg( p_libvlc, "Adds %s to the running Media Player",
                              psz_mrl );
 
                     p_dbus_msg = dbus_message_new_method_call(
-                            "org.mpris.vlc", "/TrackList",
-                            "org.freedesktop.MediaPlayer", "AddTrack" );
+                        "org.mpris.MediaPlayer2.vlc", "/org/mpris/MediaPlayer2",
+                        "org.mpris.MediaPlayer2.TrackList", "AddTrack" );
 
                     if ( NULL == p_dbus_msg )
                     {
@@ -601,9 +603,19 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
                         exit( 1 );
                     }
                     free( psz_mrl );
+
+                    if( !dbus_message_iter_append_basic( &dbus_args,
+                                DBUS_TYPE_OBJECT_PATH, &psz_after_track ) )
+                    {
+                        dbus_message_unref( p_dbus_msg );
+                        system_End( p_libvlc );
+                        exit( 1 );
+                    }
+
                     b_play = TRUE;
                     if( var_InheritBool( p_libvlc, "playlist-enqueue" ) )
                         b_play = FALSE;
+
                     if ( !dbus_message_iter_append_basic( &dbus_args,
                                 DBUS_TYPE_BOOLEAN, &b_play ) )
                     {
@@ -758,8 +770,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     priv->i_timers = 0;
     priv->pp_timers = NULL;
 
-    priv->i_last_input_id = 0; /* Not very safe, should be removed */
-
     /*
      * Initialize hotkey handling
      */
@@ -1032,6 +1042,10 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
         priv->p_memcpy_module = NULL;
     }
 
+    /* Save the configuration */
+    if( !var_InheritBool( p_libvlc, "ignore-config" ) )
+        config_AutoSaveConfigFile( VLC_OBJECT(p_libvlc) );
+
     /* Free module bank. It is refcounted, so we call this each time  */
     module_EndBank( p_libvlc, true );
 
@@ -1409,7 +1423,7 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
                  p_item < p_end;
                  p_item++ )
             {
-                if( (p_item->i_type & CONFIG_ITEM) &&
+                if( CONFIG_ITEM(p_item->i_type) &&
                     !p_item->b_advanced && !p_item->b_removed ) break;
             }
 
@@ -1466,48 +1480,43 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
                 continue;
             }
 
-            switch( p_item->i_type )
+            switch( CONFIG_CLASS(p_item->i_type) )
             {
-            case CONFIG_HINT_CATEGORY:
-            case CONFIG_HINT_USAGE:
-                if( !strcmp( "main", p_parser->psz_object_name ) )
+            case 0: // hint class
+                switch( p_item->i_type )
                 {
-                    if( b_color )
-                        utf8_fprintf( stdout, GREEN "\n %s\n" GRAY,
-                                      module_gettext( p_parser, p_item->psz_text ) );
-                    else
-                        utf8_fprintf( stdout, "\n %s\n",
-                                      module_gettext( p_parser, p_item->psz_text ) );
-                }
-                if( b_description && p_item->psz_longtext )
-                {
-                    if( b_color )
-                        utf8_fprintf( stdout, CYAN " %s\n" GRAY,
-                                      module_gettext( p_parser, p_item->psz_longtext ) );
-                    else
-                        utf8_fprintf( stdout, " %s\n",
-                                      module_gettext( p_parser, p_item->psz_longtext ) );
+                case CONFIG_HINT_CATEGORY:
+                case CONFIG_HINT_USAGE:
+                    if( !strcmp( "main", p_parser->psz_object_name ) )
+                    {
+                        if( b_color )
+                            utf8_fprintf( stdout, GREEN "\n %s\n" GRAY,
+                                          module_gettext( p_parser, p_item->psz_text ) );
+                        else
+                            utf8_fprintf( stdout, "\n %s\n",
+                                          module_gettext( p_parser, p_item->psz_text ) );
+                    }
+                    if( b_description && p_item->psz_longtext )
+                    {
+                        if( b_color )
+                            utf8_fprintf( stdout, CYAN " %s\n" GRAY,
+                                          module_gettext( p_parser, p_item->psz_longtext ) );
+                        else
+                            utf8_fprintf( stdout, " %s\n",
+                                          module_gettext( p_parser, p_item->psz_longtext ) );
                 }
                 break;
 
-            case CONFIG_HINT_SUBCATEGORY:
-                if( strcmp( "main", p_parser->psz_object_name ) )
+                case CONFIG_HINT_SUBCATEGORY:
+                    if( strcmp( "main", p_parser->psz_object_name ) )
+                        break;
+                case CONFIG_SECTION:
+                    p_section = p_item;
                     break;
-            case CONFIG_SECTION:
-                p_section = p_item;
+                }
                 break;
 
             case CONFIG_ITEM_STRING:
-            case CONFIG_ITEM_LOADFILE:
-            case CONFIG_ITEM_SAVEFILE:
-            case CONFIG_ITEM_DIRECTORY:
-            case CONFIG_ITEM_KEY:
-            case CONFIG_ITEM_MODULE: /* We could also have "=<" here */
-            case CONFIG_ITEM_MODULE_CAT:
-            case CONFIG_ITEM_MODULE_LIST:
-            case CONFIG_ITEM_MODULE_LIST_CAT:
-            case CONFIG_ITEM_FONT:
-            case CONFIG_ITEM_PASSWORD:
                 print_help_section( p_parser, p_section, b_color,
                                     b_description );
                 p_section = NULL;
@@ -1604,7 +1613,8 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
                  - strlen( psz_bra ) - strlen( psz_type )
                  - strlen( psz_ket ) - 1;
 
-            if( p_item->i_type == CONFIG_ITEM_BOOL && !b_help_module )
+            if( CONFIG_CLASS(p_item->i_type) == CONFIG_ITEM_BOOL
+             && !b_help_module )
             {
                 psz_prefix =  ", --no-";
                 i -= strlen( p_item->psz_name ) + strlen( psz_prefix );
@@ -1620,7 +1630,8 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
                 psz_spaces[i] = '\0';
             }
 
-            if( p_item->i_type == CONFIG_ITEM_BOOL && !b_help_module )
+            if( CONFIG_CLASS(p_item->i_type) == CONFIG_ITEM_BOOL
+             && !b_help_module )
             {
                 utf8_fprintf( stdout, psz_format_bool, psz_short,
                               p_item->psz_name, psz_prefix, p_item->psz_name,