Automatic navigation has been developed for the player and viewer. The plug-in provides a specific "file list". The "file list" contains all files included in a playlist or it is built with the following user specifications :
Definition in file nav_automatic.h.
#include "fs_com.h"
#include "fat.h"
#include "navigation.h"
#include "play_list.h"
Go to the source code of this file.
Data Structures | |
union | Navauto_mov_bitfield_status |
struct | Navauto_mov_state |
Structure to store the status from function navauto_mov(). More... | |
Defines | |
Definition of the directory limitations of the file list | |
#define | NAVAUTO_MODE_DIRONLY 2 |
#define | NAVAUTO_MODE_DIRSUB 3 |
#define | NAVAUTO_MODE_DISK 1 |
#define | NAVAUTO_MODE_DISKS 0 |
#define | NAVAUTO_MODE_NB 4 |
Status list of function navauto_mov() | |
#define | NAVAUTO_MOV_DISKERROR 4 |
#define | NAVAUTO_MOV_DISKNOPRESENT 3 |
#define | NAVAUTO_MOV_EMPTY 2 |
#define | NAVAUTO_MOV_OK 0 |
#define | NAVAUTO_MOV_OK_LOOP 1 |
Definition of the random states | |
#define | NAVAUTO_RAND_OFF 0 |
#define | NAVAUTO_RAND_ON 1 |
Typedefs | |
typedef U8 | Navauto_mode |
Structure to store the directory limitation of the file list. | |
typedef U8 | Navauto_rand |
Structure to store the random state. | |
Enumerations | |
enum | navauto_mov_options_t { NAVAUTO_MOV_OPTS_NONE = 0, NAVAUTO_MOV_OPTS_STAY_CURRENT_DIR = 1 } |
Functions | |
U16 | navauto_close (void) |
This function closes the file list. | |
Navauto_mode | navauto_getmode (void) |
This function returns the directory limitation of the file list. | |
U16 | navauto_getnb (void) |
This function returns the file list size. | |
U16 | navauto_getpos (void) |
This function returns the current position in the file list. | |
Navauto_rand | navauto_getrand (void) |
This function returns the random state used. | |
void | navauto_init (const FS_STRING sz_filterext) |
This function initializes the file extension filter used to create the file list. | |
Navauto_mov_state | navauto_mov (Bool b_direction, navauto_mov_options_t options) |
This function jumps to the next or previous file in file list. | |
Bool | navauto_open (Bool b_playlist, U16 pos) |
This function opens a file list at the current position in navigator. | |
Bool | navauto_setmode (Navauto_mode exp_mode) |
This function sets the directory limitation of the file list. | |
Bool | navauto_setpos (U16 u16_pos) |
This function selects a new position in fiel list. | |
void | navauto_setrand (Navauto_rand rand) |
This function changes the random state. |
#define NAVAUTO_MODE_DIRONLY 2 |
Definition at line 65 of file nav_automatic.h.
Referenced by navauto_mov_explorer(), navauto_mov_explorer_is_file(), and navauto_mov_explorer_updir().
#define NAVAUTO_MODE_DIRSUB 3 |
#define NAVAUTO_MODE_DISK 1 |
#define NAVAUTO_MODE_DISKS 0 |
Definition at line 63 of file nav_automatic.h.
Referenced by navauto_mov_explorer_reset(), and navauto_mov_ok_loop().
#define NAVAUTO_MODE_NB 4 |
Definition at line 67 of file nav_automatic.h.
#define NAVAUTO_MOV_DISKERROR 4 |
#define NAVAUTO_MOV_DISKNOPRESENT 3 |
Definition at line 102 of file nav_automatic.h.
#define NAVAUTO_MOV_EMPTY 2 |
Definition at line 101 of file nav_automatic.h.
Referenced by navauto_mov_explorer(), navauto_mov_explorer_is_file(), and navauto_mov_explorer_new_dir().
#define NAVAUTO_MOV_OK 0 |
Definition at line 99 of file nav_automatic.h.
Referenced by navauto_mov_explorer(), navauto_mov_explorer_is_dir(), navauto_mov_explorer_is_file(), navauto_mov_explorer_new_dir(), navauto_mov_playlist(), navauto_open(), and navauto_setpos().
#define NAVAUTO_MOV_OK_LOOP 1 |
Definition at line 100 of file nav_automatic.h.
Referenced by navauto_mov_explorer(), navauto_mov_explorer_is_file(), navauto_mov_ok_loop(), navauto_mov_playlist(), and navauto_open().
#define NAVAUTO_RAND_OFF 0 |
#define NAVAUTO_RAND_ON 1 |
Definition at line 76 of file nav_automatic.h.
Referenced by navauto_mov_explorer(), and navauto_mov_playlist().
typedef U8 Navauto_mode |
Structure to store the directory limitation of the file list.
Definition at line 59 of file nav_automatic.h.
typedef U8 Navauto_rand |
Definition at line 116 of file nav_automatic.h.
00117 { 00118 NAVAUTO_MOV_OPTS_NONE = 0, 00119 NAVAUTO_MOV_OPTS_STAY_CURRENT_DIR = 1 00120 } navauto_mov_options_t;
U16 navauto_close | ( | void | ) |
This function closes the file list.
//! At the end of this routine, the selected file of current navigator is : //! - the play list file (in case of a play list file has been opened) //! - the last selected file (in other case) //!
Definition at line 516 of file nav_automatic.c.
References g_navauto_b_playlist, g_navauto_u16_dir_level, g_navauto_u16_pos, and pl_main_close().
00517 { 00518 if( g_navauto_b_playlist ) 00519 { 00520 pl_main_close(); 00521 return g_navauto_u16_pos; 00522 } 00523 return g_navauto_u16_dir_level; 00524 }
Navauto_mode navauto_getmode | ( | void | ) |
This function returns the directory limitation of the file list.
//! This parameter is ignored then a play list file is selected //!
Definition at line 167 of file nav_automatic.c.
References g_navauto_exp_mode.
00168 { 00169 return g_navauto_exp_mode; 00170 }
U16 navauto_getnb | ( | void | ) |
This function returns the file list size.
Definition at line 529 of file nav_automatic.c.
References g_navauto_u16_nb.
00530 { 00531 return g_navauto_u16_nb; 00532 }
U16 navauto_getpos | ( | void | ) |
This function returns the current position in the file list.
Definition at line 536 of file nav_automatic.c.
References g_navauto_u16_pos.
00537 { 00538 return g_navauto_u16_pos; 00539 }
Navauto_rand navauto_getrand | ( | void | ) |
This function returns the random state used.
Definition at line 200 of file nav_automatic.c.
References g_navauto_rand.
Referenced by navauto_open(), and navauto_setpos().
00201 { 00202 return g_navauto_rand; 00203 }
void navauto_init | ( | const FS_STRING | sz_filterext | ) |
This function initializes the file extension filter used to create the file list.
sz_filterext | file extension filter |
//! This parameter is ignored then a play list file is selected //!
Definition at line 298 of file nav_automatic.c.
References g_navauto_filter, g_navauto_u16_dir_level_root, and g_navauto_u16_nb.
00299 { 00300 g_navauto_filter = sz_filterext; 00301 g_navauto_u16_dir_level_root = 0; 00302 g_navauto_u16_nb = 0; 00303 }
Navauto_mov_state navauto_mov | ( | Bool | b_direction, | |
navauto_mov_options_t | options | |||
) |
This function jumps to the next or previous file in file list.
b_direction | jump direction (FS_FIND_NEXT or FS_FIND_PREV) | |
options | jump direction (FS_FIND_NEXT or FS_FIND_PREV) |
//! When the random is ON, the direction is ignored //!
Definition at line 580 of file nav_automatic.c.
References g_navauto_b_playlist, navauto_mov_explorer(), and navauto_mov_playlist().
Referenced by navauto_open(), and navauto_setpos().
00581 { 00582 if( g_navauto_b_playlist ) 00583 return navauto_mov_playlist( b_direction ); 00584 else 00585 return navauto_mov_explorer( b_direction, options ); 00586 }
Bool navauto_open | ( | Bool | b_playlist, | |
U16 | pos | |||
) |
This function opens a file list at the current position in navigator.
b_playlist | if TRUE then the current selected file is a play list file to open else create a file list with files included in a disk part | |
pos | If b_playlist TRUE, then position in the play list to start else folder level of the current position |
Definition at line 315 of file nav_automatic.c.
References FS_FIND_NEXT, FS_FIND_PREV, g_navauto_b_playlist, g_navauto_filter, g_navauto_u16_dir_level, g_navauto_u16_dir_level_root, g_navauto_u16_nb, g_navauto_u16_pos, nav_dir_gotoparent(), nav_file_checkext(), nav_filelist_reset(), nav_filelist_set(), nav_filelist_validpos(), nav_getindex(), nav_gotoindex(), navauto_getrand(), navauto_mov(), navauto_mov_explorer(), navauto_mov_explorer_reset(), NAVAUTO_MOV_OK, NAVAUTO_MOV_OK_LOOP, NAVAUTO_MOV_OPTS_NONE, navauto_rand_init(), NAVAUTO_RAND_OFF, navauto_setrand(), pl_main_open(), pl_nav_getnbfile(), pl_nav_setpos(), Navauto_mov_state::status, Fs_index::u16_entry_pos_sel_file, Fs_index::u32_cluster_sel_dir, and Fs_index::u8_lun.
Referenced by navauto_setmode().
00316 { 00317 Navauto_mov_state state; 00318 00319 g_navauto_b_playlist = b_playlist; 00320 g_navauto_u16_dir_level_root = 0; 00321 g_navauto_u16_nb = 0; 00322 00323 if( b_playlist ) 00324 { 00325 g_navauto_u16_pos = pos; 00326 if( !pl_main_open(FALSE) ) 00327 return FALSE; 00328 g_navauto_u16_nb = pl_nav_getnbfile(); 00329 if( 0 == g_navauto_u16_nb ) 00330 return FALSE; 00331 if( NAVAUTO_RAND_OFF == navauto_getrand() ) 00332 { 00333 if( pl_nav_setpos( g_navauto_u16_pos )) 00334 { 00335 if( nav_filelist_validpos() ) 00336 return TRUE; 00337 } 00338 }else{ 00339 navauto_rand_init(); 00340 } 00341 // Error position then restart at the beginning 00342 g_navauto_u16_pos = 0; 00343 } 00344 else 00345 { 00346 #if( FS_NAV_AUTOMATIC_NBFILE == ENABLE ) 00347 Fs_index index; 00348 Fs_index index2; 00349 Navauto_rand rand_mode; 00350 U16 u16_current_pos=0; 00351 00352 index.u8_lun = 0xFF; // Reset index (by default no valid selected file) 00353 g_navauto_u16_dir_level = pos; 00354 00355 rand_mode = navauto_getrand(); // Save random mode 00356 navauto_setrand( NAVAUTO_RAND_OFF ); 00357 00358 // If no valid file then found the first valid file 00359 if( !nav_file_checkext( g_navauto_filter )) 00360 { 00361 // Go to previous position because "navauto_mov_explorer()" execute a next before search valid file 00362 if( !nav_filelist_set( 0 , FS_FIND_PREV ) ) 00363 nav_filelist_reset(); 00364 state = navauto_mov_explorer(FS_FIND_NEXT, NAVAUTO_MOV_OPTS_NONE); 00365 if((NAVAUTO_MOV_OK_LOOP != state.status) 00366 && (NAVAUTO_MOV_OK != state.status) ) 00367 { 00368 navauto_setrand(rand_mode); 00369 return FALSE; // List empty 00370 } 00371 } 00372 index = nav_getindex(); 00373 00374 // Compute the size of file list and search the position of selected file 00375 navauto_mov_explorer_reset(); // Go to begining of loop 00376 // Note: the number of file is updated in navauto_mov_explorer() routine when the end of list is detected 00377 00378 while( navauto_mov_explorer( FS_FIND_NEXT, NAVAUTO_MOV_OPTS_NONE ).status == NAVAUTO_MOV_OK ) 00379 { 00380 index2 = nav_getindex(); 00381 // Check the current position with the selected file 00382 if( (index.u8_lun == index2.u8_lun) 00383 && (index.u32_cluster_sel_dir == index2.u32_cluster_sel_dir) 00384 && (index.u16_entry_pos_sel_file == index2.u16_entry_pos_sel_file) ) 00385 { 00386 u16_current_pos = g_navauto_u16_pos; // Save the position number found 00387 g_navauto_u16_dir_level_root = g_navauto_u16_dir_level; 00388 } 00389 } 00390 00391 navauto_setrand(rand_mode); // Restore random mode 00392 if( 0 == g_navauto_u16_nb ) 00393 return FALSE; // loop empty 00394 00395 // Go to a file from file list 00396 if( NAVAUTO_RAND_OFF == navauto_getrand() ) 00397 { 00398 if( 0xFF != index.u8_lun ) 00399 { 00400 // Reselect the file selected at startup 00401 nav_gotoindex( &index ); // Go to this one 00402 g_navauto_u16_dir_level = g_navauto_u16_dir_level_root; // Update position file 00403 g_navauto_u16_pos = u16_current_pos; // Update folder level corresponding at file 00404 } 00405 // Else, the first file is already selected at the end of "compute file list size" loop 00406 return TRUE; 00407 }else{ 00408 navauto_rand_init(); 00409 } 00410 #else 00411 Fs_index index; 00412 Navauto_rand rand_mode; 00413 00414 rand_mode = navauto_getrand(); 00415 navauto_setrand(NAVAUTO_RAND_OFF); 00416 00417 // If no valid file then find the first valid file 00418 if( !nav_file_checkext( g_navauto_filter )) 00419 { 00420 // Go to previous position because "navauto_mov_explorer()" execute a next before search valid file 00421 if( !nav_filelist_set( 0 , FS_FIND_PREV ) ) 00422 nav_filelist_reset(); 00423 state = navauto_mov_explorer(FS_FIND_NEXT, NAVAUTO_MOV_OPTS_NONE); 00424 if((NAVAUTO_MOV_OK_LOOP != state.status) 00425 && (NAVAUTO_MOV_OK != state.status) ) 00426 { 00427 navauto_setrand(rand_mode); 00428 return FALSE; // List empty 00429 } 00430 } 00431 index = nav_getindex(); 00432 00433 navauto_setrand(rand_mode); 00434 00435 navauto_mov_explorer_reset(); 00436 // Compute directory level 00437 g_navauto_u16_dir_level = 0; 00438 while(nav_dir_gotoparent()) 00439 g_navauto_u16_dir_level++; 00440 g_navauto_u16_dir_level_root = g_navauto_u16_dir_level; 00441 //g_navauto_u16_dir_level = pos; 00442 // Restore index 00443 nav_gotoindex(&index); 00444 00445 g_navauto_u16_nb = 0xFFFF; 00446 00447 if( NAVAUTO_RAND_OFF == navauto_getrand() ) 00448 navauto_rand_init(); 00449 00450 if( nav_file_checkext( g_navauto_filter )) 00451 { 00452 // Valid file then update position with the first position but it is not the first ! 00453 g_navauto_u16_pos = 1; 00454 return TRUE; 00455 } 00456 #endif 00457 } 00458 // Find first file or use the random feature 00459 state = navauto_mov(FS_FIND_NEXT, NAVAUTO_MOV_OPTS_NONE); 00460 if((NAVAUTO_MOV_OK_LOOP != state.status) 00461 && (NAVAUTO_MOV_OK != state.status) ) 00462 return FALSE; // List empty 00463 return TRUE; 00464 }
Bool navauto_setmode | ( | Navauto_mode | exp_mode | ) |
This function sets the directory limitation of the file list.
exp_mode | mode to select (NAVAUTO_MODE_DISKS, NAVAUTO_MODE_DIRONLY, NAVAUTO_MODE_DIRSUB) |
FALSE, mode can't be changed (note: the selected file must be close)
//! This parameter is ignored then a play list file is selected //! When the mode change, the folder level is reseted at the current position. //!
Definition at line 185 of file nav_automatic.c.
References g_navauto_b_playlist, g_navauto_exp_mode, and navauto_open().
00186 { 00187 if( g_navauto_exp_mode == exp_mode ) 00188 return TRUE; 00189 g_navauto_exp_mode = exp_mode; 00190 if( g_navauto_b_playlist ) 00191 return TRUE; 00192 return navauto_open( FALSE , 0 ); // Reopen navigation to recompute the file list size 00193 }
Bool navauto_setpos | ( | U16 | u16_pos | ) |
This function selects a new position in fiel list.
u16_pos | new position to select |
Definition at line 548 of file nav_automatic.c.
References FS_FIND_NEXT, FS_FIND_PREV, g_navauto_u16_pos, navauto_getrand(), navauto_mov(), NAVAUTO_MOV_OK, NAVAUTO_MOV_OPTS_NONE, navauto_setrand(), and Navauto_mov_state::status.
00549 { 00550 Bool b_direction; 00551 Navauto_rand rand_mode; 00552 Navauto_mov_state state; 00553 00554 rand_mode = navauto_getrand(); // Save random mode 00555 state.status = NAVAUTO_MOV_OK; 00556 00557 while( (u16_pos != g_navauto_u16_pos ) ) 00558 { 00559 b_direction = ( u16_pos > g_navauto_u16_pos )? FS_FIND_NEXT : FS_FIND_PREV; 00560 state = navauto_mov( b_direction, NAVAUTO_MOV_OPTS_NONE ); 00561 } 00562 00563 navauto_setrand(rand_mode); // Restore random mode 00564 00565 return (NAVAUTO_MOV_OK == state.status); 00566 }
void navauto_setrand | ( | Navauto_rand | rand | ) |
This function changes the random state.
rand | random mode to use |
Definition at line 210 of file nav_automatic.c.
References g_navauto_rand, g_navauto_rand_tab, g_navauto_u16_pos, and navauto_rand_init().
Referenced by navauto_open(), and navauto_setpos().
00211 { 00212 g_navauto_rand = rand; 00213 navauto_rand_init(); 00214 // If current file in rand table 00215 if( g_navauto_u16_pos <= (NAVAUTO_MAX_RANGE_RAND*8) ) 00216 { 00217 // Set current position in rand table 00218 U8 u8_pos_rand = g_navauto_u16_pos-1; 00219 g_navauto_rand_tab[u8_pos_rand/8] |= 1<<(u8_pos_rand%8); 00220 } 00221 }