]> git.sesse.net Git - vlc/blobdiff - modules/gui/ncurses.c
qt4 fullscreen: Uses FIND_ANYWHERE to find vout, fixes trax issue 24
[vlc] / modules / gui / ncurses.c
index 56dbdc0cd0cc91ee1042a479a58da6f14bdff30b..8f55d68b9fae731113369c973122950fc7d89ed1 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#define _GNU_SOURCE
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>
+#include <vlc/vlc.h>
+
 #include <errno.h>                                                 /* ENOMEM */
-#include <stdio.h>
 #include <time.h>
 
 #include <curses.h>
 
-#include <vlc/vlc.h>
 #include <vlc_interface.h>
-#include <<vlc_vout.h>>
-#include <<vlc_aout.h>>
+#include <vlc_vout.h>
+#include <vlc_aout.h>
 #include <vlc_charset.h>
+#include <vlc_input.h>
+#include <vlc_playlist.h>
 
 #ifdef HAVE_SYS_STAT_H
 #   include <sys/stat.h>
@@ -80,7 +79,7 @@ static void Redraw         ( intf_thread_t *, time_t * );
 
 static playlist_item_t *PlaylistGetRoot( intf_thread_t * );
 static void PlaylistRebuild( intf_thread_t * );
-static void PlaylistAddNode( intf_thread_t *, playlist_item_t *, int, char *);
+static void PlaylistAddNode( intf_thread_t *, playlist_item_t *, int, const char *);
 static void PlaylistDestroy( intf_thread_t * );
 static int  PlaylistChanged( vlc_object_t *, const char *, vlc_value_t,
                              vlc_value_t, void * );
@@ -837,7 +836,7 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
         case 'q':
         case 'Q':
         case 0x1b:  /* Esc */
-            p_intf->p_libvlc->b_die = VLC_TRUE;
+            vlc_object_kill( p_intf->p_libvlc );
             return 0;
 
         /* Box switching */
@@ -1207,8 +1206,9 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
         vlc_value_t val_list;
 
         /* Source */
-        mvnprintw( y++, 0, COLS, " Source   : %s",
-                   p_input->input.p_item->psz_uri );
+        char *psz_uri = input_item_GetURI( input_GetItem( p_input ) );
+        mvnprintw( y++, 0, COLS, " Source   : %s", psz_uri );
+        free( psz_uri );
 
         /* State */
         var_Get( p_input, "state", &val );
@@ -1377,10 +1377,10 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
         if( p_input )
         {
             int i,j;
-            vlc_mutex_lock( &p_input->input.p_item->lock );
-            for( i = 0; i < p_input->input.p_item->i_categories; i++ )
+            vlc_mutex_lock( &input_GetItem(p_input)->lock );
+            for( i = 0; i < input_GetItem(p_input)->i_categories; i++ )
             {
-                info_category_t *p_category = p_input->input.p_item->pp_categories[i];
+                info_category_t *p_category = input_GetItem(p_input)->pp_categories[i];
                 if( y >= y_end ) break;
                 MainBoxWrite( p_intf, l++, 1, "  [%s]", p_category->psz_name );
                 for( j = 0; j < p_category->i_infos; j++ )
@@ -1390,7 +1390,7 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
                     MainBoxWrite( p_intf, l++, 1, "      %s: %s", p_info->psz_name, p_info->psz_value );
                 }
             }
-            vlc_mutex_unlock( &p_input->input.p_item->lock );
+            vlc_mutex_unlock( &input_GetItem(p_input)->lock );
         }
         else
         {
@@ -1664,7 +1664,7 @@ static void PlaylistRebuild( intf_thread_t *p_intf )
 }
 
 static void PlaylistAddNode( intf_thread_t *p_intf, playlist_item_t *p_node,
-                             int i, char *c )
+                             int i, const char *c )
 {
     intf_sys_t *p_sys = p_intf->p_sys;
     playlist_item_t *p_child;
@@ -1901,7 +1901,7 @@ static void ReadDir( intf_thread_t *p_intf )
 
     if( p_sys->psz_current_dir && *p_sys->psz_current_dir )
     {
-        const char *psz_entry;
+        char *psz_entry;
 
         /* Open the dir */
         p_current_dir = utf8_opendir( p_sys->psz_current_dir );
@@ -1929,11 +1929,8 @@ static void ReadDir( intf_thread_t *p_intf )
         p_sys->pp_dir_entries = NULL;
         p_sys->i_dir_entries = 0;
 
-        /* get the first directory entry */
-        psz_entry = utf8_readdir( p_current_dir );
-
         /* while we still have entries in the directory */
-        while( psz_entry != NULL )
+        while( ( psz_entry = utf8_readdir( p_current_dir ) ) != NULL )
         {
 #if defined( S_ISDIR )
             struct stat stat_data;
@@ -1948,7 +1945,6 @@ static void ReadDir( intf_thread_t *p_intf )
                 strcmp( psz_entry, ".." ) )
             {
                 free( psz_entry );
-                psz_entry = utf8_readdir( p_current_dir );
                 continue;
             }
 
@@ -1957,13 +1953,14 @@ static void ReadDir( intf_thread_t *p_intf )
 
             if( !( p_dir_entry = malloc( sizeof( struct dir_entry_t) ) ) )
             {
-                free( psz_uri);
-                return;
+                free( psz_uri );
+                free( psz_entry );
+                continue;
             }
 
 #if defined( S_ISDIR )
-            utf8_stat( psz_uri, &stat_data );
-            if( S_ISDIR(stat_data.st_mode) )
+            if( !utf8_stat( psz_uri, &stat_data )
+             && S_ISDIR(stat_data.st_mode) )
 /*#elif defined( DT_DIR )
             if( p_dir_content->d_type & DT_DIR )*/
 #else
@@ -1985,8 +1982,6 @@ static void ReadDir( intf_thread_t *p_intf )
 
             free( psz_uri );
             free( psz_entry );
-            /* Read next entry */
-            psz_entry = utf8_readdir( p_current_dir );
         }
 
         /* Sort */