]> git.sesse.net Git - vlc/blobdiff - src/libvlc.c
dejidjei:
[vlc] / src / libvlc.c
index 73a21e87200c7ef4a4b69be7958d1bd6083017c5..496c013c266aa6f0c491039de0371a72bac29413 100644 (file)
@@ -94,6 +94,7 @@
 #include "playlist/playlist_internal.h"
 
 #include <vlc_vlm.h>
+#include <vlc_input.h>
 
 #include <assert.h>
 
@@ -105,6 +106,47 @@ static unsigned          i_instances = 0;
 
 static bool b_daemon = false;
 
+/*****************************************************************************
+ * vlc_gc_*.
+ *****************************************************************************/
+void __vlc_gc_incref( gc_object_t * p_gc )
+{
+    assert( p_gc->i_gc_refcount > 0 );
+
+    char * name = input_item_GetName((input_item_t *)p_gc);
+    printf("--- %s++ (%d)\n", name, p_gc->i_gc_refcount+1);
+    free(name);
+    /* FIXME: atomic version needed! */
+    p_gc->i_gc_refcount ++;
+}
+
+void __vlc_gc_decref( gc_object_t *p_gc )
+{
+    assert( p_gc );
+    assert( p_gc->i_gc_refcount > 0 );
+    char * name = input_item_GetName((input_item_t *)p_gc);
+    printf("--- %s-- (%d)\n", name, p_gc->i_gc_refcount-1);
+    free(name);
+
+    /* FIXME: atomic version needed! */
+    p_gc->i_gc_refcount -- ;
+
+    if( p_gc->i_gc_refcount == 0 )
+    {
+        p_gc->pf_destructor( p_gc );
+        /* Do not use the p_gc pointer from now on ! */
+    }
+}
+
+void
+__vlc_gc_init( gc_object_t * p_gc, void (*pf_destructor)( gc_object_t * ),
+               void * arg)
+{
+    p_gc->i_gc_refcount = 1;
+    p_gc->pf_destructor = pf_destructor;
+    p_gc->p_destructor_arg = arg;
+}
+
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
@@ -1018,7 +1060,7 @@ int libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
     FOREACH_ARRAY( input_item_t *p_del, priv->input_items )
         msg_Err( p_libvlc, "input item %p has not been deleted properly: refcount %d, name %s",
             p_del, p_del->i_gc_refcount, p_del->psz_name ? p_del->psz_name : "(null)" );
-        b_clean = false;
+        //b_clean = false;
     FOREACH_END();
     assert( b_clean );
     ARRAY_RESET( priv->input_items );
@@ -1275,7 +1317,7 @@ static int GetFilenames( libvlc_int_t *p_vlc, int i_argc, const char *ppsz_argv[
 static inline void print_help_on_full_help( void )
 {
     utf8_fprintf( stdout, "\n" );
-    utf8_fprintf( stdout, "To get a exhaustive help, use '-H'.\n" );
+    utf8_fprintf( stdout, "%s\n", _("To get exhaustive help, use '-H'.") );
 }
 
 static void Help( libvlc_int_t *p_this, char const *psz_help_name )