]> git.sesse.net Git - vlc/blobdiff - modules/gui/ncurses.c
Use KiB instead of kB for input statistics
[vlc] / modules / gui / ncurses.c
index d1cdba433d534e88754748975ea28147c14b7f6a..f3641edc11b22b2afbfba49e1fdd7f859f8feff4 100644 (file)
 #include <vlc_es.h>
 #include <vlc_playlist.h>
 #include <vlc_meta.h>
+#include <vlc_fs.h>
 
 #include <assert.h>
 
 #ifdef HAVE_SYS_STAT_H
 #   include <sys/stat.h>
 #endif
-#if (!defined( WIN32 ) || defined(__MINGW32__))
-/* Mingw has its own version of dirent */
-#   include <dirent.h>
-#endif
 
 #define SEARCH_CHAIN_SIZE 20
 #define OPEN_CHAIN_SIZE 50
@@ -338,7 +335,6 @@ static void Close( vlc_object_t *p_this )
     {
         vlc_object_release( p_sys->p_input );
     }
-    pl_Release( p_intf );
 
     /* Close the ncurses interface */
     endwin();
@@ -355,7 +351,7 @@ static void Close( vlc_object_t *p_this )
 static void Run( intf_thread_t *p_intf )
 {
     intf_sys_t    *p_sys = p_intf->p_sys;
-    playlist_t    *p_playlist = pl_Hold( p_intf );
+    playlist_t    *p_playlist = pl_Get( p_intf );
     p_sys->p_playlist = p_playlist;
 
     int i_key;
@@ -538,7 +534,7 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
     intf_sys_t *p_sys = p_intf->p_sys;
     int i_ret = 1;
 
-    playlist_t *p_playlist = pl_Hold( p_intf );
+    playlist_t *p_playlist = pl_Get( p_intf );
 
     if( p_sys->i_box_type == BOX_PLAYLIST )
     {
@@ -1119,20 +1115,15 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
         /* Common control */
         case 'f':
         {
+            bool fs = var_ToggleBool( p_playlist, "fullscreen" );
             if( p_intf->p_sys->p_input )
             {
-                vout_thread_t *p_vout;
-                p_vout = vlc_object_find( p_intf->p_sys->p_input,
-                                          VLC_OBJECT_VOUT, FIND_CHILD );
+                vout_thread_t *p_vout = input_GetVout( p_intf->p_sys->p_input );
                 if( p_vout )
                 {
-                    var_ToggleBool( p_vout, "fullscreen" );
+                    var_SetBool( p_vout, "fullscreen", fs );
                     vlc_object_release( p_vout );
                 }
-                else
-                {
-                    var_ToggleBool( p_playlist, "fullscreen" );
-                }
             }
             i_ret = 0;
             break;
@@ -1203,7 +1194,6 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
     }
 
 end:
-    pl_Release( p_intf );
     return i_ret;
 }
 
@@ -1466,7 +1456,7 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
 {
     intf_sys_t     *p_sys = p_intf->p_sys;
     input_thread_t *p_input = p_sys->p_input;
-    playlist_t     *p_playlist = pl_Hold( p_intf );
+    playlist_t     *p_playlist = pl_Get( p_intf );
     int y = 0;
     int h;
     int y_end;
@@ -1530,10 +1520,10 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
 
             /* Position */
             var_Get( p_input, "time", &val );
-            msecstotimestr( buf1, val.i_time / 1000 );
+            secstotimestr( buf1, val.i_time / CLOCK_FREQ );
 
             var_Get( p_input, "length", &val );
-            msecstotimestr( buf2, val.i_time / 1000 );
+            secstotimestr( buf2, val.i_time / CLOCK_FREQ );
 
             mvnprintw( y++, 0, COLS, _(" Position : %s/%s (%.2f%%)"), buf1, buf2, p_sys->f_slider );
 
@@ -1982,13 +1972,13 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
             MainBoxWrite( p_intf, l, 1, _("+-[Incoming]"));
             SHOW_ACS( 1, ACS_ULCORNER );  SHOW_ACS( 2, ACS_HLINE ); l++;
             if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL );
-            MainBoxWrite( p_intf, l, 1, _("| input bytes read : %8.0f kB"),
-                    (float)(p_item->p_stats->i_read_bytes)/1000 );
+            MainBoxWrite( p_intf, l, 1, _("| input bytes read : %8.0f KiB"),
+                    (float)(p_item->p_stats->i_read_bytes)/1024 );
             SHOW_ACS( 1, ACS_VLINE ); l++;
             MainBoxWrite( p_intf, l, 1, _("| input bitrate    :   %6.0f kb/s"),
                     (float)(p_item->p_stats->f_input_bitrate)*8000 );
-            MainBoxWrite( p_intf, l, 1, _("| demux bytes read : %8.0f kB"),
-                    (float)(p_item->p_stats->i_demux_read_bytes)/1000 );
+            MainBoxWrite( p_intf, l, 1, _("| demux bytes read : %8.0f KiB"),
+                    (float)(p_item->p_stats->i_demux_read_bytes)/1024 );
             SHOW_ACS( 1, ACS_VLINE ); l++;
             MainBoxWrite( p_intf, l, 1, _("| demux bitrate    :   %6.0f kb/s"),
                     (float)(p_item->p_stats->f_demux_bitrate)*8000 );
@@ -2041,8 +2031,8 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
             if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL );
             MainBoxWrite( p_intf, l, 1, _("| packets sent     :    %5i"), p_item->p_stats->i_sent_packets );
             SHOW_ACS( 1, ACS_VLINE ); l++;
-            MainBoxWrite( p_intf, l, 1, _("| bytes sent       : %8.0f kB"),
-                    (float)(p_item->p_stats->i_sent_bytes)/1000 );
+            MainBoxWrite( p_intf, l, 1, _("| bytes sent       : %8.0f KiB"),
+                    (float)(p_item->p_stats->i_sent_bytes)/1024 );
             SHOW_ACS( 1, ACS_VLINE ); l++;
             MainBoxWrite( p_intf, l, 1, _("\\ sending bitrate  :   %6.0f kb/s"),
                     (float)(p_item->p_stats->f_send_bitrate*8)*1000 );
@@ -2205,13 +2195,12 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
     refresh();
 
     *t_last_refresh = time( 0 );
-    pl_Release( p_intf );
 }
 
 static playlist_item_t *PlaylistGetRoot( intf_thread_t *p_intf )
 {
     intf_sys_t *p_sys = p_intf->p_sys;
-    playlist_t *p_playlist = pl_Hold( p_intf );
+    playlist_t *p_playlist = pl_Get( p_intf );
     playlist_item_t *p_item;
 
     switch( p_sys->i_current_view )
@@ -2222,14 +2211,13 @@ static playlist_item_t *PlaylistGetRoot( intf_thread_t *p_intf )
         default:
             p_item = p_playlist->p_root_onelevel;
     }
-    pl_Release( p_intf );
     return p_item;
 }
 
 static void PlaylistRebuild( intf_thread_t *p_intf )
 {
     intf_sys_t *p_sys = p_intf->p_sys;
-    playlist_t *p_playlist = pl_Hold( p_intf );
+    playlist_t *p_playlist = pl_Get( p_intf );
 
     PL_LOCK;
 
@@ -2242,8 +2230,6 @@ static void PlaylistRebuild( intf_thread_t *p_intf )
     p_sys->b_need_update = false;
 
     PL_UNLOCK;
-
-    pl_Release( p_intf );
 }
 
 static void PlaylistAddNode( intf_thread_t *p_intf, playlist_item_t *p_node,
@@ -2299,10 +2285,9 @@ static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
     VLC_UNUSED(p_this); VLC_UNUSED(psz_variable);
     VLC_UNUSED(oval); VLC_UNUSED(nval);
     intf_thread_t *p_intf = (intf_thread_t *)param;
-    playlist_t *p_playlist = pl_Hold( p_intf );
+    playlist_t *p_playlist = pl_Get( p_intf );
     p_intf->p_sys->b_need_update = true;
     p_intf->p_sys->p_node = playlist_CurrentPlayingItem(p_playlist) ? playlist_CurrentPlayingItem(p_playlist)->p_parent : NULL;
-    pl_Release( p_intf );
     return VLC_SUCCESS;
 }
 
@@ -2371,13 +2356,12 @@ static void Eject( intf_thread_t *p_intf )
      * If it's neither of these, then return
      */
 
-    playlist_t * p_playlist = pl_Hold( p_intf );
+    playlist_t * p_playlist = pl_Get( p_intf );
     PL_LOCK;
 
     if( playlist_CurrentPlayingItem(p_playlist) == NULL )
     {
         PL_UNLOCK;
-        pl_Release( p_intf );
         return;
     }
 
@@ -2437,7 +2421,6 @@ static void Eject( intf_thread_t *p_intf )
 
     if( psz_device == NULL )
     {
-        pl_Release( p_intf );
         return;
     }
 
@@ -2460,8 +2443,6 @@ static void Eject( intf_thread_t *p_intf )
     }
 
     free( psz_device );
-    pl_Release( p_intf );
-    return;
 }
 
 static int comp_dir_entries( const void *pp_dir_entry1,
@@ -2489,7 +2470,7 @@ static void ReadDir( intf_thread_t *p_intf )
         char *psz_entry;
 
         /* Open the dir */
-        p_current_dir = utf8_opendir( p_sys->psz_current_dir );
+        p_current_dir = vlc_opendir( p_sys->psz_current_dir );
 
         if( p_current_dir == NULL )
         {
@@ -2511,7 +2492,7 @@ static void ReadDir( intf_thread_t *p_intf )
         p_sys->i_dir_entries = 0;
 
         /* while we still have entries in the directory */
-        while( ( psz_entry = utf8_readdir( p_current_dir ) ) != NULL )
+        while( ( psz_entry = vlc_readdir( p_current_dir ) ) != NULL )
         {
 #if defined( S_ISDIR )
             struct stat stat_data;
@@ -2542,7 +2523,7 @@ static void ReadDir( intf_thread_t *p_intf )
             }
 
 #if defined( S_ISDIR )
-            if( !utf8_stat( psz_uri, &stat_data )
+            if( !vlc_stat( psz_uri, &stat_data )
              && S_ISDIR(stat_data.st_mode) )
 /*#elif defined( DT_DIR )
             if( p_dir_content->d_type & DT_DIR )*/
@@ -2584,7 +2565,7 @@ static void ReadDir( intf_thread_t *p_intf )
 static void PlayPause( intf_thread_t *p_intf )
 {
     input_thread_t *p_input = p_intf->p_sys->p_input;
-    playlist_t *p_playlist = pl_Hold( p_intf );
+    playlist_t *p_playlist = pl_Get( p_intf );
     vlc_value_t val;
 
     if( p_input )
@@ -2602,8 +2583,6 @@ static void PlayPause( intf_thread_t *p_intf )
     }
     else
         playlist_Play( p_playlist );
-
-    pl_Release( p_intf );
 }
 
 /****************************************************************************