1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Daniel Stenberg
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
26 #include "applimits.h"
31 #include "backlight.h"
55 #include "filetypes.h"
60 #include "recorder/recording.h"
68 #include "gwps-common.h"
69 #include "eeprom_settings.h"
70 #include "playlist_catalog.h"
74 #include "statusbar.h"
76 #include "buttonbar.h"
78 #include "quickscreen.h"
80 #include "root_menu.h"
82 static const struct filetype
*filetypes
;
83 static int filetypes_count
;
85 struct gui_synclist tree_lists
;
87 /* I put it here because other files doesn't use it yet,
88 * but should be elsewhere since it will be used mostly everywhere */
90 struct gui_buttonbar tree_buttonbar
;
92 static struct tree_context tc
;
94 bool boot_changed
= false;
96 char lastfile
[MAX_PATH
];
97 static char lastdir
[MAX_PATH
];
99 static int lasttable
, lastextra
, lastfirstpos
;
101 static int max_files
= 0;
103 static bool reload_dir
= false;
105 static bool start_wps
= false;
106 static int curr_context
= false;/* id3db or tree*/
108 static int dirbrowse(void);
109 static int ft_play_dirname(char* name
);
110 static void ft_play_filename(char *dir
, char *file
);
111 static void say_filetype(int attr
);
113 static char * tree_get_filename(int selected_item
, void *data
,
114 char *buffer
, size_t buffer_len
)
116 struct tree_context
* local_tc
=(struct tree_context
*)data
;
119 bool stripit
= false;
121 bool id3db
= *(local_tc
->dirfilter
) == SHOW_ID3DB
;
125 return tagtree_get_entry(&tc
, selected_item
)->name
;
130 struct entry
* dc
= local_tc
->dircache
;
131 struct entry
* e
= &dc
[selected_item
];
136 if(!(attr
& ATTR_DIRECTORY
))
138 switch(global_settings
.show_filename_ext
)
141 /* show file extension: off */
145 /* show file extension: on */
148 /* show file extension: only unknown types */
149 stripit
= filetype_supported(attr
);
153 /* show file extension: only when viewing all */
154 stripit
= (*(local_tc
->dirfilter
) != SHOW_ID3DB
) &&
155 (*(local_tc
->dirfilter
) != SHOW_ALL
);
162 return(strip_extension(buffer
, buffer_len
, name
));
167 #ifdef HAVE_LCD_COLOR
168 static int tree_get_filecolor(int selected_item
, void * data
)
170 if (*tc
.dirfilter
== SHOW_ID3DB
)
172 struct tree_context
* local_tc
=(struct tree_context
*)data
;
173 struct entry
* dc
= local_tc
->dircache
;
174 struct entry
* e
= &dc
[selected_item
];
175 return filetype_get_color(e
->name
, e
->attr
);
179 static int tree_get_fileicon(int selected_item
, void * data
)
181 struct tree_context
* local_tc
=(struct tree_context
*)data
;
183 bool id3db
= *(local_tc
->dirfilter
) == SHOW_ID3DB
;
185 return tagtree_get_icon(&tc
);
190 struct entry
* dc
= local_tc
->dircache
;
191 struct entry
* e
= &dc
[selected_item
];
192 return filetype_get_icon(e
->attr
);
196 static int tree_voice_cb(int selected_item
, void * data
)
198 struct tree_context
* local_tc
=(struct tree_context
*)data
;
202 bool id3db
= *(local_tc
->dirfilter
) == SHOW_ID3DB
;
206 attr
= tagtree_get_attr(local_tc
);
207 name
= tagtree_get_entry(local_tc
, selected_item
)->name
;
212 struct entry
* dc
= local_tc
->dircache
;
213 struct entry
* e
= &dc
[selected_item
];
217 bool is_dir
= (attr
& ATTR_DIRECTORY
);
218 bool did_clip
= false;
219 /* First the .talk clip case */
222 if(global_settings
.talk_dir_clip
)
225 if(ft_play_dirname(name
) <0)
226 /* failed, not existing */
229 } else { /* it's a file */
230 if (global_settings
.talk_file_clip
&& (attr
& FILE_ATTR_THUMBNAIL
))
233 ft_play_filename(local_tc
->currdir
, name
);
238 /* say the number or spell if required or as a fallback */
239 switch (is_dir
? global_settings
.talk_dir
: global_settings
.talk_file
)
241 case 1: /* as numbers */
242 talk_id(is_dir
? VOICE_DIR
: VOICE_FILE
, false);
243 talk_number(selected_item
+1 - (is_dir
? 0 : local_tc
->dirsindir
),
245 if(global_settings
.talk_filetype
246 && !is_dir
&& *local_tc
->dirfilter
< NUM_FILTER_MODES
)
249 case 2: /* spelled */
251 if(global_settings
.talk_filetype
)
254 talk_id(VOICE_DIR
, true);
255 else if(*local_tc
->dirfilter
< NUM_FILTER_MODES
)
258 talk_spell(name
, true);
265 bool check_rockboxdir(void)
267 if(!dir_exists(ROCKBOX_DIR
))
268 { /* No need to localise this message.
269 If .rockbox is missing, it wouldn't work anyway */
272 screens
[i
].clear_display();
273 splash(HZ
*2, "No .rockbox directory");
275 screens
[i
].clear_display();
276 splash(HZ
*2, "Installation incomplete");
282 /* do this really late in the init sequence */
283 void tree_gui_init(void)
287 strcpy(tc
.currdir
, "/");
289 #ifdef HAVE_LCD_CHARCELLS
292 screens
[i
].double_height(false);
294 #ifdef HAVE_BUTTONBAR
295 gui_buttonbar_init(&tree_buttonbar
);
296 /* since archos only have one screen, no need to create more than that */
297 gui_buttonbar_set_display(&tree_buttonbar
, &(screens
[SCREEN_MAIN
]) );
299 gui_synclist_init(&tree_lists
, &tree_get_filename
, &tc
, false, 1, NULL
);
300 gui_synclist_set_voice_callback(&tree_lists
, tree_voice_cb
);
301 gui_synclist_set_icon_callback(&tree_lists
, &tree_get_fileicon
);
302 #ifdef HAVE_LCD_COLOR
303 gui_synclist_set_color_callback(&tree_lists
, &tree_get_filecolor
);
309 struct tree_context
* tree_get_context(void)
315 * Returns the position of a given file in the current directory
316 * returns -1 if not found
318 static int tree_get_file_position(char * filename
)
322 /* use lastfile to determine the selected item (default=0) */
323 for (i
=0; i
< tc
.filesindir
; i
++)
325 struct entry
* dc
= tc
.dircache
;
326 struct entry
* e
= &dc
[i
];
327 if (!strcasecmp(e
->name
, filename
))
330 return(-1);/* no file can match, returns undefined */
334 * Called when a new dir is loaded (for example when returning from other apps ...)
335 * also completely redraws the tree
337 static int update_dir(void)
339 bool changed
= false;
341 bool id3db
= *tc
.dirfilter
== SHOW_ID3DB
;
342 /* Checks for changes */
344 if (tc
.currtable
!= lasttable
||
345 tc
.currextra
!= lastextra
||
346 tc
.firstpos
!= lastfirstpos
||
349 if (tagtree_load(&tc
) < 0)
352 lasttable
= tc
.currtable
;
353 lastextra
= tc
.currextra
;
354 lastfirstpos
= tc
.firstpos
;
361 /* if the tc.currdir has been changed, reload it ...*/
362 if (strncmp(tc
.currdir
, lastdir
, sizeof(lastdir
)) || reload_dir
)
364 if (ft_load(&tc
, NULL
) < 0)
366 strcpy(lastdir
, tc
.currdir
);
370 /* if selected item is undefined */
371 if (tc
.selected_item
== -1)
373 /* use lastfile to determine the selected item */
374 tc
.selected_item
= tree_get_file_position(lastfile
);
376 /* If the file doesn't exists, select the first one (default) */
377 if(tc
.selected_item
< 0)
378 tc
.selected_item
= 0;
387 (tc
.dirfull
|| tc
.filesindir
== global_settings
.max_files_in_dir
) )
389 splash(HZ
, ID2P(LANG_SHOWDIR_BUFFER_FULL
));
395 #ifdef HAVE_LCD_BITMAP
396 if (global_settings
.show_path_in_browser
== SHOW_PATH_FULL
397 || global_settings
.show_path_in_browser
== SHOW_PATH_CURRENT
)
399 gui_synclist_set_title(&tree_lists
, tagtree_get_title(&tc
),
400 filetype_get_icon(ATTR_DIRECTORY
));
404 /* Must clear the title as the list is reused */
405 gui_synclist_set_title(&tree_lists
, NULL
, NOICON
);
412 #ifdef HAVE_LCD_BITMAP
413 if (global_settings
.show_path_in_browser
&&
414 *(tc
.dirfilter
) == SHOW_PLUGINS
)
417 if (!strcmp(tc
.currdir
, PLUGIN_GAMES_DIR
))
418 title
= str(LANG_PLUGIN_GAMES
);
419 else if (!strcmp(tc
.currdir
, PLUGIN_APPS_DIR
))
420 title
= str(LANG_PLUGIN_APPS
);
421 else if (!strcmp(tc
.currdir
, PLUGIN_DEMOS_DIR
))
422 title
= str(LANG_PLUGIN_DEMOS
);
423 else title
= str(LANG_PLUGINS
);
424 gui_synclist_set_title(&tree_lists
, title
, Icon_Plugin
);
426 else if (global_settings
.show_path_in_browser
== SHOW_PATH_FULL
)
428 gui_synclist_set_title(&tree_lists
, tc
.currdir
,
429 filetype_get_icon(ATTR_DIRECTORY
));
431 else if (global_settings
.show_path_in_browser
== SHOW_PATH_CURRENT
)
433 char *title
= strrchr(tc
.currdir
, '/') + 1;
436 /* Display "Files" for the root dir */
437 gui_synclist_set_title(&tree_lists
, str(LANG_DIR_BROWSER
),
438 filetype_get_icon(ATTR_DIRECTORY
));
441 gui_synclist_set_title(&tree_lists
, title
,
442 filetype_get_icon(ATTR_DIRECTORY
));
446 /* Must clear the title as the list is reused */
447 gui_synclist_set_title(&tree_lists
, NULL
, NOICON
);
452 gui_synclist_set_nb_items(&tree_lists
, tc
.filesindir
);
453 gui_synclist_set_icon_callback(&tree_lists
, tree_get_fileicon
);
454 if( tc
.selected_item
>= tc
.filesindir
)
455 tc
.selected_item
=tc
.filesindir
-1;
457 gui_synclist_select_item(&tree_lists
, tc
.selected_item
);
458 #ifdef HAVE_BUTTONBAR
459 if (global_settings
.buttonbar
) {
460 if (*tc
.dirfilter
< NUM_FILTER_MODES
)
461 gui_buttonbar_set(&tree_buttonbar
, str(LANG_SYSFONT_DIRBROWSE_F1
),
462 str(LANG_SYSFONT_DIRBROWSE_F2
),
463 str(LANG_SYSFONT_DIRBROWSE_F3
));
465 gui_buttonbar_set(&tree_buttonbar
, "<<<", "", "");
466 gui_buttonbar_draw(&tree_buttonbar
);
469 gui_synclist_draw(&tree_lists
);
470 gui_synclist_speak_item(&tree_lists
);
471 return tc
.filesindir
;
474 /* load tracks from specified directory to resume play */
475 void resume_directory(const char *dir
)
477 int dirfilter
= *tc
.dirfilter
;
480 bool id3db
= *tc
.dirfilter
== SHOW_ID3DB
;
482 /* make sure the dirfilter is sane. The only time it should be possible
483 * thats its not is when resume playlist is called from a plugin
488 *tc
.dirfilter
= global_settings
.dirfilter
;
489 ret
= ft_load(&tc
, dir
);
490 *tc
.dirfilter
= dirfilter
;
495 ft_build_playlist(&tc
, 0);
503 /* Returns the current working directory and also writes cwd to buf if
504 non-NULL. In case of error, returns NULL. */
505 char *getcwd(char *buf
, int size
)
511 strncpy(buf
, tc
.currdir
, size
);
518 /* Force a reload of the directory next time directory browser is called */
519 void reload_directory(void)
524 void get_current_file(char* buffer
, int buffer_len
)
527 /* in ID3DB mode it is a bad idea to call this function */
528 /* (only happens with `follow playlist') */
529 if( *tc
.dirfilter
== SHOW_ID3DB
)
533 struct entry
* dc
= tc
.dircache
;
534 struct entry
* e
= &dc
[tc
.selected_item
];
535 snprintf(buffer
, buffer_len
, "%s/%s", getcwd(NULL
,0),
536 tc
.dirlength
? e
->name
: "");
539 /* Allow apps to change our dirfilter directly (required for sub browsers)
540 if they're suddenly going to become a file browser for example */
541 void set_dirfilter(int l_dirfilter
)
543 *tc
.dirfilter
= l_dirfilter
;
546 /* Selects a file and update tree context properly */
547 void set_current_file(char *path
)
553 /* in ID3DB mode it is a bad idea to call this function */
554 /* (only happens with `follow playlist') */
555 if( *tc
.dirfilter
== SHOW_ID3DB
)
559 /* separate directory from filename */
560 /* gets the directory's name and put it into tc.currdir */
561 name
= strrchr(path
+1,'/');
565 strcpy(tc
.currdir
, path
);
571 strcpy(tc
.currdir
, "/");
575 strcpy(lastfile
, name
);
578 /* If we changed dir we must recalculate the dirlevel
579 and adjust the selected history properly */
580 if (strncmp(tc
.currdir
,lastdir
,sizeof(lastdir
)))
583 tc
.selected_item_history
[tc
.dirlevel
] = -1;
585 /* use '/' to calculate dirlevel */
586 for (i
= 1; path
[i
] != '\0'; i
++)
591 tc
.selected_item_history
[tc
.dirlevel
] = -1;
595 if (ft_load(&tc
, NULL
) >= 0)
597 tc
.selected_item
= tree_get_file_position(lastfile
);
602 /* main loop, handles key events */
603 static int dirbrowse()
607 int button
, oldbutton
;
608 bool reload_root
= false;
609 int lastfilter
= *tc
.dirfilter
;
610 bool lastsortcase
= global_settings
.sort_case
;
611 bool exit_func
= false;
613 char* currdir
= tc
.currdir
; /* just a shortcut */
615 bool id3db
= *tc
.dirfilter
== SHOW_ID3DB
;
618 curr_context
=CONTEXT_ID3DB
;
621 curr_context
=CONTEXT_TREE
;
622 if (tc
.selected_item
< 0)
623 tc
.selected_item
= 0;
632 numentries
= update_dir();
634 if (numentries
== -1)
635 return GO_TO_PREVIOUS
; /* currdir is not a directory */
637 if (*tc
.dirfilter
> NUM_FILTER_MODES
&& numentries
==0)
639 splash(HZ
*2, ID2P(LANG_NO_FILES
));
640 return GO_TO_PREVIOUS
; /* No files found for rockbox_browser() */
643 gui_synclist_draw(&tree_lists
);
645 struct entry
*dircache
= tc
.dircache
;
646 bool restore
= false;
648 tc
.dirlevel
= 0; /* shouldnt be needed.. this code needs work! */
651 static const char *lines
[]={ID2P(LANG_BOOT_CHANGED
), ID2P(LANG_REBOOT_NOW
)};
652 static const struct text_message message
={lines
, 2};
653 if(gui_syncyesno_run(&message
, NULL
, NULL
)==YESNO_YES
)
654 rolo_load("/" BOOTFILE
);
656 boot_changed
= false;
659 button
= get_action(CONTEXT_TREE
,
660 list_do_action_timeout(&tree_lists
, HZ
/2));
662 gui_synclist_do_button(&tree_lists
, &button
,LIST_WRAP_UNLESS_HELD
);
663 tc
.selected_item
= gui_synclist_get_sel_pos(&tree_lists
);
666 /* nothing to do if no files to display */
667 if ( numentries
== 0 )
671 switch (id3db
?tagtree_enter(&tc
):ft_enter(&tc
))
673 switch (ft_enter(&tc
))
676 case 1: reload_dir
= true; break;
677 case 2: start_wps
= true; break;
678 case 3: exit_func
= true; break;
684 case ACTION_STD_CANCEL
:
685 if (*tc
.dirfilter
> NUM_FILTER_MODES
&& tc
.dirlevel
< 1) {
689 if ((*tc
.dirfilter
== SHOW_ID3DB
&& tc
.dirlevel
== 0) ||
690 ((*tc
.dirfilter
!= SHOW_ID3DB
&& !strcmp(currdir
,"/"))))
692 #ifdef HAVE_LCD_BITMAP /* charcell doesnt have ACTION_TREE_PGLEFT so this isnt needed */
693 if (oldbutton
== ACTION_TREE_PGLEFT
)
705 if (ft_exit(&tc
) == 3)
711 case ACTION_TREE_STOP
:
712 if (list_stop_handler())
716 case ACTION_STD_MENU
:
720 #ifdef HAVE_RECORDING
722 return GO_TO_RECSCREEN
;
725 case ACTION_TREE_WPS
:
726 return GO_TO_PREVIOUS_MUSIC
;
728 #ifdef HAVE_QUICKSCREEN
729 case ACTION_STD_QUICKSCREEN
:
730 /* don't enter f2 from plugin browser */
731 if (*tc
.dirfilter
< NUM_FILTER_MODES
)
733 if (quick_screen_quick(button
))
741 /* don't enter f3 from plugin browser */
742 if (*tc
.dirfilter
< NUM_FILTER_MODES
)
744 if (quick_screen_f3(ACTION_F3
))
751 case ACTION_STD_CONTEXT
:
757 onplay_result
= onplay(NULL
, 0, curr_context
);
762 if (tagtree_get_attr(&tc
) == FILE_ATTR_AUDIO
)
764 attr
= FILE_ATTR_AUDIO
;
765 tagtree_get_filename(&tc
, buf
, sizeof(buf
));
768 attr
= ATTR_DIRECTORY
;
773 attr
= dircache
[tc
.selected_item
].attr
;
775 if (currdir
[1]) /* Not in / */
776 snprintf(buf
, sizeof buf
, "%s/%s",
778 dircache
[tc
.selected_item
].name
);
780 snprintf(buf
, sizeof buf
, "/%s",
781 dircache
[tc
.selected_item
].name
);
783 onplay_result
= onplay(buf
, attr
, curr_context
);
785 switch (onplay_result
)
787 case ONPLAY_MAINMENU
:
794 case ONPLAY_RELOAD_DIR
:
798 case ONPLAY_START_PLAY
:
811 /* The 'dir no longer valid' situation will be caught later
812 * by checking the showdir() result. */
817 if (default_event_handler(button
) == SYS_USB_CONNECTED
)
819 if(*tc
.dirfilter
> NUM_FILTER_MODES
)
820 /* leave sub-browsers after usb, doing otherwise
821 might be confusing to the user */
830 if (button
&& !IS_SYSEVENT(button
))
837 /* do we need to rescan dir? */
838 if (reload_dir
|| reload_root
||
839 lastfilter
!= *tc
.dirfilter
||
840 lastsortcase
!= global_settings
.sort_case
)
843 strcpy(currdir
, "/");
856 gui_synclist_select_item(&tree_lists
, 0);
857 gui_synclist_draw(&tree_lists
);
858 tc
.selected_item
= 0;
862 lastfilter
= *tc
.dirfilter
;
863 lastsortcase
= global_settings
.sort_case
;
868 return GO_TO_PREVIOUS
;
870 if (restore
|| reload_dir
) {
871 /* restore display */
872 numentries
= update_dir();
874 if (currdir
[1] && (numentries
< 0))
875 { /* not in root and reload failed */
876 reload_root
= true; /* try root */
884 bool create_playlist(void)
886 char filename
[MAX_PATH
];
888 snprintf(filename
, sizeof filename
, "%s.m3u8",
889 tc
.currdir
[1] ? tc
.currdir
: "/root");
890 splashf(0, "%s %s", str(LANG_CREATING
), filename
);
893 catalog_add_to_a_playlist(tc
.currdir
, ATTR_DIRECTORY
, true, filename
);
899 int rockbox_browse(const char *root
, int dirfilter
)
902 int *last_filter
= tc
.dirfilter
;
903 tc
.dirfilter
= &dirfilter
;
904 tc
.sort_dir
= global_settings
.sort_dir
;
907 if (dirfilter
>= NUM_FILTER_MODES
)
909 static struct tree_context backup
;
913 tc
.selected_item
= 0;
915 memcpy(tc
.currdir
, root
, sizeof(tc
.currdir
));
917 last_context
= curr_context
;
919 ret_val
= dirbrowse();
921 curr_context
= last_context
;
925 static char buf
[MAX_PATH
];
926 if (dirfilter
!= SHOW_ID3DB
)
927 tc
.dirfilter
= &global_settings
.dirfilter
;
929 set_current_file(buf
);
930 ret_val
= dirbrowse();
932 tc
.dirfilter
= last_filter
;
936 void tree_mem_init(void)
938 /* We copy the settings value in case it is changed by the user. We can't
939 use it until the next reboot. */
940 max_files
= global_settings
.max_files_in_dir
;
942 /* initialize tree context struct */
943 memset(&tc
, 0, sizeof(tc
));
944 tc
.dirfilter
= &global_settings
.dirfilter
;
945 tc
.sort_dir
= global_settings
.sort_dir
;
947 tc
.name_buffer_size
= AVERAGE_FILENAME_LENGTH
* max_files
;
948 tc
.name_buffer
= buffer_alloc(tc
.name_buffer_size
);
950 tc
.dircache_size
= max_files
* sizeof(struct entry
);
951 tc
.dircache
= buffer_alloc(tc
.dircache_size
);
952 tree_get_filetypes(&filetypes
, &filetypes_count
);
955 bool bookmark_play(char *resume_file
, int index
, int offset
, int seed
,
959 char* suffix
= strrchr(resume_file
, '.');
960 bool started
= false;
962 if (suffix
!= NULL
&&
963 (!strcasecmp(suffix
, ".m3u") || !strcasecmp(suffix
, ".m3u8")))
965 /* Playlist playback */
967 /* check that the file exists */
968 if(!file_exists(resume_file
))
971 slash
= strrchr(resume_file
,'/');
981 if (playlist_create(cp
, slash
+1) != -1)
983 if (global_settings
.playlist_shuffle
)
984 playlist_shuffle(seed
, -1);
985 playlist_start(index
,offset
);
993 /* Directory playback */
995 if (playlist_create(resume_file
, NULL
) != -1)
998 resume_directory(resume_file
);
999 if (global_settings
.playlist_shuffle
)
1000 playlist_shuffle(seed
, -1);
1002 /* Check if the file is at the same spot in the directory,
1003 else search for it */
1004 peek_filename
= playlist_peek(index
);
1006 if (peek_filename
== NULL
)
1009 if (strcmp(strrchr(peek_filename
, '/') + 1, filename
))
1011 for ( i
=0; i
< playlist_amount(); i
++ )
1013 peek_filename
= playlist_peek(i
);
1015 if (peek_filename
== NULL
)
1018 if (!strcmp(strrchr(peek_filename
, '/') + 1, filename
))
1021 if (i
< playlist_amount())
1026 playlist_start(index
,offset
);
1036 static void say_filetype(int attr
)
1038 /* try to find a voice ID for the extension, if known */
1040 attr
&= FILE_ATTR_MASK
; /* file type */
1041 for (j
=0; j
<filetypes_count
; j
++)
1042 if (attr
== filetypes
[j
].tree_attr
)
1044 talk_id(filetypes
[j
].voiceclip
, true);
1049 static int ft_play_dirname(char* name
)
1051 #if CONFIG_CODEC != SWCODEC
1052 if (audio_status() & AUDIO_STATUS_PLAY
)
1056 if(talk_file(tc
.currdir
, name
, dir_thumbnail_name
, NULL
,
1059 if(global_settings
.talk_filetype
)
1060 talk_id(VOICE_DIR
, true);
1067 static void ft_play_filename(char *dir
, char *file
)
1069 #if CONFIG_CODEC != SWCODEC
1070 if (audio_status() & AUDIO_STATUS_PLAY
)
1074 if (strlen(file
) >= strlen(file_thumbnail_ext
)
1075 && strcasecmp(&file
[strlen(file
) - strlen(file_thumbnail_ext
)],
1076 file_thumbnail_ext
))
1077 /* file has no .talk extension */
1078 talk_file(dir
, NULL
, file
, file_thumbnail_ext
,
1081 /* it already is a .talk file, play this directly, but prefix it. */
1082 talk_file(dir
, NULL
, file
, NULL
,
1083 TALK_IDARRAY(LANG_VOICE_DIR_HOVER
), false);
1086 /* These two functions are called by the USB and shutdown handlers */
1087 void tree_flush(void)
1089 #ifdef HAVE_TAGCACHE
1090 tagcache_shutdown();
1093 #ifdef HAVE_TC_RAMCACHE
1094 tagcache_unload_ramcache();
1097 #ifdef HAVE_DIRCACHE
1099 int old_val
= global_status
.dircache_size
;
1100 if (global_settings
.dircache
)
1102 if (!dircache_is_initializing())
1103 global_status
.dircache_size
= dircache_get_cache_size();
1104 # ifdef HAVE_EEPROM_SETTINGS
1105 if (firmware_settings
.initialized
)
1112 global_status
.dircache_size
= 0;
1114 if (old_val
!= global_status
.dircache_size
)
1120 void tree_restore(void)
1122 #ifdef HAVE_EEPROM_SETTINGS
1123 firmware_settings
.disk_clean
= false;
1126 #ifdef HAVE_TC_RAMCACHE
1127 remove(TAGCACHE_STATEFILE
);
1130 #ifdef HAVE_DIRCACHE
1131 remove(DIRCACHE_FILE
);
1132 if (global_settings
.dircache
)
1134 /* Print "Scanning disk..." to the display. */
1135 splash(0, str(LANG_SCANNING_DISK
));
1137 dircache_build(global_status
.dircache_size
);
1140 #ifdef HAVE_TAGCACHE
1141 tagcache_start_scan();