Atmel Software Framework

ai_usb_ms.c File Reference

Audio interface USB Mass Storage Services.

This function should be connected to the audio interface to give access to the mass storage audio player If you use this routines then you don't must use the other FileSystem routine provide in nav_auto.h, navigation.h, file.h, playlist.h

Copyright (c) 2009-2012 Atmel Corporation. All rights reserved.

#include "conf_audio_player.h"
#include "conf_explorer.h"
#include <LIB_CTRLACCESS>
#include <LIB_MEM>
#include "file.h"
#include "navigation.h"
#include "play_list.h"
#include "nav_filterlist.h"
#include "nav_automatic.h"
#include "ai_usb_ms.h"

Data Structures

struct  navigator_context_t
 

Macros

#define EX_RETRY_COUNT   1
 
#define PLAYLIST_FILE_EXT   PL_FILE_EXT
 

Functions

bool ai_usb_ms_audio_context_restore (void *p, ai_async_status_t *cmd_ai_status)
 Restore a audio context (eventualy restart play). More...
 
void * ai_usb_ms_audio_context_save (uint8_t *status, uint16_t *size, ai_async_status_t *cmd_ai_status)
 Give complete audio context (player state, play time, repeat, shuffle, file played, explorer mode ) More...
 
bool ai_usb_ms_audio_ctrl_ffw (uint32_t u32_duration, ai_async_status_t *cmd_ai_status)
 Fast Forward. More...
 
bool ai_usb_ms_audio_ctrl_frw (uint32_t u32_duration, ai_async_status_t *cmd_ai_status)
 Fast Rewind. More...
 
bool ai_usb_ms_audio_ctrl_pause (ai_async_status_t *cmd_ai_status)
 Pause the current audio file. More...
 
bool ai_usb_ms_audio_ctrl_resume (ai_async_status_t *cmd_ai_status)
 Resume the play of the current audio file. More...
 
bool ai_usb_ms_audio_ctrl_start_ffw (ai_async_status_t *cmd_ai_status)
 Start Fast Forward. More...
 
bool ai_usb_ms_audio_ctrl_start_frw (ai_async_status_t *cmd_ai_status)
 Start Fast Rewind. More...
 
Ai_player_flag_t ai_usb_ms_audio_ctrl_status (ai_async_status_t *cmd_ai_status)
 Return the current status of player. More...
 
bool ai_usb_ms_audio_ctrl_stop (ai_async_status_t *cmd_ai_status)
 Stop the player. More...
 
bool ai_usb_ms_audio_ctrl_stop_ffw_frw (ai_async_status_t *cmd_ai_status)
 Stop FastForward/FastRewind. More...
 
uint32_t ai_usb_ms_audio_ctrl_time (ai_async_status_t *cmd_ai_status)
 Return current time played (ms) More...
 
bool ai_usb_ms_audio_nav_eof_occur (ai_async_status_t *cmd_ai_status)
 Start next file. More...
 
Ai_explorer_mode ai_usb_ms_audio_nav_expmode_get (ai_async_status_t *cmd_ai_status)
 This function returns the mode used. More...
 
void ai_usb_ms_audio_nav_expmode_set (Ai_explorer_mode exp_mode, ai_async_status_t *cmd_ai_status)
 This function selects the loop mode. More...
 
uint16_t ai_usb_ms_audio_nav_file_info_album (char **sz_album, ai_async_status_t *cmd_ai_status)
 Return album of current song file selected. More...
 
uint16_t ai_usb_ms_audio_nav_file_info_artist (char **sz_artist, ai_async_status_t *cmd_ai_status)
 Return artist of current song file selected. More...
 
uint32_t ai_usb_ms_audio_nav_file_info_duration (ai_async_status_t *cmd_ai_status)
 Return duration of current song file selected. More...
 
uint16_t ai_usb_ms_audio_nav_file_info_genre (char **sz_genre, ai_async_status_t *cmd_ai_status)
 Return genre of current song file selected. More...
 
void * ai_usb_ms_audio_nav_file_info_image (ai_image_size_t *size, ai_async_status_t *cmd_ai_status)
 Returns a pointer and image information of the embedded image of the selected track. More...
 
uint16_t ai_usb_ms_audio_nav_file_info_title (char **sz_title, ai_async_status_t *cmd_ai_status)
 Return title of current song file selected. More...
 
uint32_t ai_usb_ms_audio_nav_file_info_track (ai_async_status_t *cmd_ai_status)
 Return track of current song file selected. More...
 
uint32_t ai_usb_ms_audio_nav_file_info_type (ai_async_status_t *cmd_ai_status)
 Return the type of the song for the selected file. More...
 
St_ai_info_version ai_usb_ms_audio_nav_file_info_version (ai_async_status_t *cmd_ai_status)
 Return the version of the metadata storage method used for the selected file. More...
 
uint16_t ai_usb_ms_audio_nav_file_info_year (ai_async_status_t *cmd_ai_status)
 Return year of current song file selected. More...
 
uint16_t ai_usb_ms_audio_nav_getname (char **string, ai_async_status_t *cmd_ai_status)
 Get name of current file played. More...
 
uint16_t ai_usb_ms_audio_nav_getpos (ai_async_status_t *cmd_ai_status)
 Give the position of play file. More...
 
static bool ai_usb_ms_audio_nav_mov (bool b_direction, ai_async_status_t *cmd_ai_status)
 Go to previous or next file to play. More...
 
uint16_t ai_usb_ms_audio_nav_nb (ai_async_status_t *cmd_ai_status)
 Number of song file present in current directory played or the number of file present in playlist played. More...
 
bool ai_usb_ms_audio_nav_next (ai_async_status_t *cmd_ai_status)
 Go to next file to play. More...
 
bool ai_usb_ms_audio_nav_playfile (ai_async_status_t *cmd_ai_status)
 Start the play of current file selected in File System navigation. More...
 
bool ai_usb_ms_audio_nav_previous (ai_async_status_t *cmd_ai_status)
 Go to previous file to play. More...
 
Ai_repeat_mode ai_usb_ms_audio_nav_repeat_get (ai_async_status_t *cmd_ai_status)
 Get repeat mode. More...
 
void ai_usb_ms_audio_nav_repeat_set (Ai_repeat_mode repeat_mode, ai_async_status_t *cmd_ai_status)
 Set repeat mode. More...
 
bool ai_usb_ms_audio_nav_setpos (uint16_t u16_pos, ai_async_status_t *cmd_ai_status)
 Set audio navigation at a position. More...
 
Ai_shuffle_mode ai_usb_ms_audio_nav_shuffle_get (ai_async_status_t *cmd_ai_status)
 This function return the shuffle mode used. More...
 
void ai_usb_ms_audio_nav_shuffle_set (Ai_shuffle_mode shuffle, ai_async_status_t *cmd_ai_status)
 This function selects the shuffle mode. More...
 
ai_device_status_t ai_usb_ms_get_device_status (ai_async_status_t *cmd_ai_status)
 Tells if a device is connected or not. More...
 
uint16_t ai_usb_ms_get_product_id (ai_async_status_t *cmd_ai_status)
 Here is the list of the SYNCHRONOUS functions. More...
 
uint16_t ai_usb_ms_get_serial_number (char **sz_sn, ai_async_status_t *cmd_ai_status)
 Return the serial number of the connected USB mass storage device. More...
 
uint16_t ai_usb_ms_get_vendor_id (ai_async_status_t *cmd_ai_status)
 Return the vendor ID of the connected USB mass storage device. More...
 
void ai_usb_ms_init (void)
 Initialize the Mass Storage Audio Interface. More...
 
void ai_usb_ms_init_drive (void)
 
bool ai_usb_ms_nav_dir_cd (ai_async_status_t *cmd_ai_status)
 Enters in the current directory selected in file list filtered. More...
 
bool ai_usb_ms_nav_dir_gotoparent (ai_async_status_t *cmd_ai_status)
 Goes to the parent directory of current directory corresponding at file list filtered. More...
 
uint16_t ai_usb_ms_nav_dir_name (char **string, ai_async_status_t *cmd_ai_status)
 Return the file name of current parent directory. More...
 
uint16_t ai_usb_ms_nav_dir_nb (ai_async_status_t *cmd_ai_status)
 Computes the number of directories in the filtered list. More...
 
bool ai_usb_ms_nav_dir_root (ai_async_status_t *cmd_ai_status)
 Initializes the file list filtered on the root directory. More...
 
uint64_t ai_usb_ms_nav_drive_free_space (ai_async_status_t *cmd_ai_status)
 Get the free space in bytes available on the device. More...
 
uint8_t ai_usb_ms_nav_drive_get (ai_async_status_t *cmd_ai_status)
 Returns the number of the selected drive. More...
 
bool ai_usb_ms_nav_drive_mount (ai_async_status_t *cmd_ai_status)
 Mounts the current drive selected. More...
 
uint8_t ai_usb_ms_nav_drive_nb (ai_async_status_t *cmd_ai_status)
 Return the number of drives. More...
 
bool ai_usb_ms_nav_drive_set (uint8_t u8_number, ai_async_status_t *cmd_ai_status)
 Selects the drive in current navigator but do not mount it. More...
 
uint64_t ai_usb_ms_nav_drive_total_space (ai_async_status_t *cmd_ai_status)
 Get the total space in bytes available on the device. More...
 
bool ai_usb_ms_nav_file_goto (uint32_t u32_newpos, ai_async_status_t *cmd_ai_status)
 Goes to a position in the filtered list. More...
 
uint16_t ai_usb_ms_nav_file_info_album (char **sz_album, ai_async_status_t *cmd_ai_status)
 Return album of current file selected. More...
 
uint16_t ai_usb_ms_nav_file_info_artist (char **sz_artist, ai_async_status_t *cmd_ai_status)
 Return artist of current file selected. More...
 
uint32_t ai_usb_ms_nav_file_info_duration (ai_async_status_t *cmd_ai_status)
 Return duration of current file selected. More...
 
uint16_t ai_usb_ms_nav_file_info_genre (char **sz_genre, ai_async_status_t *cmd_ai_status)
 Return genre of current file selected. More...
 
void * ai_usb_ms_nav_file_info_image (ai_image_size_t *size, ai_async_status_t *cmd_ai_status)
 Returns a pointer and image information of the embedded image of the selected track. More...
 
uint16_t ai_usb_ms_nav_file_info_title (char **sz_title, ai_async_status_t *cmd_ai_status)
 Return title of current file selected. More...
 
uint32_t ai_usb_ms_nav_file_info_track (ai_async_status_t *cmd_ai_status)
 Return track of current file selected. More...
 
uint32_t ai_usb_ms_nav_file_info_type (ai_async_status_t *cmd_ai_status)
 Return the type of the song for the selected file. More...
 
St_ai_info_version ai_usb_ms_nav_file_info_version (ai_async_status_t *cmd_ai_status)
 Return the version of the metadata storage method used for the selected file. More...
 
uint16_t ai_usb_ms_nav_file_info_year (ai_async_status_t *cmd_ai_status)
 Return year of current file selected. More...
 
bool ai_usb_ms_nav_file_isdir (ai_async_status_t *cmd_ai_status)
 Returns the type of the selected file. More...
 
uint16_t ai_usb_ms_nav_file_name (char **string, ai_async_status_t *cmd_ai_status)
 Return the file name of current file selected. More...
 
uint16_t ai_usb_ms_nav_file_nb (ai_async_status_t *cmd_ai_status)
 Computes the number of files in the filtered list. More...
 
bool ai_usb_ms_nav_file_next (ai_async_status_t *cmd_ai_status)
 Goes to the next file of the filtered list. More...
 
uint32_t ai_usb_ms_nav_file_pos (ai_async_status_t *cmd_ai_status)
 Returns the position of selected file in list filtered. More...
 
bool ai_usb_ms_nav_file_previous (ai_async_status_t *cmd_ai_status)
 Goes to the previous file of the filtered list. More...
 
bool ai_usb_ms_nav_getplayfile (ai_async_status_t *cmd_ai_status)
 Position the File system navigation on the file play. More...
 
uint16_t ai_usb_ms_nav_playlist_nb (ai_async_status_t *cmd_ai_status)
 Computes the number of playlists in the filtered list. More...
 
void ai_usb_ms_new_connection (void)
 Routine to notify the Audio Interface of a new device connection. More...
 
bool ai_usb_ms_read_string (bool(*fcnt_read_string)(FS_STRING, uint8_t), char **string, uint16_t *size_string)
 
uint16_t ai_usb_ms_song_read_info (uint16_t(*fcnt_song_read_info)(FS_STRING *, ai_async_status_t *), char **string, ai_async_status_t *cmd_ai_status)
 
static bool ai_usb_ms_specific_async_cmd_task (cmd_ai_id_t cmd_id, uint32_t u32_in, uint16_t *u16_arg_size, char **u8_arg_in, uint32_t *u32_out, uint64_t *u64_out, ai_async_status_t *cmd_ai_status)
 
static bool ai_usb_ms_specific_audio_nav_get_folder_name (char **string, uint8_t u8_size_max, ai_async_status_t *cmd_ai_status)
 
static bool ai_usb_ms_specific_audio_nav_playlist_play_link (uint16_t u16_link_pos, ai_async_status_t *cmd_ai_status)
 Play the link inside the currently selected playlist. More...
 
static uint16_t ai_usb_ms_specific_nav_get_next_playlist_pos (uint16_t u16_start_file_pos, ai_async_status_t *cmd_ai_status)
 Return the next playlist on the current directory. More...
 
static bool ai_usb_ms_specific_nav_getplaylistfile (ai_async_status_t *cmd_ai_status)
 
static void ai_usb_ms_specific_restore_navigator (navigator_context_t *nav_ctx)
 
static bool ai_usb_ms_specific_restore_navigator_ex (uint8_t navigator_id, navigator_context_t **nav_ctx, ai_async_status_t *cmd_ai_status)
 
static void ai_usb_ms_specific_save_navigator (navigator_context_t *nav_ctx)
 
static bool ai_usb_ms_specific_save_navigator_ex (uint8_t navigator_id, navigator_context_t **nav_ctx, ai_async_status_t *cmd_ai_status)
 

Variables

const ai_fct_set ai_usb_ms_fct_set
 
char * ai_usb_ms_filter_file = NULL
 
char * ai_usb_ms_filter_playlist = NULL
 
char * ai_usb_ms_filter_songfile = NULL
 
static bool b_previous_direction = FS_FIND_NEXT
 
struct {
   void(*   clear_play_file_notification )(void)
 
   const char *   file_ext
 
   void(*   init )(void)
 
   bool(*   is_audio_file )(void)
 
   bool(*   is_file_playing )(void)
 
   bool(*   is_metadata_compatible_file )(void)
 
   bool(*   read_metadata_album )(FS_STRING, uint8_t)
 
   bool(*   read_metadata_artist )(FS_STRING, uint8_t)
 
   uint32_t(*   read_metadata_duration )(void)
 
   bool(*   read_metadata_genre )(FS_STRING, uint8_t)
 
   void *(*   read_metadata_image )(ai_image_size_t *)
 
   bool(*   read_metadata_title )(FS_STRING, uint8_t)
 
   uint32_t(*   read_metadata_track )(void)
 
   St_ai_info_version(*   read_metadata_version )(void)
 
   uint16_t(*   read_metadata_year )(void)
 
   void(*   set_play_file_notification )(void)
 
file_format_supported [] = SUPPORTED_FILE_FORMATS
 
bool g_ai_usb_ms_b_audio_file = false
 true if a file is selected in audio navigator More...
 
Ai_repeat_mode g_ai_usb_ms_repeat_mode = AI_DEFAULT_REPEAT_MODE
 repeat mode used More...
 
Ai_shuffle_mode g_ai_usb_ms_shuffle_mode = AI_DEFAULT_SHUFFLE_MODE
 shuffle mode used More...
 
bool g_b_stop_player = false
 
static uint8_t g_Cmd_state
 
uint32_t g_player_currentTime_ms
 
uint32_t g_player_duration
 
Ai_player_flag_t g_player_flag
 
bool g_player_flag_error
 
uint32_t g_player_target_file_pos
 
uint8_t g_smooth_com_cnt
 
uint16_t g_u16_count
 

#define EX_RETRY_COUNT   1
#define PLAYLIST_FILE_EXT   PL_FILE_EXT

Referenced by ai_usb_ms_init().

bool ai_usb_ms_audio_ctrl_ffw ( uint32_t  u32_duration,
ai_async_status_t cmd_ai_status 
)

Fast Forward.

Parameters
u32_durationduration of FFW in seconds
Returns
false in case of error

References CMD_DONE, CMD_ERROR, file_format_supported, i, is_file_playing, PLAYER_FLAG_FFW, and Ai_player_flag_t::status_fast.

Referenced by ai_usb_ms_audio_context_restore(), and ai_usb_ms_audio_ctrl_start_ffw().

bool ai_usb_ms_audio_ctrl_frw ( uint32_t  u32_duration,
ai_async_status_t cmd_ai_status 
)
bool ai_usb_ms_audio_ctrl_start_ffw ( ai_async_status_t cmd_ai_status)

Start Fast Forward.

Returns
false in case of error

References ai_usb_ms_audio_ctrl_ffw().

bool ai_usb_ms_audio_ctrl_start_frw ( ai_async_status_t cmd_ai_status)

Start Fast Rewind.

Returns
false in case of error

References ai_usb_ms_audio_ctrl_frw().

Ai_player_flag_t ai_usb_ms_audio_ctrl_status ( ai_async_status_t cmd_ai_status)

Return the current status of player.

Returns
field of bits (PLAYER_STATUS_PLAY)

References CMD_DONE, CMD_ERROR, fat_check_device(), FS_NAV_ID_FILESYSTEM, nav_select(), Ai_player_flag_t::new_directory, and Ai_player_flag_t::new_file_played.

Referenced by ai_usb_ms_audio_context_save().

bool ai_usb_ms_audio_ctrl_stop_ffw_frw ( ai_async_status_t cmd_ai_status)

Stop FastForward/FastRewind.

Returns
false in case of error

References CMD_ERROR.

uint32_t ai_usb_ms_audio_ctrl_time ( ai_async_status_t cmd_ai_status)

Return current time played (ms)

Returns
current time

References CMD_DONE.

Referenced by ai_usb_ms_audio_context_save(), and ai_usb_ms_audio_ctrl_frw().

Ai_explorer_mode ai_usb_ms_audio_nav_expmode_get ( ai_async_status_t cmd_ai_status)

This function returns the mode used.

Returns
mode used (NAVAUTO_MODE_DISKS, NAVAUTO_MODE_DIRONLY, NAVAUTO_MODE_DIRSUB)

References AUDIO_EXPLORER_MODE_DIRONLY, AUDIO_EXPLORER_MODE_DIRSUB, AUDIO_EXPLORER_MODE_DISK, AUDIO_EXPLORER_MODE_DISKS, CMD_DONE, FS_NAV_ID_AUDIO, nav_select(), navauto_getmode(), NAVAUTO_MODE_DIRONLY, NAVAUTO_MODE_DIRSUB, NAVAUTO_MODE_DISK, and NAVAUTO_MODE_DISKS.

void ai_usb_ms_audio_nav_expmode_set ( Ai_explorer_mode  exp_mode,
ai_async_status_t cmd_ai_status 
)

This function selects the loop mode.

Note
It reinit the folder level at the current position
Parameters
exp_modemode to select (NAVAUTO_MODE_DISKS, NAVAUTO_MODE_DIRONLY, NAVAUTO_MODE_DIRSUB)

References ai_usb_ms_audio_ctrl_resume(), ai_usb_ms_audio_ctrl_stop(), AUDIO_EXPLORER_MODE_DIRONLY, AUDIO_EXPLORER_MODE_DIRSUB, AUDIO_EXPLORER_MODE_DISK, AUDIO_EXPLORER_MODE_DISKS, CMD_DONE, CMD_EXECUTING, FS_NAV_ID_AUDIO, nav_select(), NAVAUTO_MODE_DIRONLY, NAVAUTO_MODE_DIRSUB, NAVAUTO_MODE_DISK, NAVAUTO_MODE_DISKS, navauto_setmode(), PLAYER_FLAG_PAUSE, PLAYER_FLAG_STOP, and Ai_player_flag_t::status.

uint16_t ai_usb_ms_audio_nav_file_info_album ( char **  sz_album,
ai_async_status_t cmd_ai_status 
)

Return album of current song file selected.

Parameters
stringpointer to store the string allocated by the routine
Returns
number of character (unit 2B for UNICODE) allocated

References ai_usb_ms_nav_file_info_album(), and ai_usb_ms_song_read_info().

uint16_t ai_usb_ms_audio_nav_file_info_artist ( char **  sz_artist,
ai_async_status_t cmd_ai_status 
)

Return artist of current song file selected.

Parameters
stringpointer to store the string allocated by the routine
Returns
number of character (unit 2B for UNICODE) allocated

References ai_usb_ms_nav_file_info_artist(), and ai_usb_ms_song_read_info().

uint32_t ai_usb_ms_audio_nav_file_info_duration ( ai_async_status_t cmd_ai_status)

Return duration of current song file selected.

Returns
duration (ms)

References ai_usb_ms_nav_file_info_duration(), CMD_DONE, CMD_ERROR, FS_NAV_ID_AUDIO, FS_NAV_ID_FILESYSTEM, nav_getindex(), nav_gotoindex(), and nav_select().

uint16_t ai_usb_ms_audio_nav_file_info_genre ( char **  sz_genre,
ai_async_status_t cmd_ai_status 
)

Return genre of current song file selected.

Parameters
stringpointer to store the string allocated by the routine
Returns
number of character (unit 2B for UNICODE) allocated

References ai_usb_ms_nav_file_info_genre(), and ai_usb_ms_song_read_info().

void* ai_usb_ms_audio_nav_file_info_image ( ai_image_size_t size,
ai_async_status_t cmd_ai_status 
)

Returns a pointer and image information of the embedded image of the selected track.

Parameters
sizeThe desire width and height of the decoded image.
Returns
pointer on the image data. NULL in case of error.

References CMD_DONE, file_format_supported, FS_NAV_ID_AUDIO, i, is_metadata_compatible_file, nav_select(), NULL, and read_metadata_image.

uint16_t ai_usb_ms_audio_nav_file_info_title ( char **  sz_title,
ai_async_status_t cmd_ai_status 
)

Return title of current song file selected.

Parameters
stringpointer to store the string allocated by the routine
Returns
number of character (unit 2B for UNICODE) allocated

References ai_usb_ms_nav_file_info_title(), and ai_usb_ms_song_read_info().

uint32_t ai_usb_ms_audio_nav_file_info_track ( ai_async_status_t cmd_ai_status)

Return track of current song file selected.

Returns
track number

References ai_usb_ms_nav_file_info_track(), CMD_DONE, CMD_ERROR, FS_NAV_ID_AUDIO, FS_NAV_ID_FILESYSTEM, nav_getindex(), nav_gotoindex(), and nav_select().

uint32_t ai_usb_ms_audio_nav_file_info_type ( ai_async_status_t cmd_ai_status)

Return the type of the song for the selected file.

Returns
Type of file

References AUDIO_TYPE_MP1, AUDIO_TYPE_MP2, AUDIO_TYPE_MP3, AUDIO_TYPE_UNKNOWN, AUDIO_TYPE_WAV, CMD_DONE, FS_NAV_ID_AUDIO, nav_file_checkext(), and nav_select().

St_ai_info_version ai_usb_ms_audio_nav_file_info_version ( ai_async_status_t cmd_ai_status)

Return the version of the metadata storage method used for the selected file.

Returns
Metadata version

References ai_usb_ms_nav_file_info_version(), CMD_DONE, CMD_ERROR, St_ai_info_version::digit, FS_NAV_ID_AUDIO, FS_NAV_ID_FILESYSTEM, St_ai_info_version::major, nav_getindex(), nav_gotoindex(), and nav_select().

uint16_t ai_usb_ms_audio_nav_file_info_year ( ai_async_status_t cmd_ai_status)

Return year of current song file selected.

Returns
year

References ai_usb_ms_nav_file_info_year(), CMD_DONE, CMD_ERROR, FS_NAV_ID_AUDIO, FS_NAV_ID_FILESYSTEM, nav_getindex(), nav_gotoindex(), and nav_select().

uint16_t ai_usb_ms_audio_nav_getname ( char **  string,
ai_async_status_t cmd_ai_status 
)

Get name of current file played.

Parameters
stringbuffer to fill
Returns
size of string, if no 0 then you must free it

References ai_usb_ms_read_string(), CMD_DONE, FS_NAV_ID_AUDIO, nav_file_getname(), and nav_select().

uint16_t ai_usb_ms_audio_nav_getpos ( ai_async_status_t cmd_ai_status)

Give the position of play file.

Returns
1 to nb file in directory or play list

References CMD_DONE, FS_NAV_ID_AUDIO, nav_select(), and navauto_getpos().

uint16_t ai_usb_ms_audio_nav_nb ( ai_async_status_t cmd_ai_status)

Number of song file present in current directory played or the number of file present in playlist played.

Returns
nb file in directory or play list

References CMD_DONE, FS_NAV_ID_AUDIO, nav_select(), and navauto_getnb().

bool ai_usb_ms_audio_nav_next ( ai_async_status_t cmd_ai_status)

Go to next file to play.

Returns
false in case of error

References ai_usb_ms_audio_nav_mov(), and FS_FIND_NEXT.

Referenced by ai_usb_ms_audio_nav_shuffle_set().

bool ai_usb_ms_audio_nav_previous ( ai_async_status_t cmd_ai_status)

Go to previous file to play.

Returns
false in case of error

References ai_usb_ms_audio_nav_mov(), and FS_FIND_PREV.

Ai_repeat_mode ai_usb_ms_audio_nav_repeat_get ( ai_async_status_t cmd_ai_status)

Get repeat mode.

Returns
repeat mode used (AUDIO_REPEAT_OFF, AUDIO_REPEAT_TRACK, AUDIO_REPEAT_FOLDER, AUDIO_REPEAT_ALL)

References CMD_DONE, and g_ai_usb_ms_repeat_mode.

void ai_usb_ms_audio_nav_repeat_set ( Ai_repeat_mode  repeat_mode,
ai_async_status_t cmd_ai_status 
)

Set repeat mode.

Parameters
repeat_moderepeat mode to select (AUDIO_REPEAT_OFF, AUDIO_REPEAT_TRACK, AUDIO_REPEAT_FOLDER, AUDIO_REPEAT_ALL)

References CMD_DONE.

Referenced by ai_usb_ms_audio_context_restore().

bool ai_usb_ms_audio_nav_setpos ( uint16_t  ,
ai_async_status_t cmd_ai_status 
)

Set audio navigation at a position.

Parameters
u16_posposition to set
Returns
false in case of error

References ai_usb_ms_audio_ctrl_resume(), ai_usb_ms_audio_ctrl_stop(), CMD_DONE, CMD_ERROR, CMD_EXECUTING, FS_NAV_ID_AUDIO, nav_select(), navauto_setpos(), PLAYER_FLAG_PAUSE, PLAYER_FLAG_STOP, status, and Ai_player_flag_t::status.

Ai_shuffle_mode ai_usb_ms_audio_nav_shuffle_get ( ai_async_status_t cmd_ai_status)

This function return the shuffle mode used.

Returns
shuffle mode used (AUDIO_SHUFFLE_OFF, AUDIO_SHUFFLE_FOLDER, AUDIO_SHUFFLE_ALL)

References CMD_DONE, FS_NAV_ID_AUDIO, g_ai_usb_ms_shuffle_mode, and nav_select().

void ai_usb_ms_audio_nav_shuffle_set ( Ai_shuffle_mode  shuffle,
ai_async_status_t cmd_ai_status 
)

This function selects the shuffle mode.

Parameters
shuffleshuffle mode to select (AUDIO_SHUFFLE_OFF, AUDIO_SHUFFLE_FOLDER, AUDIO_SHUFFLE_ALL)

References ai_usb_ms_audio_nav_next(), AUDIO_SHUFFLE_ALL, AUDIO_SHUFFLE_FOLDER, AUDIO_SHUFFLE_OFF, CMD_DONE, FS_NAV_ID_AUDIO, nav_select(), NAVAUTO_RAND_OFF, NAVAUTO_RAND_ON, and navauto_setrand().

Referenced by ai_usb_ms_audio_context_restore().

uint16_t ai_usb_ms_get_product_id ( ai_async_status_t cmd_ai_status)

Here is the list of the SYNCHRONOUS functions.

Here is the list of the SYNCHRONOUS functions.Return the product ID of the connected USB mass storage device

Returns
product ID

References CMD_DONE, and Get_PID.

uint16_t ai_usb_ms_get_serial_number ( char **  sz_sn,
ai_async_status_t cmd_ai_status 
)

Return the serial number of the connected USB mass storage device.

Parameters
sz_sna string to store the serial number
Returns
the length in byte of the serial number

References CMD_DONE.

uint16_t ai_usb_ms_get_vendor_id ( ai_async_status_t cmd_ai_status)

Return the vendor ID of the connected USB mass storage device.

Returns
vendor ID

References CMD_DONE, and Get_VID.

void ai_usb_ms_init ( void  )

Initialize the Mass Storage Audio Interface.

Parameters
filter_filelist of the files that will be filtered in the disk navigator.
filter_songfilelist of the audio files that will be filtered in the audio navigator.
filter_filelist of the playlist files that will be filtered in the audio navigator.

References file_ext, file_format_supported, i, NULL, and PLAYLIST_FILE_EXT.

void ai_usb_ms_init_drive ( void  )

Set the file extension filters to the drive

References FS_NAV_ID_FILESYSTEM, nav_filterlist_setfilter(), nav_reset(), nav_select(), and navauto_init().

Referenced by ai_sd_mmc_nav_drive_set(), and ai_usb_ms_nav_drive_set().

bool ai_usb_ms_nav_dir_cd ( ai_async_status_t cmd_ai_status)

Enters in the current directory selected in file list filtered.

@return  false in case of error, see global value "fs_g_status" for more detail
@return  true otherwise
//! After this routine the file list change and contains the files of new current directory,
//! also no file is selected
//! 

References CMD_DONE, CMD_ERROR, FS_NAV_ID_FILESYSTEM, nav_dir_cd(), nav_filterflat_cd(), nav_filterlist_reset(), nav_select(), and status.

bool ai_usb_ms_nav_dir_gotoparent ( ai_async_status_t cmd_ai_status)

Goes to the parent directory of current directory corresponding at file list filtered.

@return  false in case of error, see global value "fs_g_status" for more detail
@return  true otherwise
//! After, the file list change and contains the files of parent directory,
//! also the file selected is the old directory.
//! "Filter list" is a list of files filtered and directories present in current directory
//! 

References CMD_DONE, CMD_ERROR, FS_NAV_ID_FILESYSTEM, nav_filterflat_gotoparent(), nav_filterlist_gotoparent(), nav_select(), and status.

uint16_t ai_usb_ms_nav_dir_name ( char **  string,
ai_async_status_t cmd_ai_status 
)

Return the file name of current parent directory.

Parameters
stringpointer to store the string allocated by the routine
Returns
number of character (unit 2B for UNICODE) allocated

References ai_usb_ms_read_string(), CMD_DONE, FS_NAV_ID_FILESYSTEM, nav_dir_name(), and nav_select().

uint16_t ai_usb_ms_nav_dir_nb ( ai_async_status_t cmd_ai_status)

Computes the number of directories in the filtered list.

@return    number of directories present in list filtered
//! "Filter list" is a list of files filtered and directories present in current directory
//! 

References CMD_DONE, CMD_EXECUTING, EX_RETRY_COUNT, FL_DIR, FS_NAV_ID_FILESYSTEM, g_Cmd_state, g_u16_count, nav_filterlist_nb_ex(), nav_select(), and NULL.

bool ai_usb_ms_nav_dir_root ( ai_async_status_t cmd_ai_status)

Initializes the file list filtered on the root directory.

Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References CMD_DONE, CMD_ERROR, FS_NAV_ID_FILESYSTEM, nav_dir_root(), nav_select(), and status.

uint64_t ai_usb_ms_nav_drive_free_space ( ai_async_status_t cmd_ai_status)

Get the free space in bytes available on the device.

Returns
the free space available on the drive in bytes

References CMD_DONE, FS_NAV_ID_FILESYSTEM, FS_SIZE_OF_SECTOR, nav_partition_freespace(), and nav_select().

uint8_t ai_usb_ms_nav_drive_get ( ai_async_status_t cmd_ai_status)

Returns the number of the selected drive.

Returns
0 to nav_drive_nb()-1
0xFF in case of no drive selected

References CMD_DONE, FS_NAV_ID_FILESYSTEM, MAX_LUN, nav_drive_get(), and nav_select().

bool ai_usb_ms_nav_drive_mount ( ai_async_status_t cmd_ai_status)

Mounts the current drive selected.

@return  false in case of error, see global value "fs_g_status" for more detail
@return  true otherwise
//! If the option FS_MULTI_PARTITION is disable
//! then the mount routine select the first partition supported by file system. <br>
//! After mount, the file list corresponding at the files and directories present in ROOT directory
//! 

References CMD_DONE, CMD_ERROR, FS_NAV_ID_FILESYSTEM, nav_partition_mount(), nav_select(), and status.

uint8_t ai_usb_ms_nav_drive_nb ( ai_async_status_t cmd_ai_status)

Return the number of drives.

Returns
number of drives, 0 = NO DEVICE AVAILABLE

References CMD_DONE, FS_NAV_ID_FILESYSTEM, MAX_LUN, nav_drive_nb(), and nav_select().

bool ai_usb_ms_nav_drive_set ( uint8_t  u8_number,
ai_async_status_t cmd_ai_status 
)

Selects the drive in current navigator but do not mount it.

Parameters
u8_numberdevice number (0 to nav_drive_nb()-1 )
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References ai_usb_ms_init_drive(), CMD_DONE, CMD_ERROR, MAX_LUN, nav_drive_set(), and status.

uint64_t ai_usb_ms_nav_drive_total_space ( ai_async_status_t cmd_ai_status)

Get the total space in bytes available on the device.

Returns
the capacity of the drive in bytes

References CMD_DONE, FS_NAV_ID_FILESYSTEM, FS_SIZE_OF_SECTOR, nav_partition_space(), and nav_select().

bool ai_usb_ms_nav_file_goto ( uint32_t  u32_newpos,
ai_async_status_t cmd_ai_status 
)

Goes to a position in the filtered list.

@param     u16_newpos     new position to select in file list, 0 is the first position

@return    false in case of error, see global value "fs_g_status" for more detail
@return    true otherwise
//! "Filter list" is a list of files filtered and directories present in current directory
//! 

References CMD_DONE, CMD_ERROR, CMD_EXECUTING, FS_NAV_ID_FILESYSTEM, nav_filterflat_goto(), nav_filterlist_goto(), nav_select(), and status.

uint16_t ai_usb_ms_nav_file_info_album ( char **  sz_album,
ai_async_status_t cmd_ai_status 
)

Return album of current file selected.

Parameters
stringpointer to store the string allocated by the routine
Returns
number of character (unit 2B for UNICODE) allocated

References ai_usb_ms_read_string(), CMD_DONE, file_format_supported, FS_NAV_ID_FILESYSTEM, i, is_metadata_compatible_file, nav_select(), and read_metadata_album.

Referenced by ai_usb_ms_audio_nav_file_info_album().

uint16_t ai_usb_ms_nav_file_info_artist ( char **  sz_artist,
ai_async_status_t cmd_ai_status 
)

Return artist of current file selected.

Parameters
stringpointer to store the string allocated by the routine
Returns
number of character (unit 2B for UNICODE) allocated

References ai_usb_ms_read_string(), CMD_DONE, file_format_supported, FS_NAV_ID_FILESYSTEM, i, is_metadata_compatible_file, nav_select(), and read_metadata_artist.

Referenced by ai_usb_ms_audio_nav_file_info_artist().

uint32_t ai_usb_ms_nav_file_info_duration ( ai_async_status_t cmd_ai_status)

Return duration of current file selected.

Returns
duration (ms)

References CMD_DONE, file_format_supported, FS_NAV_ID_FILESYSTEM, i, is_metadata_compatible_file, nav_select(), and read_metadata_duration.

Referenced by ai_usb_ms_audio_nav_file_info_duration().

uint16_t ai_usb_ms_nav_file_info_genre ( char **  sz_genre,
ai_async_status_t cmd_ai_status 
)

Return genre of current file selected.

Parameters
stringpointer to store the string allocated by the routine
Returns
number of character (unit 2B for UNICODE) allocated

References ai_usb_ms_read_string(), CMD_DONE, file_format_supported, FS_NAV_ID_FILESYSTEM, i, is_metadata_compatible_file, nav_select(), and read_metadata_genre.

Referenced by ai_usb_ms_audio_nav_file_info_genre().

void* ai_usb_ms_nav_file_info_image ( ai_image_size_t size,
ai_async_status_t cmd_ai_status 
)

Returns a pointer and image information of the embedded image of the selected track.

Parameters
sizeThe desire width and height of the decoded image.
Returns
pointer on the image data. NULL in case of error.

References CMD_DONE, file_format_supported, FS_NAV_ID_FILESYSTEM, i, is_metadata_compatible_file, nav_select(), NULL, and read_metadata_image.

uint16_t ai_usb_ms_nav_file_info_title ( char **  sz_title,
ai_async_status_t cmd_ai_status 
)

Return title of current file selected.

Parameters
stringpointer to store the string allocated by the routine
Returns
number of character (unit 2B for UNICODE) allocated

References ai_usb_ms_read_string(), CMD_DONE, file_format_supported, FS_NAV_ID_FILESYSTEM, i, is_metadata_compatible_file, nav_select(), and read_metadata_title.

Referenced by ai_usb_ms_audio_nav_file_info_title().

uint32_t ai_usb_ms_nav_file_info_track ( ai_async_status_t cmd_ai_status)

Return track of current file selected.

Returns
track number

References CMD_DONE, file_format_supported, FS_NAV_ID_FILESYSTEM, i, is_metadata_compatible_file, nav_select(), and read_metadata_track.

Referenced by ai_usb_ms_audio_nav_file_info_track().

uint32_t ai_usb_ms_nav_file_info_type ( ai_async_status_t cmd_ai_status)

Return the type of the song for the selected file.

Returns
Type of file

References AUDIO_TYPE_MP1, AUDIO_TYPE_MP2, AUDIO_TYPE_MP3, AUDIO_TYPE_UNKNOWN, AUDIO_TYPE_WAV, CMD_DONE, FS_NAV_ID_FILESYSTEM, nav_file_checkext(), and nav_select().

St_ai_info_version ai_usb_ms_nav_file_info_version ( ai_async_status_t cmd_ai_status)

Return the version of the metadata storage method used for the selected file.

Returns
Metadata version

References CMD_DONE, St_ai_info_version::digit, file_format_supported, FS_NAV_ID_FILESYSTEM, i, is_metadata_compatible_file, St_ai_info_version::major, nav_select(), and read_metadata_version.

Referenced by ai_usb_ms_audio_nav_file_info_version().

uint16_t ai_usb_ms_nav_file_info_year ( ai_async_status_t cmd_ai_status)

Return year of current file selected.

Returns
year

References CMD_DONE, file_format_supported, FS_NAV_ID_FILESYSTEM, i, is_metadata_compatible_file, nav_select(), and read_metadata_year.

Referenced by ai_usb_ms_audio_nav_file_info_year().

bool ai_usb_ms_nav_file_isdir ( ai_async_status_t cmd_ai_status)

Returns the type of the selected file.

Returns
true, it is a directory
false, in other case

References CMD_DONE, FS_NAV_ID_FILESYSTEM, nav_file_isdir(), nav_select(), and status.

uint16_t ai_usb_ms_nav_file_name ( char **  string,
ai_async_status_t cmd_ai_status 
)

Return the file name of current file selected.

Parameters
stringpointer to store the string allocated by the routine
Returns
number of character (unit 2B for UNICODE) allocated

References ai_usb_ms_read_string(), CMD_DONE, FS_NAV_ID_FILESYSTEM, nav_file_getname(), and nav_select().

uint16_t ai_usb_ms_nav_file_nb ( ai_async_status_t cmd_ai_status)

Computes the number of files in the filtered list.

@return    number of files present in list filtered
//! "Filter list" is a list of files filtered and directories present in current directory
//! 

References ai_usb_ms_filter_songfile, CMD_DONE, CMD_EXECUTING, EX_RETRY_COUNT, FL_FILE, FS_NAV_ID_FILESYSTEM, g_Cmd_state, g_u16_count, nav_filterflat_nb(), nav_filterlist_nb_ex(), and nav_select().

bool ai_usb_ms_nav_file_next ( ai_async_status_t cmd_ai_status)

Goes to the next file of the filtered list.

Returns
cmd_out_status - false in case of error, true is success

References CMD_DONE, FS_NAV_ID_FILESYSTEM, nav_filterlist_next(), nav_select(), and status.

uint32_t ai_usb_ms_nav_file_pos ( ai_async_status_t cmd_ai_status)

Returns the position of selected file in list filtered.

@return    position of selected file in current directory, 0 is the first position
@return    FS_NO_SEL, in case of no file selected
//! "Filter list" is a list of files filtered and directories present in current directory
//! 

References CMD_DONE, FS_NAV_ID_FILESYSTEM, nav_filterflat_get(), nav_filterlist_get(), and nav_select().

bool ai_usb_ms_nav_file_previous ( ai_async_status_t cmd_ai_status)

Goes to the previous file of the filtered list.

Returns
cmd_out_status - false in case of error, true is success

References CMD_DONE, FS_NAV_ID_FILESYSTEM, nav_filterlist_previous(), nav_select(), and status.

bool ai_usb_ms_nav_getplayfile ( ai_async_status_t cmd_ai_status)

Position the File system navigation on the file play.

Returns
false in case of error

References CMD_DONE, CMD_ERROR, FS_NAV_ID_AUDIO, FS_NAV_ID_FILESYSTEM, index, nav_dir_root(), nav_filterlist_gotoindex(), nav_getindex(), nav_select(), and status.

uint16_t ai_usb_ms_nav_playlist_nb ( ai_async_status_t cmd_ai_status)

Computes the number of playlists in the filtered list.

@return    number of playlists present in list filtered
//! "Filter list" is a list of files filtered and directories present in current directory
//! 

References CMD_DONE, CMD_EXECUTING, EX_RETRY_COUNT, FL_FILE, FS_NAV_ID_FILESYSTEM, g_Cmd_state, g_u16_count, nav_filterlist_nb_ex(), and nav_select().

void ai_usb_ms_new_connection ( void  )
static bool ai_usb_ms_specific_audio_nav_get_folder_name ( char **  string,
uint8_t  u8_size_max,
ai_async_status_t cmd_ai_status 
)
static
static bool ai_usb_ms_specific_audio_nav_playlist_play_link ( uint16_t  u16_link_pos,
ai_async_status_t cmd_ai_status 
)
static
static uint16_t ai_usb_ms_specific_nav_get_next_playlist_pos ( uint16_t  u16_start_file_pos,
ai_async_status_t cmd_ai_status 
)
static

Return the next playlist on the current directory.

Parameters
u16_start_file_posThe starting file position where to start searching for the next playlist. This value has to be set to ((uint16_t) -1) at the beginning of the list.
Returns
The next playlist position found. If no playlist are found, returns ((uint16_t) -1).
Note
This function does not restore the position of the FILESYSTEM navigator.
This has been done to avoid audio blips.

References CMD_DONE, CMD_ERROR, FS_NAV_ID_FILESYSTEM, nav_file_checkext(), nav_file_isdir(), nav_filterlist_get(), nav_filterlist_goto(), nav_filterlist_next(), and nav_select().

Referenced by ai_usb_ms_specific_async_cmd_task().

static bool ai_usb_ms_specific_nav_getplaylistfile ( ai_async_status_t cmd_ai_status)
static
static bool ai_usb_ms_specific_restore_navigator_ex ( uint8_t  navigator_id,
navigator_context_t **  nav_ctx,
ai_async_status_t cmd_ai_status 
)
static
static bool ai_usb_ms_specific_save_navigator_ex ( uint8_t  navigator_id,
navigator_context_t **  nav_ctx,
ai_async_status_t cmd_ai_status 
)
static

const ai_fct_set ai_usb_ms_fct_set

Referenced by ai_init().

char* ai_usb_ms_filter_file = NULL
char* ai_usb_ms_filter_playlist = NULL
char* ai_usb_ms_filter_songfile = NULL
bool b_previous_direction = FS_FIND_NEXT
static
void(* clear_play_file_notification)(void)
const char* file_ext

Referenced by ai_usb_ms_init().

bool g_ai_usb_ms_b_audio_file = false

true if a file is selected in audio navigator

Referenced by ai_usb_ms_audio_context_save().

Ai_repeat_mode g_ai_usb_ms_repeat_mode = AI_DEFAULT_REPEAT_MODE
Ai_shuffle_mode g_ai_usb_ms_shuffle_mode = AI_DEFAULT_SHUFFLE_MODE
bool g_b_stop_player = false
uint32_t g_player_currentTime_ms

Referenced by header(), and play_wav().

uint32_t g_player_duration

Referenced by header(), and play_wav().

Ai_player_flag_t g_player_flag
bool g_player_flag_error

Referenced by codec_mp3_task(), and codec_wav_task().

uint32_t g_player_target_file_pos

Referenced by header().

uint8_t g_smooth_com_cnt

Referenced by output().

void(* init)(void)
bool(* is_audio_file)(void)
bool(* read_metadata_album)(FS_STRING, uint8_t)
bool(* read_metadata_artist)(FS_STRING, uint8_t)
uint32_t(* read_metadata_duration)(void)
bool(* read_metadata_genre)(FS_STRING, uint8_t)
void*(* read_metadata_image)(ai_image_size_t *)
bool(* read_metadata_title)(FS_STRING, uint8_t)
uint32_t(* read_metadata_track)(void)
St_ai_info_version(* read_metadata_version)(void)
uint16_t(* read_metadata_year)(void)
void(* set_play_file_notification)(void)