play_list.h File Reference


Detailed Description

Play list Services.

This plug-in allow to open and manage a play list file (*.txt,*.m3u,*.m3u8,...) included in text file This plug-in is connected on the reader_txt plug-in and the navigation module.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file play_list.h.

#include "fs_com.h"
#include "conf_explorer.h"

Go to the source code of this file.

List of supported file extensions

#define PL_FILE_EXT   "m3u,pls,smp"
enum  readline_opt_t { PL_MAIN_READLINE_OPT_CHECKLINE, PL_MAIN_READLINE_OPT_READSTRING, PL_MAIN_READLINE_OPT_GOTOPATH }
 This function reads and checks the next line. More...
Bool pl_add (const FS_STRING sz_filterext, U8 u8_mode)
 This function adds files in play list.
Bool pl_main_close (void)
 This function closes the play list and selects this one in current navigator.
Bool pl_main_ismodify (void)
 This function checks if the play list file is modified.
Bool pl_main_isopen (void)
 This function checks if a play list file is already opened.
Bool pl_main_modify (void)
 This function creates a copy of the play list in case of a restore action.
Bool pl_main_new (const FS_STRING sz_name, Bool b_undo)
 This function creates a new empty play list file.
Bool pl_main_open (Bool b_undo)
 This function opens the current selected file in the current navigator.
Bool pl_main_readline (readline_opt_t opt, U8 id_nav, FS_STRING *sz_path, U16 *u16_size_line)
 This function reads and checks the next line.
Bool pl_main_save (void)
 This function saves the play list file.
Bool pl_nav_eol (void)
 This function checks the end of the play list.
U16 pl_nav_getnbfile (void)
 Return the number of files in play list.
U16 pl_nav_getpos (void)
 Return the position in the play list.
Bool pl_nav_readentry (U16 u16_position, FS_STRING *sz_pat, U16 *u16_size_line)
 This function read the playliost's entry at a specific position.
Bool pl_nav_setpos (U16 u16_position)
 This function goes to a position in the play list.
Bool pl_rem_dead (void)
 This function remove the dead file in the list.
Bool pl_rem_sel (void)
 This function removes the selected file in the list.
Bool pl_rem_sel_all (void)
 This function removes all files in the list.
Bool pl_sel_isvalid (void)
 This function tests the valid path in list.

Defines

Options for "pl_add()"
#define PL_ADD_DIR   0x01
#define PL_ADD_FILE   0x00
#define PL_ADD_SUBDIR   0x02


Define Documentation

#define PL_ADD_DIR   0x01

Definition at line 54 of file play_list.h.

#define PL_ADD_FILE   0x00

Definition at line 53 of file play_list.h.

Referenced by pl_add().

#define PL_ADD_SUBDIR   0x02

Definition at line 55 of file play_list.h.

Referenced by pl_add().

#define PL_FILE_EXT   "m3u,pls,smp"

Definition at line 59 of file play_list.h.


Enumeration Type Documentation

This function reads and checks the next line.

Parameters:
b_gotopath PL_MAIN_READLINE_OPT_CHECKLINE to check the next line in the file.
PL_MAIN_READLINE_OPT_READSTRING to read the string in the text file.
PL_MAIN_READLINE_OPT_GOTOPATH to read, chack and goto the path.
id_nav ID navigator to update with the selected file (ignore if b_gotopatch == FALSE)
sz_path Address of the string returned. It is used only if PL_MAIN_READLINE_OPT_READSTRING or PL_MAIN_READLINE_OPT_GOTOPATH options are specified.
u16_size_line The length of the path.
Returns:
TRUE if a line with a correct path FALSE line ignored or end of file
Enumerator:
PL_MAIN_READLINE_OPT_CHECKLINE 
PL_MAIN_READLINE_OPT_READSTRING 
PL_MAIN_READLINE_OPT_GOTOPATH 

Definition at line 164 of file play_list.h.


Function Documentation

Bool pl_add ( const FS_STRING  sz_filterext,
U8  u8_mode 
)

This function adds files in play list.

Parameters:
sz_filterext add file only corresponding to the extension filter
u8_mode PL_ADD_FILE, PL_ADD_DIR, PL_ADD_SUBDIR
Returns:
FALSE in case of error, see global value "fs_g_status" for more detail

TRUE otherwise

//! It is possible to select a file or all files in a directory
//! 

Definition at line 705 of file play_list.c.

References file_getc(), file_putc(), file_seek(), FS_FIND_NEXT, FS_SEEK_END, FS_SEEK_SET, nav_dir_cd(), nav_dir_gotoparent(), nav_file_checkext(), nav_file_isdir(), nav_file_lgt(), nav_filelist_reset(), nav_filelist_set(), nav_get(), nav_getcwd(), nav_select(), nav_string_ascii(), nav_string_unicode(), PL_ADD_FILE, PL_ADD_SUBDIR, pl_cache_path, PL_CACHE_PATH_MAX_SIZE, pl_g_u16_list_sel, pl_g_u16_list_size, and pl_main_modify().

00706 {
00707    U8 nav_id_save;
00708    U8 u8_folder_level;
00709 
00710    if( !pl_main_modify() )
00711       return FALSE;
00712    nav_id_save = nav_get();
00713 
00714    // Check last character of file
00715    nav_select( FS_NAV_ID_PLAYLIST );
00716    if( 0!=nav_file_lgt() )
00717    {
00718 #if( PL_UNICODE == ENABLED)
00719       file_string_unicode();
00720       file_seek( 2, FS_SEEK_END);
00721       if( '\n' != file_getc())
00722       {
00723          file_seek( 2, FS_SEEK_END);
00724          file_putc('\n');
00725       }
00726       file_string_ascii();
00727 #else
00728       file_seek( 1, FS_SEEK_END);
00729       if( '\n' != file_getc())
00730       {
00731          file_seek( 1, FS_SEEK_END);
00732          file_putc('\n');
00733       }
00734 #endif
00735    }
00736    nav_select( nav_id_save );
00737 
00738    // Get path of play list file and check with curent to create a relative path
00739 
00740    if( PL_ADD_FILE == u8_mode )
00741       goto pl_add_file;
00742 
00743    // Add all files valid in current dir
00744    u8_folder_level = 0;
00745    nav_filelist_reset();
00746    while(1)
00747    {
00748       while(1)
00749       {
00750          if( nav_filelist_set( 0 , FS_FIND_NEXT ) )
00751             break;   // a next file and directory is found
00752          // No other dir or file in current dir then go to parent dir
00753          if( 0 == u8_folder_level )
00754             goto pl_add_end;  // end of ADD
00755          // Remark, nav_dir_gotoparent() routine go to in parent dir and select the children dir in list
00756          u8_folder_level--;
00757          if( !nav_dir_gotoparent() )
00758             return FALSE;
00759       }
00760 
00761       if( nav_file_isdir())
00762       {
00763          if( PL_ADD_SUBDIR == u8_mode )
00764          {  // Enter in sub dir
00765             if( !nav_dir_cd())
00766                return FALSE;
00767             u8_folder_level++;
00768          }
00769       }
00770       else
00771       {
00772 pl_add_file:
00773          if( nav_file_checkext( sz_filterext ) )
00774          {
00775             // It is a valid file
00776             // Get name of current file
00777 #if( (FS_ASCII == ENABLED) && (FS_UNICODE == ENABLED) && (PL_UNICODE == DISABLED) )
00778             nav_string_ascii();
00779 #endif
00780             nav_getcwd( (FS_STRING)pl_cache_path, PL_CACHE_PATH_MAX_SIZE, TRUE );
00781 #if( (FS_ASCII == ENABLED) && (FS_UNICODE == ENABLED) && (PL_UNICODE == DISABLED) )
00782             nav_string_unicode();
00783 #endif
00784             // Write path in file list
00785             nav_select( FS_NAV_ID_PLAYLIST );
00786 #if( PL_UNICODE == ENABLED)
00787             file_string_unicode();
00788 #endif
00789             if( file_puts(pl_cache_path))
00790                file_putc('\n');
00791 #if( PL_UNICODE == ENABLED)
00792             file_string_ascii();
00793 #endif
00794             nav_select( nav_id_save );
00795             pl_g_u16_list_size++;
00796          }
00797          if( PL_ADD_FILE == u8_mode )
00798             goto pl_add_end;
00799       } // if dir OR file
00800    } // end of first while(1)
00801 
00802 pl_add_end:
00803    // Go to beginning of file AND no file selected
00804    nav_select( FS_NAV_ID_PLAYLIST );
00805    file_seek( 0 , FS_SEEK_SET );
00806    pl_g_u16_list_sel = 0;
00807    nav_select( nav_id_save );
00808    return TRUE;
00809 }

Bool pl_main_close ( void   ) 

This function closes the play list and selects this one in current navigator.

Returns:
FALSE in case of error, see global value "fs_g_status" for more detail

TRUE otherwise

Definition at line 277 of file play_list.c.

References copyfile_index, file_close(), FS_NAME_GET, Is_unicode, nav_file_del(), nav_file_name(), nav_file_rename(), nav_get(), nav_getindex(), nav_gotoindex(), nav_select(), nav_string_length_disable(), nav_string_length_enable(), pl_g_list_is_modify, pl_g_list_is_open, pl_g_list_undo, and pl_main_isopen().

Referenced by navauto_close().

00278 {
00279    _MEM_TYPE_SLOW_ Fs_index index;
00280    U8 nav_id_save;
00281 
00282    if( !pl_main_isopen() )
00283       return FALSE;
00284 
00285    // Close play list
00286    nav_id_save = nav_get();
00287    nav_select( FS_NAV_ID_PLAYLIST );
00288    file_close();
00289 
00290 #if( PL_READONLY == DISABLED )
00291    if( pl_g_list_is_modify )
00292    {
00293       if( pl_g_list_undo )
00294       {
00295          U16 size_name;
00296          FS_STRING sz_name;
00297 
00298          //** Play list modified but not saved, then restore previous list
00299          // Get name of play list
00300          nav_string_length_enable();
00301          nav_file_name( (FS_STRING)&size_name, 1, FS_NAME_GET, FALSE );
00302          nav_string_length_disable();
00303          sz_name = PLAYLIST_BUF_ALLOC( size_name* (Is_unicode? 2 : 1 ) );
00304          if( NULL != sz_name )
00305          {
00306             if( nav_file_name( sz_name, size_name, FS_NAME_GET, FALSE ) )
00307             {
00308                // Delete current play list
00309                if( nav_file_del( TRUE ) )             // Remove copy file
00310                {
00311                   nav_gotoindex( &copyfile_index );   // Select copy play list
00312                   nav_file_rename( sz_name );         // rename copy play list
00313                }
00314             }
00315             PLAYLIST_BUF_FREE( sz_name );
00316          }
00317       }
00318    }
00319 #endif
00320 
00321    // Select the play list file in current navigator
00322    index = nav_getindex();       // Save a pointer on play list file
00323    nav_select( nav_id_save );
00324    nav_gotoindex( &index );
00325    pl_g_list_is_open = FALSE;
00326    return TRUE;
00327 }

Bool pl_main_ismodify ( void   ) 

This function checks if the play list file is modified.

Returns:
TRUE the play list file is modified

Definition at line 121 of file play_list.c.

References pl_g_list_is_modify.

00122 {
00123 #if( PL_READONLY == DISABLED )
00124    return pl_g_list_is_modify;
00125 #else
00126    return FALSE;
00127 #endif
00128 }

Bool pl_main_isopen ( void   ) 

This function checks if a play list file is already opened.

Returns:
TRUE a play list file is opened

Definition at line 110 of file play_list.c.

References FS_ERR_PL_NOT_OPEN, fs_g_status, and pl_g_list_is_open.

Referenced by pl_main_close(), pl_main_modify(), pl_main_new(), pl_main_open(), pl_main_save(), and pl_sel_isvalid().

00111 {
00112    fs_g_status = FS_ERR_PL_NOT_OPEN;
00113    return pl_g_list_is_open;
00114 }

Bool pl_main_modify ( void   ) 

This function creates a copy of the play list in case of a restore action.

Returns:
FALSE in case of error, see global value "fs_g_status" for more detail

TRUE otherwise

Bool pl_main_new ( const FS_STRING  sz_name,
Bool  b_undo 
)

This function creates a new empty play list file.

Parameters:
sz_name contains the file name (ASCII or UNICODE )
b_undo TRUE to autorize the undo feature
Returns:
FALSE in case of error, see global value "fs_g_status" for more detail

TRUE otherwise

Definition at line 140 of file play_list.c.

References pl_main_isopen(), pl_main_open(), reader_txt_close(), reader_txt_new(), and UNI_TYPE_UTF16BE.

00141 {
00142    if( pl_main_isopen() )
00143       return FALSE;
00144 
00145    // Create an empty text file
00146    if( !reader_txt_new( sz_name, UNI_TYPE_UTF16BE ))
00147       return FALSE;
00148    reader_txt_close();
00149 
00150    // Load the play list file
00151    return pl_main_open( b_undo );
00152 }

Bool pl_main_open ( Bool  b_undo  ) 

This function opens the current selected file in the current navigator.

Parameters:
b_undo TRUE to autorize the undo feature
Returns:
FALSE in case of error, see global value "fs_g_status" for more detail

TRUE otherwise

Definition at line 163 of file play_list.c.

References E_PL_M3U, E_PL_PLS, E_PL_SMP, file_eof(), nav_copy(), nav_file_checkext(), nav_file_isreadonly(), nav_filelist_reset(), nav_get(), nav_select(), pl_g_list_is_modify, pl_g_list_is_open, pl_g_list_is_readonly, pl_g_list_type, pl_g_list_undo, pl_g_u16_list_sel, pl_g_u16_list_size, pl_main_isopen(), pl_main_readline(), PL_MAIN_READLINE_OPT_CHECKLINE, reader_txt_beg(), and reader_txt_open().

Referenced by navauto_open(), pl_main_modify(), pl_main_new(), and pl_main_save().

00164 {
00165    U8 nav_id_save;
00166 
00167    if( pl_main_isopen() )
00168       return FALSE;
00169 
00170    // Select the play list file in "play list" navigator
00171    nav_id_save = nav_get();            // Save current navigator
00172    nav_copy( FS_NAV_ID_PLAYLIST );
00173    nav_select( FS_NAV_ID_PLAYLIST );
00174 
00175    // Make sure the selected file is a playlist
00176    if( nav_file_checkext("m3u") )
00177    {
00178       pl_g_list_type = E_PL_M3U;
00179    }else
00180    if( nav_file_checkext("pls") )
00181    {
00182       pl_g_list_type = E_PL_PLS;
00183    }else
00184    if( nav_file_checkext("smp") )
00185    {
00186       pl_g_list_type = E_PL_SMP;
00187    }else
00188       goto pl_main_open_end;
00189 
00190    // Open list
00191 #if( PL_READONLY == DISABLED )
00192    pl_g_list_undo          = b_undo;
00193    pl_g_list_is_modify     = FALSE;
00194    pl_g_list_is_readonly   = nav_file_isreadonly();
00195    if( pl_g_list_is_readonly )
00196    {
00197       if( !reader_txt_open( TRUE ))
00198          goto pl_main_open_end;
00199    }else{
00200       if( !reader_txt_open( FALSE ))
00201          goto pl_main_open_end;
00202    }
00203 #else
00204     if( !reader_txt_open( TRUE ))
00205        goto pl_main_open_end;
00206 #endif
00207 
00208    // Compute the number of file in list
00209    pl_g_u16_list_size    = 0;
00210    while( 0 == file_eof() )
00211    {
00212       if( pl_main_readline(PL_MAIN_READLINE_OPT_CHECKLINE,0,NULL,NULL) )
00213          pl_g_u16_list_size++;   // Add a file
00214    }
00215 
00216    // Go to at the beginning of text file
00217    reader_txt_beg();
00218 
00219    pl_g_u16_list_sel    = 0;     // Don't select a file
00220    pl_g_list_is_open    = TRUE;  // Play list file is opened
00221    nav_select( nav_id_save );    // Re select the previous navigator
00222    nav_filelist_reset();
00223 
00224 pl_main_open_end:
00225    nav_select( nav_id_save );    // Re select the previous navigator
00226    return pl_g_list_is_open;
00227 }

Bool pl_main_readline ( readline_opt_t  opt,
U8  id_nav,
FS_STRING sz_path,
U16 *  u16_size_line 
)

This function reads and checks the next line.

Parameters:
opt PL_MAIN_READLINE_OPT_CHECKLINE to check the next line in the file.
PL_MAIN_READLINE_OPT_READSTRING to read the string in the text file.
PL_MAIN_READLINE_OPT_GOTOPATH to read, chack and goto the path.
id_nav ID navigator to update with the selected file (ignore if b_gotopatch == FALSE)
sz_path Address of the string returned. It is used only if PL_MAIN_READLINE_OPT_READSTRING or PL_MAIN_READLINE_OPT_GOTOPATH options are specified.
u16_size_line The length of the path. If this parameter is NULL, then the lenght is not returned.
Returns:
TRUE if a line with a correct path FALSE line ignored or end of file

Definition at line 577 of file play_list.c.

References E_PL_M3U, E_PL_PLS, E_PL_SMP, file_getpos(), file_seek(), FS_SEEK_SET, FS_UNICODE, Is_unicode, nav_copy(), nav_filelist_reset(), nav_select(), nav_setcwd(), pl_g_list_type, PL_MAIN_READLINE_OPT_CHECKLINE, PL_MAIN_READLINE_OPT_READSTRING, and reader_txt_get_line().

Referenced by pl_main_open(), pl_nav_readentry(), and pl_nav_setpos().

00578 {
00579    U16 line_beg[8];           // Contains first characters of the line
00580    U32 u32_file_pos;
00581    U16 u16_alt_length = 0;
00582    U8  u8_pos_path_in_line = 0;
00583 
00584    // Set output to NULL to specify if there is an error
00585    *sz_path = NULL;
00586 
00587    // Read the 3 first char in the line
00588    u32_file_pos = file_getpos();
00589    if( E_PL_M3U == pl_g_list_type )
00590    {
00591       // M3U path lines = "path\file"
00592       // M3U comment lines = "#..."
00593       u16_alt_length = reader_txt_get_line( TRUE, (FS_STRING)line_beg, 2 );
00594       if( (2 > u16_alt_length)   // The line size is not correct
00595       ||  ('#' == line_beg[0]) ) // It is a comment line
00596       {
00597          return FALSE;
00598       }
00599       u8_pos_path_in_line=0;
00600    }
00601    if( (E_PL_PLS == pl_g_list_type) || (E_PL_SMP == pl_g_list_type) )
00602    {
00603       // PLS path lines = "Filexxx=path\file"
00604       // SMP path lines = "File=path\file"
00605       u16_alt_length = reader_txt_get_line( TRUE, (FS_STRING)line_beg, 8 );
00606       if(6 > u16_alt_length)     // The line size can't containt a path line
00607          return FALSE;
00608       // Check if it is a path line
00609       if( ('F' != line_beg[0])
00610       ||  ('i' != line_beg[1])
00611       ||  ('l' != line_beg[2])
00612       ||  ('e' != line_beg[3]) )
00613       {
00614          return FALSE;
00615       }
00616       u8_pos_path_in_line=5;
00617       if('=' != line_beg[4])
00618       {
00619          u8_pos_path_in_line++;
00620          if('=' != line_beg[5])
00621          {
00622             u8_pos_path_in_line++;
00623             if('=' != line_beg[6])
00624             {
00625                u8_pos_path_in_line++;
00626                if('=' != line_beg[7])
00627                   return FALSE;
00628             }
00629          }
00630       }
00631    }
00632    // Here, the line contains a path
00633 
00634    // Store the length of the line if a buffer is set
00635    if (u16_size_line)
00636      *u16_size_line = u16_alt_length - u8_pos_path_in_line;
00637    if (opt == PL_MAIN_READLINE_OPT_CHECKLINE)
00638       return TRUE;
00639    // else go to path
00640 
00641    // Read all characters in line
00642    file_seek( u32_file_pos, FS_SEEK_SET );
00643    *sz_path = PLAYLIST_BUF_ALLOC( u16_alt_length * (Is_unicode? 2 : 1 ) );
00644    if( NULL == *sz_path )
00645       return FALSE;   // no enought memory, impossible to store the path but path present in line
00646    if( 0 == reader_txt_get_line( (FS_UNICODE==ENABLED), *sz_path, u16_alt_length ) )
00647       return FALSE;  // Error during the read
00648    if( 0 != u8_pos_path_in_line )
00649    {
00650       // Shift the path to the beginning of the buffer
00651       memmove(*sz_path, *sz_path + u8_pos_path_in_line * ((FS_UNICODE==ENABLED) ? 2 : 1),
00652               (u16_alt_length - u8_pos_path_in_line) * ((FS_UNICODE==ENABLED) ? 2 : 1));
00653    }
00654    if (opt == PL_MAIN_READLINE_OPT_READSTRING)
00655      return TRUE;
00656 
00657    // Update the navigator with the path of play list file, because the path is relatif at this one
00658    nav_copy( id_nav );
00659    nav_select( id_nav );
00660    // Go to the path included in the line
00661    if( !nav_setcwd( (FS_STRING) *sz_path , FALSE, FALSE ) )
00662    {
00663       // path no found then path is dead -> reset list to deselect a file
00664       nav_filelist_reset();
00665    }
00666    nav_select( FS_NAV_ID_PLAYLIST );
00667 
00668    return TRUE;
00669 }

Bool pl_main_save ( void   ) 

This function saves the play list file.

Returns:
FALSE in case of error, see global value "fs_g_status" for more detail

TRUE otherwise

Definition at line 236 of file play_list.c.

References copyfile_index, file_close(), nav_file_del(), nav_get(), nav_getindex(), nav_gotoindex(), nav_select(), pl_g_list_is_modify, pl_g_list_is_open, pl_g_list_undo, pl_g_u16_list_sel, pl_main_isopen(), pl_main_open(), and pl_nav_setpos().

00237 {
00238    _MEM_TYPE_SLOW_ Fs_index index;
00239    U8 nav_id_save;
00240    U16 u16_pos;
00241 
00242    // Check if the play list file is opened and modified
00243    if( !pl_main_isopen() )
00244       return FALSE;
00245    if( !pl_g_list_is_modify )
00246       return TRUE;
00247    pl_g_list_is_modify = FALSE;
00248 
00249    // Check if a undo file exists
00250    if( !pl_g_list_undo )
00251       return TRUE;
00252 
00253    // Remove original copy of play list file
00254    nav_id_save = nav_get();
00255    nav_select( FS_NAV_ID_PLAYLIST );
00256    u16_pos = pl_g_u16_list_sel;           // Save position in play list
00257    file_close();                          // Close list
00258    index = nav_getindex();                // Save the pointer on play list file
00259    pl_g_list_is_open = FALSE;
00260    if( nav_gotoindex( &copyfile_index ) ) // Go to the copy of file
00261       nav_file_del( TRUE );               // Remove the copy
00262    nav_gotoindex( &index );               // Re select play list file
00263    pl_main_open( TRUE );                  // Re open play list file
00264    pl_nav_setpos(u16_pos);                // Restort position in play list
00265    nav_select( nav_id_save );
00266 
00267    return TRUE;
00268 }

Bool pl_nav_eol ( void   ) 

This function checks the end of the play list.

Returns:
TRUE if the position is the last file of the play list

Definition at line 435 of file play_list.c.

References pl_g_u16_list_sel, and pl_g_u16_list_size.

00436 {
00437    return (pl_g_u16_list_size == pl_g_u16_list_sel);
00438 }

U16 pl_nav_getnbfile ( void   ) 

Return the number of files in play list.

Returns:
number of files in play list

Definition at line 416 of file play_list.c.

References pl_g_u16_list_size.

Referenced by navauto_mov_playlist(), and navauto_open().

00417 {
00418   return pl_g_u16_list_size;
00419 }

U16 pl_nav_getpos ( void   ) 

Return the position in the play list.

Returns:
position in the play list

Definition at line 426 of file play_list.c.

References pl_g_u16_list_sel.

Referenced by navauto_mov_playlist().

00427 {
00428    return pl_g_u16_list_sel;
00429 }

Bool pl_nav_readentry ( U16  u16_position,
FS_STRING sz_path,
U16 *  u16_size_line 
)

This function read the playliost's entry at a specific position.

Parameters:
u16_position Position in play list.
sz_path The address of the string where is stored the information.
u16_size_line The length of the path.

Definition at line 502 of file play_list.c.

References file_eof(), file_getpos(), file_seek(), FS_ERR_PL_OUT_LST, fs_g_status, FS_SEEK_SET, nav_get(), nav_select(), pl_g_u16_list_sel, pl_g_u16_list_size, pl_main_readline(), PL_MAIN_READLINE_OPT_CHECKLINE, PL_MAIN_READLINE_OPT_GOTOPATH, and reader_txt_beg().

00503 {
00504   U8 nav_id_save;
00505   U16 u16_current_pos;
00506   U32 u32_file_pos;
00507 
00508   // Set output to NULL to specify if there is an error
00509   *sz_path = NULL;
00510 
00511   // Position out of range
00512   if ((0 == u16_position)
00513    || (pl_g_u16_list_size < u16_position))
00514   {
00515      fs_g_status = FS_ERR_PL_OUT_LST;
00516      return FALSE;
00517   }
00518 
00519   // Go to play list file navigator
00520   nav_id_save = nav_get();
00521   nav_select(FS_NAV_ID_PLAYLIST);
00522 
00523   // Save current file position
00524   u32_file_pos = file_getpos();
00525 
00526   if (pl_g_u16_list_sel > u16_position)
00527   {
00528     // Go to the beginning of the text file
00529     reader_txt_beg();
00530     u16_current_pos = 0;
00531   }
00532   else
00533   {
00534     u16_current_pos = pl_g_u16_list_sel;
00535   }
00536 
00537   while(u16_current_pos != u16_position)
00538   {
00539     if (file_eof())
00540     {
00541       // Restore file position
00542       file_seek(u32_file_pos, FS_SEEK_SET);
00543       // Reselect the previous navigator
00544       nav_select(nav_id_save);
00545       return FALSE;
00546     }
00547     if (u16_current_pos+1 == u16_position)
00548     {
00549       if (pl_main_readline(PL_MAIN_READLINE_OPT_GOTOPATH, nav_id_save, sz_path, u16_size_line))
00550         break;
00551     }
00552     else if (pl_main_readline(PL_MAIN_READLINE_OPT_CHECKLINE, 0, NULL, NULL))
00553       u16_current_pos++; // Add a file
00554   }
00555 
00556   // Restore file position
00557   file_seek(u32_file_pos, FS_SEEK_SET);
00558   // Reselect the previous navigator
00559   nav_select(nav_id_save);
00560 
00561   return TRUE;
00562 }

Bool pl_nav_setpos ( U16  u16_position  ) 

This function goes to a position in the play list.

Parameters:
u16_position position in play list to go

Definition at line 444 of file play_list.c.

References file_eof(), FS_ERR_PL_OUT_LST, fs_g_status, nav_filelist_reset(), nav_get(), nav_select(), pl_g_u16_list_sel, pl_g_u16_list_size, pl_main_readline(), PL_MAIN_READLINE_OPT_CHECKLINE, PL_MAIN_READLINE_OPT_GOTOPATH, and reader_txt_beg().

Referenced by navauto_mov_playlist(), navauto_open(), pl_main_modify(), pl_main_save(), and pl_rem_dead().

00445 {
00446    U8 nav_id_save;
00447 
00448    if( (0 == u16_position )
00449    ||  (pl_g_u16_list_size < u16_position) )
00450    {
00451       fs_g_status = FS_ERR_PL_OUT_LST;
00452       return FALSE;
00453    }
00454 
00455    if( pl_g_u16_list_sel == u16_position )
00456       return TRUE;
00457 
00458    // Reset previous selection
00459    nav_filelist_reset();
00460 
00461    // Go to play list file navigator
00462    nav_id_save = nav_get();
00463    nav_select( FS_NAV_ID_PLAYLIST );
00464 
00465    if( pl_g_u16_list_sel > u16_position )
00466    {
00467       // Go to at the beginning of text file
00468       reader_txt_beg();
00469       pl_g_u16_list_sel    = 0;
00470    }
00471    while( pl_g_u16_list_sel != u16_position )
00472    {
00473       FS_STRING sz_path;
00474       Bool next_pos = FALSE;
00475 
00476       if( 0 != file_eof() )
00477       {
00478          nav_select( nav_id_save ); // Re select the previous navigator
00479          return FALSE;
00480       }
00481       if (pl_g_u16_list_sel+1 == u16_position)
00482       {
00483         next_pos = pl_main_readline(PL_MAIN_READLINE_OPT_GOTOPATH, nav_id_save, &sz_path, NULL);
00484         if (sz_path)
00485           PLAYLIST_BUF_FREE(sz_path);
00486       }
00487       else
00488         next_pos = pl_main_readline(PL_MAIN_READLINE_OPT_CHECKLINE, 0, NULL, NULL);
00489       if (next_pos)
00490          pl_g_u16_list_sel++; // Add a file
00491    }
00492    nav_select( nav_id_save ); // Re select the previous navigator
00493    return TRUE;
00494 }

Bool pl_rem_dead ( void   ) 

This function remove the dead file in the list.

Returns:
FALSE in case of error, see global value "fs_g_status" for more detail

TRUE otherwise

Definition at line 893 of file play_list.c.

References nav_get(), nav_gotoindex(), nav_select(), pl_g_u16_list_sel, pl_g_u16_list_size, pl_nav_setpos(), and pl_rem_sel().

00894 {
00895    U8 nav_id_save;
00896 
00897    pl_g_u16_list_sel = 0;
00898 
00899    nav_id_save = nav_get();
00900    nav_select( FS_NAV_ID_PLAYLIST );
00901 
00902    while( pl_g_u16_list_sel < pl_g_u16_list_size )
00903    {
00904       if( nav_gotoindex( &pl_g_list[ pl_g_u16_list_sel ] ))
00905       {
00906          // the file is good -> go to next file in list
00907          pl_g_u16_list_sel++;
00908          continue;
00909       }
00910 
00911       // The file is dead -> remove this one
00912       pl_rem_sel();
00913    }
00914    nav_select( nav_id_save );
00915    pl_nav_setpos(0);
00916 }

Bool pl_rem_sel ( void   ) 

This function removes the selected file in the list.

Returns:
FALSE in case of error, see global value "fs_g_status" for more detail

TRUE otherwise

Definition at line 845 of file play_list.c.

References file_putc(), file_seek(), FS_ERR_PL_OUT_LST, fs_g_status, FS_SEEK_CUR_RE, FS_SEEK_SET, nav_get(), nav_select(), pl_g_u16_list_sel, pl_g_u16_list_size, and pl_main_modify().

Referenced by pl_rem_dead().

00846 {
00847    U8 nav_id_save;
00848    Bool b_status = FALSE;
00849 
00850    if( !pl_main_modify() )
00851       return FALSE;
00852    if( 0 == pl_g_u16_list_sel )
00853    {
00854       fs_g_status = FS_ERR_PL_OUT_LST;
00855       return FALSE;
00856    }
00857    nav_id_save = nav_get();
00858    nav_select( FS_NAV_ID_PLAYLIST );
00859 
00860    // Jump at the beginning of the current path
00861 #if( PL_UNICODE == ENABLED)
00862    file_string_unicode();
00863    if( !file_seek( pl_g_u16_path_size*2 , FS_SEEK_CUR_RE ))
00864       goto pl_rem_sys_err;
00865 #else
00866    if( !file_seek( pl_g_u16_path_size , FS_SEEK_CUR_RE ))
00867       goto pl_rem_sys_err;
00868 #endif
00869 
00870    // Comment the line
00871    if( !file_putc('#'))
00872       goto pl_rem_sys_err;
00873    b_status = TRUE;
00874    pl_g_u16_list_size--;
00875 
00876 pl_rem_sys_err:
00877 #if( PL_UNICODE == ENABLED)
00878     file_string_ascii();
00879 #endif
00880    // Go to beginning of file AND no file selected
00881    file_seek( 0 , FS_SEEK_SET );
00882    pl_g_u16_list_sel = 0;
00883    nav_select( nav_id_save );
00884    return b_status;
00885 }

Bool pl_rem_sel_all ( void   ) 

This function removes all files in the list.

Returns:
FALSE in case of error, see global value "fs_g_status" for more detail

TRUE otherwise

Definition at line 822 of file play_list.c.

References file_seek(), file_set_eof(), FS_SEEK_SET, nav_get(), nav_select(), and pl_main_modify().

00823 {
00824    U8 nav_id_save;
00825    Bool b_status;
00826 
00827    if( !pl_main_modify() )
00828       return FALSE;
00829 
00830    nav_id_save = nav_get();
00831    nav_select( FS_NAV_ID_PLAYLIST );
00832    // Go to beginning of file AND set eof to have a size = 0
00833    file_seek( 0 , FS_SEEK_SET );
00834    b_status = file_set_eof();
00835    nav_select( nav_id_save );
00836    return b_status;
00837 }

Bool pl_sel_isvalid ( void   ) 

This function tests the valid path in list.

Returns:
FALSE = path is not valid in list - DEAD

Definition at line 679 of file play_list.c.

References nav_filelist_validpos(), pl_g_u16_list_sel, and pl_main_isopen().

00680 {
00681    if(!pl_main_isopen())
00682       return FALSE;
00683    if(0 == pl_g_u16_list_sel)
00684       return FALSE;
00685    return nav_filelist_validpos();
00686 }


Generated on Fri Feb 19 02:29:49 2010 for AVR32 UC3 - FSACCESS Services by  doxygen 1.5.5