]> git.sesse.net Git - vlc/blobdiff - src/libvlc.c
Fix stats collecting
[vlc] / src / libvlc.c
index bef0db4eabba3193b8be8fd6e19266920247b3ad..077648b3a02ab482a227f9ce8ba95ae9d67ebb81 100644 (file)
@@ -286,7 +286,9 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
     vlc_value_t  val;
 #if defined( ENABLE_NLS ) \
      && ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) )
+# if defined (WIN32) || defined (__APPLE__)
     char *       psz_language;
+#endif
 #endif
 
     if( !p_vlc )
@@ -417,6 +419,33 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
 
         p_vlc->p_libvlc->b_daemon = VLC_TRUE;
 
+        /* lets check if we need to write the pidfile */
+        char * psz_pidfile = config_GetPsz( p_vlc, "pidfile" );
+        
+        msg_Dbg( p_vlc, "psz_pidfile is %s", psz_pidfile );
+        
+        if( psz_pidfile != NULL )
+        {
+            FILE *pidfile;
+            pid_t i_pid = getpid ();
+            
+            msg_Dbg( p_vlc, "our PID is %d, writing it to %s", i_pid, psz_pidfile );
+            
+            pidfile = utf8_fopen( psz_pidfile,"w" );
+            if( pidfile != NULL )
+            {
+                utf8_fprintf( pidfile, "%d", (int)i_pid );
+                fclose( pidfile );
+            }
+            else
+            {
+                msg_Err( p_vlc, "Cannot open pid file for writing: %s, error: %s", 
+                        psz_pidfile, strerror(errno) );
+            }
+        }
+
+        free( psz_pidfile );
+
 #else
         pid_t i_pid;
 
@@ -684,7 +713,9 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
     }
 
     libvlc.b_stats = config_GetInt( p_vlc, "stats" );
-    libvlc.p_stats = NULL;
+    libvlc.i_timers = 0;
+    libvlc.pp_timers = NULL;
+    vlc_mutex_init( p_vlc, &libvlc.timer_lock );
 
     /*
      * Initialize hotkey handling
@@ -697,7 +728,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
     /*
      * Initialize playlist and get commandline files
      */
-    p_playlist = playlist_Create( p_vlc );
+    p_playlist = playlist_ThreadCreate( p_vlc );
     if( !p_playlist )
     {
         msg_Err( p_vlc, "playlist initialization failed" );
@@ -772,30 +803,30 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
 #ifdef HAVE_X11_XLIB_H
     if( config_GetInt( p_vlc, "disable-screensaver" ) == 1 )
     {
-        VLC_AddIntf( 0, "screensaver", VLC_FALSE, VLC_FALSE );
+        VLC_AddIntf( 0, "screensaver,none", VLC_FALSE, VLC_FALSE );
     }
 #endif
 
     if( config_GetInt( p_vlc, "file-logging" ) == 1 )
     {
-        VLC_AddIntf( 0, "logger", VLC_FALSE, VLC_FALSE );
+        VLC_AddIntf( 0, "logger,none", VLC_FALSE, VLC_FALSE );
     }
 #ifdef HAVE_SYSLOG_H
     if( config_GetInt( p_vlc, "syslog" ) == 1 )
     {
         char *psz_logmode = "logmode=syslog";
-        AddIntfInternal( 0, "logger", VLC_FALSE, VLC_FALSE, 1, &psz_logmode );
+        AddIntfInternal( 0, "logger,none", VLC_FALSE, VLC_FALSE, 1, &psz_logmode );
     }
 #endif
 
     if( config_GetInt( p_vlc, "show-intf" ) == 1 )
     {
-        VLC_AddIntf( 0, "showintf", VLC_FALSE, VLC_FALSE );
+        VLC_AddIntf( 0, "showintf,none", VLC_FALSE, VLC_FALSE );
     }
 
     if( config_GetInt( p_vlc, "network-synchronisation") == 1 )
     {
-        VLC_AddIntf( 0, "netsync", VLC_FALSE, VLC_FALSE );
+        VLC_AddIntf( 0, "netsync,none", VLC_FALSE, VLC_FALSE );
     }
 
     /*
@@ -885,7 +916,6 @@ int VLC_CleanUp( int i_object )
     vout_thread_t      * p_vout;
     aout_instance_t    * p_aout;
     announce_handler_t * p_announce;
-    stats_handler_t    * p_stats;
     vlc_t *p_vlc = vlc_current_object( i_object );
 
     /* Check that the handle is valid */
@@ -915,7 +945,7 @@ int VLC_CleanUp( int i_object )
     {
         vlc_object_detach( p_playlist );
         vlc_object_release( p_playlist );
-        playlist_Destroy( p_playlist );
+        playlist_ThreadDestroy( p_playlist );
     }
 
     /*
@@ -940,14 +970,8 @@ int VLC_CleanUp( int i_object )
         aout_Delete( p_aout );
     }
 
-    while( ( p_stats = vlc_object_find( p_vlc, VLC_OBJECT_STATS, FIND_CHILD) ))
-    {
-        stats_TimersDumpAll( p_vlc );
-        stats_HandlerDestroy( p_stats );
-        vlc_object_detach( (vlc_object_t*) p_stats );
-        vlc_object_release( (vlc_object_t *)p_stats );
-        // TODO: Delete it
-    }
+    stats_TimersDumpAll( p_vlc );
+    stats_TimersClean( p_vlc );
 
     /*
      * Free announce handler(s?)
@@ -1198,7 +1222,7 @@ int VLC_AddTarget( int i_object, char const *psz_target,
     if( p_playlist == NULL )
     {
         msg_Dbg( p_vlc, "no playlist present, creating one" );
-        p_playlist = playlist_Create( p_vlc );
+        p_playlist = playlist_ThreadCreate( p_vlc );
 
         if( p_playlist == NULL )
         {
@@ -1209,7 +1233,7 @@ int VLC_AddTarget( int i_object, char const *psz_target,
         vlc_object_yield( p_playlist );
     }
 
-    i_err = playlist_AddExt( p_playlist, psz_target, psz_target,
+    i_err = playlist_PlaylistAddExt( p_playlist, psz_target, psz_target,
                              i_mode, i_pos, -1, ppsz_options, i_options);
 
     vlc_object_release( p_playlist );
@@ -1337,7 +1361,6 @@ vlc_bool_t VLC_IsPlaying( int i_object )
     }
     else
     {
-        msg_Dbg(p_vlc, "polling playlist_IsPlaying");
         b_playing = playlist_IsPlaying( p_playlist );
     }
     vlc_object_release( p_playlist );
@@ -1632,29 +1655,8 @@ float VLC_SpeedSlower( int i_object )
  */
 int VLC_PlaylistIndex( int i_object )
 {
-    int i_index;
-    playlist_t * p_playlist;
-    vlc_t *p_vlc = vlc_current_object( i_object );
-
-    /* Check that the handle is valid */
-    if( !p_vlc )
-    {
-        return VLC_ENOOBJ;
-    }
-
-    p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
-
-    if( !p_playlist )
-    {
-        if( i_object ) vlc_object_release( p_vlc );
-        return VLC_ENOOBJ;
-    }
-
-    i_index = p_playlist->i_index;
-    vlc_object_release( p_playlist );
-
-    if( i_object ) vlc_object_release( p_vlc );
-    return i_index;
+    printf( "This function is deprecated and should not be used anymore" );
+    return -1;
 }
 
 /**
@@ -1764,7 +1766,6 @@ int VLC_PlaylistPrev( int i_object )
  *****************************************************************************/
 int VLC_PlaylistClear( int i_object )
 {
-    int i_err;
     playlist_t * p_playlist;
     vlc_t *p_vlc = vlc_current_object( i_object );
 
@@ -1782,12 +1783,12 @@ int VLC_PlaylistClear( int i_object )
         return VLC_ENOOBJ;
     }
 
-    i_err = playlist_Clear( p_playlist );
+    playlist_Clear( p_playlist );
 
     vlc_object_release( p_playlist );
 
     if( i_object ) vlc_object_release( p_vlc );
-    return i_err;
+    return VLC_SUCCESS;
 }
 
 /**