]> git.sesse.net Git - vlc/blobdiff - src/libvlc.c
libvlc: Add a --verbose-objects option to select which objects should print their...
[vlc] / src / libvlc.c
index 023aa6edbb7b07d32c24099bd850f3266eb89eab..70236ec3b3136928623686b10bd16b03033a7754 100644 (file)
@@ -633,6 +633,28 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     /*
      * Message queue options
      */
+    char * psz_verbose_objects = config_GetPsz( p_libvlc, "verbose-objects" );
+    if( psz_verbose_objects )
+    {
+        char * psz_object, * iter = psz_verbose_objects;
+        while( (psz_object = strsep( &iter, "," )) )
+        {
+            switch( psz_object[0] )
+            {
+                printf("%s\n", psz_object+1);
+                case '+': msg_EnableObjectPrinting(p_libvlc, psz_object+1); break;
+                case '-': msg_DisableObjectPrinting(p_libvlc, psz_object+1); break;
+                default:
+                    msg_Err( p_libvlc, "verbose-objects usage: \n"
+                            "--verbose-objects=+printthatobject,"
+                            "-dontprintthatone\n"
+                            "(keyword 'all' to applies to all objects)\n");
+                    free( psz_verbose_objects );
+                    return VLC_EGENERIC;
+            }
+        }
+        free( psz_verbose_objects );
+    }
 
     var_Create( p_libvlc, "verbose", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
     if( config_GetInt( p_libvlc, "quiet" ) > 0 )
@@ -899,8 +921,10 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     var_Create( p_libvlc, "volume-change", VLC_VAR_BOOL );
 
     /* Create a variable for showing the interface (moved from playlist). */
-    var_Create( p_playlist, "intf-show", VLC_VAR_BOOL );
-    var_SetBool( p_playlist, "intf-show", true );
+    var_Create( p_libvlc, "intf-show", VLC_VAR_BOOL );
+    var_SetBool( p_libvlc, "intf-show", true );
+
+    var_Create( p_libvlc, "intf-popupmenu", VLC_VAR_BOOL );
 
     /*
      * Get input filenames given as commandline arguments
@@ -931,7 +955,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 int libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
 {
     intf_thread_t      * p_intf = NULL;
-    vout_thread_t      * p_vout = NULL;
     libvlc_priv_t      *priv = libvlc_priv (p_libvlc);
 
     /* Ask the interfaces to stop and destroy them */
@@ -952,25 +975,30 @@ int libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
     }
 #endif
 
+    playlist_t *p_playlist = priv->p_playlist;
     /* Remove all services discovery */
     msg_Dbg( p_libvlc, "removing all services discovery tasks" );
-    playlist_ServicesDiscoveryKillAll( priv->p_playlist );
+    playlist_ServicesDiscoveryKillAll( p_playlist );
 
     /* Free playlist */
+    /* Any thread still running must not assume pl_Yield() succeeds. */
     msg_Dbg( p_libvlc, "removing playlist" );
-    vlc_object_release( priv->p_playlist );
+    priv->p_playlist = NULL;
+    vlc_object_kill( p_playlist ); /* <-- memory barrier for pl_Yield() */
+    vlc_thread_join( p_playlist );
+    vlc_object_release( p_playlist );
 
     /* Free interaction */
     msg_Dbg( p_libvlc, "removing interaction" );
-    vlc_object_release( priv->p_interaction );
+    interaction_Destroy( priv->p_interaction );
 
     /* Free video outputs */
     msg_Dbg( p_libvlc, "removing all video outputs" );
-    while( (p_vout = vlc_object_find( p_libvlc, VLC_OBJECT_VOUT, FIND_CHILD )) )
+    vlc_list_t *list = vlc_list_find (p_libvlc, VLC_OBJECT_VOUT, FIND_CHILD);
+    for (unsigned i = 0; i < list->i_count; i++)
     {
-        vlc_object_detach( p_vout );
-        vlc_object_release( p_vout );
-        vlc_object_release( p_vout );
+        vlc_object_release (list->p_values[i].p_object);
+        vlc_object_release (list->p_values[i].p_object);
     }
 
     stats_TimersDumpAll( p_libvlc );
@@ -1023,9 +1051,8 @@ int libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
  * termination, and destroys their structure.
  * It stops the thread systems: no instance can run after this has run
  * \param p_libvlc the instance to destroy
- * \param b_release whether we should do a release on the instance
  */
-int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release )
+int libvlc_InternalDestroy( libvlc_int_t *p_libvlc )
 {
     if( !p_libvlc )
         return VLC_EGENERIC;
@@ -1084,7 +1111,6 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release )
     vlc_cond_destroy (&priv->threads_wait);
     vlc_mutex_destroy (&priv->threads_lock);
 
-    if( b_release ) vlc_object_release( p_libvlc );
     vlc_object_release( p_libvlc );
     p_libvlc = NULL;