]> git.sesse.net Git - vlc/blobdiff - src/libvlc-common.c
Add long overdue private libvlc object pointer...
[vlc] / src / libvlc-common.c
index 46c8d44f7d68c6b46bf7e8e2b88627885f17bc58..2e648d4ace09c64a0408a4d3ca6d4c1c6d350de3 100644 (file)
@@ -146,7 +146,8 @@ libvlc_int_t * vlc_current_object( int i_object )
  */
 libvlc_int_t * libvlc_InternalCreate( void )
 {
-    libvlc_int_t * p_libvlc = NULL;
+    libvlc_int_t *p_libvlc;
+    libvlc_priv_t *priv;
     char *psz_env = NULL;
 
     /* vlc_threads_init *must* be the first internal call! No other call is
@@ -158,31 +159,30 @@ libvlc_int_t * libvlc_InternalCreate( void )
     /* Now that the thread system is initialized, we don't have much, but
      * at least we have variables */
     vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
-
-    i_instances++;
-
-    if( !p_libvlc_global->b_ready )
+    if( i_instances == 0 )
     {
         /* Guess what CPU we have */
         cpu_flags = CPUCapabilities();
        /* The module bank will be initialized later */
         p_libvlc_global->p_module_bank = NULL;
-
-        p_libvlc_global->b_ready = true;
     }
-    vlc_mutex_unlock( lock );
 
     /* Allocate a libvlc instance object */
-    p_libvlc = vlc_object_create( p_libvlc_global, VLC_OBJECT_LIBVLC );
+    p_libvlc = vlc_custom_create( VLC_OBJECT(p_libvlc_global),
+                                  sizeof (*p_libvlc) + sizeof (libvlc_priv_t),
+                                  VLC_OBJECT_LIBVLC, "libvlc" );
+    if( p_libvlc != NULL )
+        i_instances++;
+    vlc_mutex_unlock( lock );
+
     if( p_libvlc == NULL )
-    {
-        i_instances--;
         return NULL;
-    }
+
     p_libvlc->p_playlist = NULL;
     p_libvlc->p_interaction = NULL;
     p_libvlc->p_vlm = NULL;
     p_libvlc->psz_object_name = strdup( "libvlc" );
+    priv = libvlc_priv (p_libvlc);
 
     /* Initialize message queue */
     msg_Create( p_libvlc );
@@ -204,8 +204,8 @@ libvlc_int_t * libvlc_InternalCreate( void )
     msg_Dbg( p_libvlc, "libvlc was configured with %s", CONFIGURE_LINE );
 
     /* Initialize mutexes */
-    vlc_mutex_init( &p_libvlc->timer_lock );
-    vlc_mutex_init( &p_libvlc->config_lock );
+    vlc_mutex_init( &priv->timer_lock );
+    vlc_mutex_init( &priv->config_lock );
 #ifdef __APPLE__
     vlc_thread_set_priority( p_libvlc, VLC_THREAD_PRIORITY_LOW );
 #endif
@@ -227,6 +227,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
                          const char *ppsz_argv[] )
 {
     libvlc_global_data_t *p_libvlc_global = vlc_global();
+    libvlc_priv_t *priv = libvlc_priv (p_libvlc);
     char         p_capabilities[200];
     char *       p_tmp = NULL;
     char *       psz_modules = NULL;
@@ -709,9 +710,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
      */
     p_libvlc->p_memcpy_module = module_Need( p_libvlc, "memcpy", "$memcpy", 0 );
 
-    p_libvlc->b_stats = config_GetInt( p_libvlc, "stats" ) > 0;
-    p_libvlc->i_timers = 0;
-    p_libvlc->pp_timers = NULL;
+    priv->b_stats = config_GetInt( p_libvlc, "stats" ) > 0;
+    priv->i_timers = 0;
+    priv->pp_timers = NULL;
 
     /* Init stats */
     p_libvlc->p_stats = (global_stats_t *)malloc( sizeof( global_stats_t ) );
@@ -1034,6 +1035,8 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release )
     if( !p_libvlc )
         return VLC_EGENERIC;
 
+    libvlc_priv_t *priv = libvlc_priv (p_libvlc);
+
 #ifndef WIN32
     char* psz_pidfile = NULL;
 
@@ -1085,8 +1088,8 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release )
     msg_Destroy( p_libvlc );
 
     /* Destroy mutexes */
-    vlc_mutex_destroy( &p_libvlc->config_lock );
-    vlc_mutex_destroy( &p_libvlc->timer_lock );
+    vlc_mutex_destroy( &priv->config_lock );
+    vlc_mutex_destroy( &priv->timer_lock );
 
     if( b_release ) vlc_object_release( p_libvlc );
     vlc_object_release( p_libvlc );