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"
56 #include "filetypes.h"
61 #include "recorder/recording.h"
69 #include "gwps-common.h"
70 #include "eeprom_settings.h"
71 #include "scrobbler.h"
72 #include "playlist_catalog.h"
76 #include "statusbar.h"
78 #include "buttonbar.h"
80 #include "quickscreen.h"
82 #include "root_menu.h"
85 static const struct filetype
*filetypes
;
86 static int filetypes_count
;
88 struct gui_synclist tree_lists
;
90 /* I put it here because other files doesn't use it yet,
91 * but should be elsewhere since it will be used mostly everywhere */
93 struct gui_buttonbar tree_buttonbar
;
95 static struct tree_context tc
;
97 bool boot_changed
= false;
99 char lastfile
[MAX_PATH
];
100 static char lastdir
[MAX_PATH
];
102 static int lasttable
, lastextra
, lastfirstpos
;
104 static int max_files
= 0;
106 static bool reload_dir
= false;
108 static bool start_wps
= false;
109 static int curr_context
= false;/* id3db or tree*/
111 static int dirbrowse(void);
112 static int ft_play_dirname(char* name
);
113 static void ft_play_filename(char *dir
, char *file
);
114 static void say_filetype(int attr
);
116 static char * tree_get_filename(int selected_item
, void *data
,
117 char *buffer
, size_t buffer_len
)
119 struct tree_context
* local_tc
=(struct tree_context
*)data
;
122 bool stripit
= false;
124 bool id3db
= *(local_tc
->dirfilter
) == SHOW_ID3DB
;
128 return tagtree_get_entry(&tc
, selected_item
)->name
;
133 struct entry
* dc
= local_tc
->dircache
;
134 struct entry
* e
= &dc
[selected_item
];
139 if(!(attr
& ATTR_DIRECTORY
))
141 switch(global_settings
.show_filename_ext
)
144 /* show file extension: off */
148 /* show file extension: on */
151 /* show file extension: only unknown types */
152 stripit
= filetype_supported(attr
);
156 /* show file extension: only when viewing all */
157 stripit
= (*(local_tc
->dirfilter
) != SHOW_ID3DB
) &&
158 (*(local_tc
->dirfilter
) != SHOW_ALL
);
165 return(strip_extension(buffer
, buffer_len
, name
));
170 #ifdef HAVE_LCD_COLOR
171 static int tree_get_filecolor(int selected_item
, void * data
)
173 if (*tc
.dirfilter
== SHOW_ID3DB
)
175 struct tree_context
* local_tc
=(struct tree_context
*)data
;
176 struct entry
* dc
= local_tc
->dircache
;
177 struct entry
* e
= &dc
[selected_item
];
178 return filetype_get_color(e
->name
, e
->attr
);
182 static int tree_get_fileicon(int selected_item
, void * data
)
184 struct tree_context
* local_tc
=(struct tree_context
*)data
;
186 bool id3db
= *(local_tc
->dirfilter
) == SHOW_ID3DB
;
188 return tagtree_get_icon(&tc
);
193 struct entry
* dc
= local_tc
->dircache
;
194 struct entry
* e
= &dc
[selected_item
];
195 return filetype_get_icon(e
->attr
);
199 static int tree_voice_cb(int selected_item
, void * data
)
201 struct tree_context
* local_tc
=(struct tree_context
*)data
;
205 bool id3db
= *(local_tc
->dirfilter
) == SHOW_ID3DB
;
209 attr
= tagtree_get_attr(local_tc
);
210 name
= tagtree_get_entry(local_tc
, selected_item
)->name
;
215 struct entry
* dc
= local_tc
->dircache
;
216 struct entry
* e
= &dc
[selected_item
];
220 bool is_dir
= (attr
& ATTR_DIRECTORY
);
221 bool did_clip
= false;
222 /* First the .talk clip case */
225 if(global_settings
.talk_dir_clip
)
228 if(ft_play_dirname(name
) <0)
229 /* failed, not existing */
232 } else { /* it's a file */
233 if (global_settings
.talk_file_clip
&& (attr
& FILE_ATTR_THUMBNAIL
))
236 ft_play_filename(local_tc
->currdir
, name
);
241 /* say the number or spell if required or as a fallback */
242 switch (is_dir
? global_settings
.talk_dir
: global_settings
.talk_file
)
244 case 1: /* as numbers */
245 talk_id(is_dir
? VOICE_DIR
: VOICE_FILE
, false);
246 talk_number(selected_item
+1 - (is_dir
? 0 : local_tc
->dirsindir
),
248 if(global_settings
.talk_filetype
249 && !is_dir
&& *local_tc
->dirfilter
< NUM_FILTER_MODES
)
252 case 2: /* spelled */
254 if(global_settings
.talk_filetype
)
257 talk_id(VOICE_DIR
, true);
258 else if(*local_tc
->dirfilter
< NUM_FILTER_MODES
)
261 talk_spell(name
, true);
268 bool check_rockboxdir(void)
270 if(!dir_exists(ROCKBOX_DIR
))
271 { /* No need to localise this message.
272 If .rockbox is missing, it wouldn't work anyway */
275 screens
[i
].clear_display();
276 splash(HZ
*2, "No .rockbox directory");
278 screens
[i
].clear_display();
279 splash(HZ
*2, "Installation incomplete");
285 /* do this really late in the init sequence */
286 void tree_gui_init(void)
290 strcpy(tc
.currdir
, "/");
292 #ifdef HAVE_LCD_CHARCELLS
295 screens
[i
].double_height(false);
297 #ifdef HAVE_BUTTONBAR
298 gui_buttonbar_init(&tree_buttonbar
);
299 /* since archos only have one screen, no need to create more than that */
300 gui_buttonbar_set_display(&tree_buttonbar
, &(screens
[SCREEN_MAIN
]) );
302 gui_synclist_init(&tree_lists
, &tree_get_filename
, &tc
, false, 1, NULL
);
303 gui_synclist_set_voice_callback(&tree_lists
, tree_voice_cb
);
304 gui_synclist_set_icon_callback(&tree_lists
, &tree_get_fileicon
);
305 #ifdef HAVE_LCD_COLOR
306 gui_synclist_set_color_callback(&tree_lists
, &tree_get_filecolor
);
312 struct tree_context
* tree_get_context(void)
318 * Returns the position of a given file in the current directory
319 * returns -1 if not found
321 static int tree_get_file_position(char * filename
)
325 /* use lastfile to determine the selected item (default=0) */
326 for (i
=0; i
< tc
.filesindir
; i
++)
328 struct entry
* dc
= tc
.dircache
;
329 struct entry
* e
= &dc
[i
];
330 if (!strcasecmp(e
->name
, filename
))
333 return(-1);/* no file can match, returns undefined */
337 * Called when a new dir is loaded (for example when returning from other apps ...)
338 * also completely redraws the tree
340 static int update_dir(void)
342 bool changed
= false;
344 bool id3db
= *tc
.dirfilter
== SHOW_ID3DB
;
345 /* Checks for changes */
347 if (tc
.currtable
!= lasttable
||
348 tc
.currextra
!= lastextra
||
349 tc
.firstpos
!= lastfirstpos
||
352 if (tagtree_load(&tc
) < 0)
355 lasttable
= tc
.currtable
;
356 lastextra
= tc
.currextra
;
357 lastfirstpos
= tc
.firstpos
;
364 /* if the tc.currdir has been changed, reload it ...*/
365 if (strncmp(tc
.currdir
, lastdir
, sizeof(lastdir
)) || reload_dir
)
367 if (ft_load(&tc
, NULL
) < 0)
369 strcpy(lastdir
, tc
.currdir
);
373 /* if selected item is undefined */
374 if (tc
.selected_item
== -1)
376 /* use lastfile to determine the selected item */
377 tc
.selected_item
= tree_get_file_position(lastfile
);
379 /* If the file doesn't exists, select the first one (default) */
380 if(tc
.selected_item
< 0)
381 tc
.selected_item
= 0;
390 (tc
.dirfull
|| tc
.filesindir
== global_settings
.max_files_in_dir
) )
392 splash(HZ
, ID2P(LANG_SHOWDIR_BUFFER_FULL
));
398 #ifdef HAVE_LCD_BITMAP
399 if (global_settings
.show_path_in_browser
== SHOW_PATH_FULL
400 || global_settings
.show_path_in_browser
== SHOW_PATH_CURRENT
)
402 gui_synclist_set_title(&tree_lists
, tagtree_get_title(&tc
),
403 filetype_get_icon(ATTR_DIRECTORY
));
407 /* Must clear the title as the list is reused */
408 gui_synclist_set_title(&tree_lists
, NULL
, NOICON
);
415 #ifdef HAVE_LCD_BITMAP
416 if (global_settings
.show_path_in_browser
&&
417 *(tc
.dirfilter
) == SHOW_PLUGINS
)
420 if (!strcmp(tc
.currdir
, PLUGIN_GAMES_DIR
))
421 title
= str(LANG_PLUGIN_GAMES
);
422 else if (!strcmp(tc
.currdir
, PLUGIN_APPS_DIR
))
423 title
= str(LANG_PLUGIN_APPS
);
424 else if (!strcmp(tc
.currdir
, PLUGIN_DEMOS_DIR
))
425 title
= str(LANG_PLUGIN_DEMOS
);
426 else title
= str(LANG_PLUGINS
);
427 gui_synclist_set_title(&tree_lists
, title
, Icon_Plugin
);
429 else if (global_settings
.show_path_in_browser
== SHOW_PATH_FULL
)
431 gui_synclist_set_title(&tree_lists
, tc
.currdir
,
432 filetype_get_icon(ATTR_DIRECTORY
));
434 else if (global_settings
.show_path_in_browser
== SHOW_PATH_CURRENT
)
436 char *title
= strrchr(tc
.currdir
, '/') + 1;
439 /* Display "Files" for the root dir */
440 gui_synclist_set_title(&tree_lists
, str(LANG_DIR_BROWSER
),
441 filetype_get_icon(ATTR_DIRECTORY
));
444 gui_synclist_set_title(&tree_lists
, title
,
445 filetype_get_icon(ATTR_DIRECTORY
));
449 /* Must clear the title as the list is reused */
450 gui_synclist_set_title(&tree_lists
, NULL
, NOICON
);
455 gui_synclist_set_nb_items(&tree_lists
, tc
.filesindir
);
456 gui_synclist_set_icon_callback(&tree_lists
, tree_get_fileicon
);
457 if( tc
.selected_item
>= tc
.filesindir
)
458 tc
.selected_item
=tc
.filesindir
-1;
460 gui_synclist_select_item(&tree_lists
, tc
.selected_item
);
461 #ifdef HAVE_BUTTONBAR
462 if (global_settings
.buttonbar
) {
463 if (*tc
.dirfilter
< NUM_FILTER_MODES
)
464 gui_buttonbar_set(&tree_buttonbar
, str(LANG_SYSFONT_DIRBROWSE_F1
),
465 str(LANG_SYSFONT_DIRBROWSE_F2
),
466 str(LANG_SYSFONT_DIRBROWSE_F3
));
468 gui_buttonbar_set(&tree_buttonbar
, "<<<", "", "");
469 gui_buttonbar_draw(&tree_buttonbar
);
472 gui_synclist_draw(&tree_lists
);
473 gui_synclist_speak_item(&tree_lists
);
474 return tc
.filesindir
;
477 /* load tracks from specified directory to resume play */
478 void resume_directory(const char *dir
)
481 bool id3db
= *tc
.dirfilter
== SHOW_ID3DB
;
484 if (ft_load(&tc
, dir
) < 0)
488 ft_build_playlist(&tc
, 0);
496 /* Returns the current working directory and also writes cwd to buf if
497 non-NULL. In case of error, returns NULL. */
498 char *getcwd(char *buf
, int size
)
504 strncpy(buf
, tc
.currdir
, size
);
511 /* Force a reload of the directory next time directory browser is called */
512 void reload_directory(void)
517 void get_current_file(char* buffer
, int buffer_len
)
520 /* in ID3DB mode it is a bad idea to call this function */
521 /* (only happens with `follow playlist') */
522 if( *tc
.dirfilter
== SHOW_ID3DB
)
526 struct entry
* dc
= tc
.dircache
;
527 struct entry
* e
= &dc
[tc
.selected_item
];
528 snprintf(buffer
, buffer_len
, "%s/%s", getcwd(NULL
,0),
529 tc
.dirlength
? e
->name
: "");
532 /* Allow apps to change our dirfilter directly (required for sub browsers)
533 if they're suddenly going to become a file browser for example */
534 void set_dirfilter(int l_dirfilter
)
536 *tc
.dirfilter
= l_dirfilter
;
539 /* Selects a file and update tree context properly */
540 void set_current_file(char *path
)
546 /* in ID3DB mode it is a bad idea to call this function */
547 /* (only happens with `follow playlist') */
548 if( *tc
.dirfilter
== SHOW_ID3DB
)
552 /* separate directory from filename */
553 /* gets the directory's name and put it into tc.currdir */
554 name
= strrchr(path
+1,'/');
558 strcpy(tc
.currdir
, path
);
564 strcpy(tc
.currdir
, "/");
568 strcpy(lastfile
, name
);
571 /* If we changed dir we must recalculate the dirlevel
572 and adjust the selected history properly */
573 if (strncmp(tc
.currdir
,lastdir
,sizeof(lastdir
)))
576 tc
.selected_item_history
[tc
.dirlevel
] = -1;
578 /* use '/' to calculate dirlevel */
579 for (i
= 1; path
[i
] != '\0'; i
++)
584 tc
.selected_item_history
[tc
.dirlevel
] = -1;
588 if (ft_load(&tc
, NULL
) >= 0)
590 tc
.selected_item
= tree_get_file_position(lastfile
);
595 /* main loop, handles key events */
596 static int dirbrowse()
600 int button
, oldbutton
;
601 bool reload_root
= false;
602 int lastfilter
= *tc
.dirfilter
;
603 bool lastsortcase
= global_settings
.sort_case
;
604 bool exit_func
= false;
606 char* currdir
= tc
.currdir
; /* just a shortcut */
608 bool id3db
= *tc
.dirfilter
== SHOW_ID3DB
;
611 curr_context
=CONTEXT_ID3DB
;
614 curr_context
=CONTEXT_TREE
;
615 if (tc
.selected_item
< 0)
616 tc
.selected_item
= 0;
625 numentries
= update_dir();
627 if (numentries
== -1)
628 return GO_TO_PREVIOUS
; /* currdir is not a directory */
630 if (*tc
.dirfilter
> NUM_FILTER_MODES
&& numentries
==0)
632 splash(HZ
*2, ID2P(LANG_NO_FILES
));
633 return GO_TO_PREVIOUS
; /* No files found for rockbox_browser() */
636 gui_synclist_draw(&tree_lists
);
638 struct entry
*dircache
= tc
.dircache
;
639 bool restore
= false;
641 tc
.dirlevel
= 0; /* shouldnt be needed.. this code needs work! */
644 static const char *lines
[]={ID2P(LANG_BOOT_CHANGED
), ID2P(LANG_REBOOT_NOW
)};
645 static const struct text_message message
={lines
, 2};
646 if(gui_syncyesno_run(&message
, NULL
, NULL
)==YESNO_YES
)
647 rolo_load("/" BOOTFILE
);
649 boot_changed
= false;
652 button
= get_action(CONTEXT_TREE
,
653 list_do_action_timeout(&tree_lists
, HZ
/2));
655 gui_synclist_do_button(&tree_lists
, &button
,LIST_WRAP_UNLESS_HELD
);
656 tc
.selected_item
= gui_synclist_get_sel_pos(&tree_lists
);
659 /* nothing to do if no files to display */
660 if ( numentries
== 0 )
664 switch (id3db
?tagtree_enter(&tc
):ft_enter(&tc
))
666 switch (ft_enter(&tc
))
669 case 1: reload_dir
= true; break;
670 case 2: start_wps
= true; break;
671 case 3: exit_func
= true; break;
677 case ACTION_STD_CANCEL
:
678 if (*tc
.dirfilter
> NUM_FILTER_MODES
&& tc
.dirlevel
< 1) {
682 if ((*tc
.dirfilter
== SHOW_ID3DB
&& tc
.dirlevel
== 0) ||
683 ((*tc
.dirfilter
!= SHOW_ID3DB
&& !strcmp(currdir
,"/"))))
685 #ifdef HAVE_LCD_BITMAP /* charcell doesnt have ACTION_TREE_PGLEFT so this isnt needed */
686 if (oldbutton
== ACTION_TREE_PGLEFT
)
698 if (ft_exit(&tc
) == 3)
704 case ACTION_TREE_STOP
:
705 if (list_stop_handler())
709 case ACTION_STD_MENU
:
713 #ifdef HAVE_RECORDING
715 return GO_TO_RECSCREEN
;
718 case ACTION_TREE_WPS
:
719 return GO_TO_PREVIOUS_MUSIC
;
721 #ifdef HAVE_QUICKSCREEN
722 case ACTION_STD_QUICKSCREEN
:
723 /* don't enter f2 from plugin browser */
724 if (*tc
.dirfilter
< NUM_FILTER_MODES
)
726 if (quick_screen_quick(button
))
734 /* don't enter f3 from plugin browser */
735 if (*tc
.dirfilter
< NUM_FILTER_MODES
)
737 if (quick_screen_f3(ACTION_F3
))
744 case ACTION_STD_CONTEXT
:
750 onplay_result
= onplay(NULL
, 0, curr_context
);
755 if (tagtree_get_attr(&tc
) == FILE_ATTR_AUDIO
)
757 attr
= FILE_ATTR_AUDIO
;
758 tagtree_get_filename(&tc
, buf
, sizeof(buf
));
761 attr
= ATTR_DIRECTORY
;
766 attr
= dircache
[tc
.selected_item
].attr
;
768 if (currdir
[1]) /* Not in / */
769 snprintf(buf
, sizeof buf
, "%s/%s",
771 dircache
[tc
.selected_item
].name
);
773 snprintf(buf
, sizeof buf
, "/%s",
774 dircache
[tc
.selected_item
].name
);
776 onplay_result
= onplay(buf
, attr
, curr_context
);
778 switch (onplay_result
)
780 case ONPLAY_MAINMENU
:
787 case ONPLAY_RELOAD_DIR
:
791 case ONPLAY_START_PLAY
:
804 /* The 'dir no longer valid' situation will be caught later
805 * by checking the showdir() result. */
810 if (default_event_handler(button
) == SYS_USB_CONNECTED
)
812 if(*tc
.dirfilter
> NUM_FILTER_MODES
)
813 /* leave sub-browsers after usb, doing otherwise
814 might be confusing to the user */
823 if (button
&& !IS_SYSEVENT(button
))
830 /* do we need to rescan dir? */
831 if (reload_dir
|| reload_root
||
832 lastfilter
!= *tc
.dirfilter
||
833 lastsortcase
!= global_settings
.sort_case
)
836 strcpy(currdir
, "/");
849 gui_synclist_select_item(&tree_lists
, 0);
850 gui_synclist_draw(&tree_lists
);
851 tc
.selected_item
= 0;
855 lastfilter
= *tc
.dirfilter
;
856 lastsortcase
= global_settings
.sort_case
;
861 return GO_TO_PREVIOUS
;
863 if (restore
|| reload_dir
) {
864 /* restore display */
865 numentries
= update_dir();
867 if (currdir
[1] && (numentries
< 0))
868 { /* not in root and reload failed */
869 reload_root
= true; /* try root */
877 bool create_playlist(void)
879 char filename
[MAX_PATH
];
881 snprintf(filename
, sizeof filename
, "%s.m3u8",
882 tc
.currdir
[1] ? tc
.currdir
: "/root");
883 splashf(0, "%s %s", str(LANG_CREATING
), filename
);
886 catalog_add_to_a_playlist(tc
.currdir
, ATTR_DIRECTORY
, true, filename
);
892 int rockbox_browse(const char *root
, int dirfilter
)
895 int *last_filter
= tc
.dirfilter
;
896 tc
.dirfilter
= &dirfilter
;
897 tc
.sort_dir
= global_settings
.sort_dir
;
900 if (dirfilter
>= NUM_FILTER_MODES
)
902 static struct tree_context backup
;
906 tc
.selected_item
= 0;
908 memcpy(tc
.currdir
, root
, sizeof(tc
.currdir
));
910 last_context
= curr_context
;
912 ret_val
= dirbrowse();
914 curr_context
= last_context
;
918 static char buf
[MAX_PATH
];
919 if (dirfilter
!= SHOW_ID3DB
)
920 tc
.dirfilter
= &global_settings
.dirfilter
;
922 set_current_file(buf
);
923 ret_val
= dirbrowse();
925 tc
.dirfilter
= last_filter
;
929 void tree_mem_init(void)
931 /* We copy the settings value in case it is changed by the user. We can't
932 use it until the next reboot. */
933 max_files
= global_settings
.max_files_in_dir
;
935 /* initialize tree context struct */
936 memset(&tc
, 0, sizeof(tc
));
937 tc
.dirfilter
= &global_settings
.dirfilter
;
938 tc
.sort_dir
= global_settings
.sort_dir
;
940 tc
.name_buffer_size
= AVERAGE_FILENAME_LENGTH
* max_files
;
941 tc
.name_buffer
= buffer_alloc(tc
.name_buffer_size
);
943 tc
.dircache_size
= max_files
* sizeof(struct entry
);
944 tc
.dircache
= buffer_alloc(tc
.dircache_size
);
945 tree_get_filetypes(&filetypes
, &filetypes_count
);
948 bool bookmark_play(char *resume_file
, int index
, int offset
, int seed
,
952 char* suffix
= strrchr(resume_file
, '.');
953 bool started
= false;
955 if (suffix
!= NULL
&&
956 (!strcasecmp(suffix
, ".m3u") || !strcasecmp(suffix
, ".m3u8")))
958 /* Playlist playback */
960 /* check that the file exists */
961 if(!file_exists(resume_file
))
964 slash
= strrchr(resume_file
,'/');
974 if (playlist_create(cp
, slash
+1) != -1)
976 if (global_settings
.playlist_shuffle
)
977 playlist_shuffle(seed
, -1);
978 playlist_start(index
,offset
);
986 /* Directory playback */
988 if (playlist_create(resume_file
, NULL
) != -1)
991 resume_directory(resume_file
);
992 if (global_settings
.playlist_shuffle
)
993 playlist_shuffle(seed
, -1);
995 /* Check if the file is at the same spot in the directory,
996 else search for it */
997 peek_filename
= playlist_peek(index
);
999 if (peek_filename
== NULL
)
1002 if (strcmp(strrchr(peek_filename
, '/') + 1, filename
))
1004 for ( i
=0; i
< playlist_amount(); i
++ )
1006 peek_filename
= playlist_peek(i
);
1008 if (peek_filename
== NULL
)
1011 if (!strcmp(strrchr(peek_filename
, '/') + 1, filename
))
1014 if (i
< playlist_amount())
1019 playlist_start(index
,offset
);
1029 static void say_filetype(int attr
)
1031 /* try to find a voice ID for the extension, if known */
1033 attr
&= FILE_ATTR_MASK
; /* file type */
1034 for (j
=0; j
<filetypes_count
; j
++)
1035 if (attr
== filetypes
[j
].tree_attr
)
1037 talk_id(filetypes
[j
].voiceclip
, true);
1042 static int ft_play_dirname(char* name
)
1044 #if CONFIG_CODEC != SWCODEC
1045 if (audio_status() & AUDIO_STATUS_PLAY
)
1049 if(talk_file(tc
.currdir
, name
, dir_thumbnail_name
, NULL
,
1052 if(global_settings
.talk_filetype
)
1053 talk_id(VOICE_DIR
, true);
1060 static void ft_play_filename(char *dir
, char *file
)
1062 #if CONFIG_CODEC != SWCODEC
1063 if (audio_status() & AUDIO_STATUS_PLAY
)
1067 if (strlen(file
) >= strlen(file_thumbnail_ext
)
1068 && strcasecmp(&file
[strlen(file
) - strlen(file_thumbnail_ext
)],
1069 file_thumbnail_ext
))
1070 /* file has no .talk extension */
1071 talk_file(dir
, NULL
, file
, file_thumbnail_ext
,
1074 /* it already is a .talk file, play this directly, but prefix it. */
1075 talk_file(dir
, NULL
, file
, NULL
,
1076 TALK_IDARRAY(LANG_VOICE_DIR_HOVER
), false);
1079 /* These two functions are called by the USB and shutdown handlers */
1080 void tree_flush(void)
1082 #ifdef HAVE_TAGCACHE
1083 tagcache_shutdown();
1086 #ifdef HAVE_TC_RAMCACHE
1087 tagcache_unload_ramcache();
1090 #ifdef HAVE_DIRCACHE
1092 int old_val
= global_status
.dircache_size
;
1093 if (global_settings
.dircache
)
1095 if (!dircache_is_initializing())
1096 global_status
.dircache_size
= dircache_get_cache_size();
1097 # ifdef HAVE_EEPROM_SETTINGS
1098 if (firmware_settings
.initialized
)
1105 global_status
.dircache_size
= 0;
1107 if (old_val
!= global_status
.dircache_size
)
1113 void tree_restore(void)
1115 #ifdef HAVE_EEPROM_SETTINGS
1116 firmware_settings
.disk_clean
= false;
1119 #ifdef HAVE_TC_RAMCACHE
1120 remove(TAGCACHE_STATEFILE
);
1123 #ifdef HAVE_DIRCACHE
1124 remove(DIRCACHE_FILE
);
1125 if (global_settings
.dircache
)
1127 /* Print "Scanning disk..." to the display. */
1128 splash(0, str(LANG_SCANNING_DISK
));
1130 dircache_build(global_status
.dircache_size
);
1133 #ifdef HAVE_TAGCACHE
1134 tagcache_start_scan();