1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Daniel Stenberg
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
24 #include "applimits.h"
29 #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
)
227 DEBUGF("Playing directory thumbnail: %s", local_tc
->currdir
);
229 if(ft_play_dirname(name
) <0)
230 /* failed, not existing */
233 } else { /* it's a file */
234 if (global_settings
.talk_file_clip
&& (attr
& FILE_ATTR_THUMBNAIL
))
237 DEBUGF("Playing file thumbnail: %s/%s%s\n",
238 local_tc
->currdir
, name
, file_thumbnail_ext
);
239 ft_play_filename(local_tc
->currdir
, name
);
244 /* say the number or spell if required or as a fallback */
245 switch (is_dir
? global_settings
.talk_dir
: global_settings
.talk_file
)
247 case 1: /* as numbers */
248 talk_id(is_dir
? VOICE_DIR
: VOICE_FILE
, false);
249 talk_number(selected_item
+1 - (is_dir
? 0 : local_tc
->dirsindir
),
251 if(global_settings
.talk_filetype
252 && !is_dir
&& *local_tc
->dirfilter
< NUM_FILTER_MODES
)
255 case 2: /* spelled */
257 if(global_settings
.talk_filetype
)
260 talk_id(VOICE_DIR
, true);
261 else if(*local_tc
->dirfilter
< NUM_FILTER_MODES
)
264 talk_spell(name
, true);
271 bool check_rockboxdir(void)
273 if(!dir_exists(ROCKBOX_DIR
))
274 { /* No need to localise this message.
275 If .rockbox is missing, it wouldn't work anyway */
278 screens
[i
].clear_display();
279 gui_syncsplash(HZ
*2, "No .rockbox directory");
281 screens
[i
].clear_display();
282 gui_syncsplash(HZ
*2, "Installation incomplete");
288 /* do this really late in the init sequence */
289 void tree_gui_init(void)
291 gui_sync_wps_screen_init();
295 strcpy(tc
.currdir
, "/");
297 #ifdef HAVE_LCD_CHARCELLS
300 screens
[i
].double_height(false);
302 #ifdef HAVE_BUTTONBAR
303 gui_buttonbar_init(&tree_buttonbar
);
304 /* since archos only have one screen, no need to create more than that */
305 gui_buttonbar_set_display(&tree_buttonbar
, &(screens
[SCREEN_MAIN
]) );
307 gui_synclist_init(&tree_lists
, &tree_get_filename
, &tc
, false, 1, NULL
);
308 gui_synclist_set_voice_callback(&tree_lists
, tree_voice_cb
);
309 gui_synclist_set_icon_callback(&tree_lists
, &tree_get_fileicon
);
310 #ifdef HAVE_LCD_COLOR
311 gui_synclist_set_color_callback(&tree_lists
, &tree_get_filecolor
);
317 struct tree_context
* tree_get_context(void)
323 * Returns the position of a given file in the current directory
324 * returns -1 if not found
326 static int tree_get_file_position(char * filename
)
330 /* use lastfile to determine the selected item (default=0) */
331 for (i
=0; i
< tc
.filesindir
; i
++)
333 struct entry
* dc
= tc
.dircache
;
334 struct entry
* e
= &dc
[i
];
335 if (!strcasecmp(e
->name
, filename
))
338 return(-1);/* no file can match, returns undefined */
342 * Called when a new dir is loaded (for example when returning from other apps ...)
343 * also completely redraws the tree
345 static int update_dir(void)
347 bool changed
= false;
349 bool id3db
= *tc
.dirfilter
== SHOW_ID3DB
;
350 /* Checks for changes */
352 if (tc
.currtable
!= lasttable
||
353 tc
.currextra
!= lastextra
||
354 tc
.firstpos
!= lastfirstpos
||
357 if (tagtree_load(&tc
) < 0)
360 lasttable
= tc
.currtable
;
361 lastextra
= tc
.currextra
;
362 lastfirstpos
= tc
.firstpos
;
369 /* if the tc.currdir has been changed, reload it ...*/
370 if (strncmp(tc
.currdir
, lastdir
, sizeof(lastdir
)) || reload_dir
)
372 if (ft_load(&tc
, NULL
) < 0)
374 strcpy(lastdir
, tc
.currdir
);
378 /* if selected item is undefined */
379 if (tc
.selected_item
== -1)
381 /* use lastfile to determine the selected item */
382 tc
.selected_item
= tree_get_file_position(lastfile
);
384 /* If the file doesn't exists, select the first one (default) */
385 if(tc
.selected_item
< 0)
386 tc
.selected_item
= 0;
395 (tc
.dirfull
|| tc
.filesindir
== global_settings
.max_files_in_dir
) )
397 gui_syncsplash(HZ
, ID2P(LANG_SHOWDIR_BUFFER_FULL
));
403 #ifdef HAVE_LCD_BITMAP
404 if (global_settings
.show_path_in_browser
== SHOW_PATH_FULL
405 || global_settings
.show_path_in_browser
== SHOW_PATH_CURRENT
)
407 gui_synclist_set_title(&tree_lists
, tagtree_get_title(&tc
),
408 filetype_get_icon(ATTR_DIRECTORY
));
412 /* Must clear the title as the list is reused */
413 gui_synclist_set_title(&tree_lists
, NULL
, NOICON
);
420 #ifdef HAVE_LCD_BITMAP
421 if (global_settings
.show_path_in_browser
&&
422 *(tc
.dirfilter
) == SHOW_PLUGINS
)
425 if (!strcmp(tc
.currdir
, PLUGIN_GAMES_DIR
))
426 title
= str(LANG_PLUGIN_GAMES
);
427 else if (!strcmp(tc
.currdir
, PLUGIN_APPS_DIR
))
428 title
= str(LANG_PLUGIN_APPS
);
429 else if (!strcmp(tc
.currdir
, PLUGIN_DEMOS_DIR
))
430 title
= str(LANG_PLUGIN_DEMOS
);
431 else title
= str(LANG_PLUGINS
);
432 gui_synclist_set_title(&tree_lists
, title
, Icon_Plugin
);
434 else if (global_settings
.show_path_in_browser
== SHOW_PATH_FULL
)
436 gui_synclist_set_title(&tree_lists
, tc
.currdir
,
437 filetype_get_icon(ATTR_DIRECTORY
));
439 else if (global_settings
.show_path_in_browser
== SHOW_PATH_CURRENT
)
441 char *title
= strrchr(tc
.currdir
, '/') + 1;
444 /* Display "Files" for the root dir */
445 gui_synclist_set_title(&tree_lists
, str(LANG_DIR_BROWSER
),
446 filetype_get_icon(ATTR_DIRECTORY
));
449 gui_synclist_set_title(&tree_lists
, title
,
450 filetype_get_icon(ATTR_DIRECTORY
));
454 /* Must clear the title as the list is reused */
455 gui_synclist_set_title(&tree_lists
, NULL
, NOICON
);
460 gui_synclist_set_nb_items(&tree_lists
, tc
.filesindir
);
461 gui_synclist_set_icon_callback(&tree_lists
, tree_get_fileicon
);
462 if( tc
.selected_item
>= tc
.filesindir
)
463 tc
.selected_item
=tc
.filesindir
-1;
465 gui_synclist_select_item(&tree_lists
, tc
.selected_item
);
466 #ifdef HAVE_BUTTONBAR
467 if (global_settings
.buttonbar
) {
468 if (*tc
.dirfilter
< NUM_FILTER_MODES
)
469 gui_buttonbar_set(&tree_buttonbar
, str(LANG_SYSFONT_DIRBROWSE_F1
),
470 str(LANG_SYSFONT_DIRBROWSE_F2
),
471 str(LANG_SYSFONT_DIRBROWSE_F3
));
473 gui_buttonbar_set(&tree_buttonbar
, "<<<", "", "");
474 gui_buttonbar_draw(&tree_buttonbar
);
477 gui_synclist_draw(&tree_lists
);
478 gui_synclist_speak_item(&tree_lists
);
479 gui_syncstatusbar_draw(&statusbars
, true);
480 return tc
.filesindir
;
483 /* load tracks from specified directory to resume play */
484 void resume_directory(const char *dir
)
487 bool id3db
= *tc
.dirfilter
== SHOW_ID3DB
;
490 if (ft_load(&tc
, dir
) < 0)
494 ft_build_playlist(&tc
, 0);
502 /* Returns the current working directory and also writes cwd to buf if
503 non-NULL. In case of error, returns NULL. */
504 char *getcwd(char *buf
, int size
)
510 strncpy(buf
, tc
.currdir
, size
);
517 /* Force a reload of the directory next time directory browser is called */
518 void reload_directory(void)
523 void get_current_file(char* buffer
, int buffer_len
)
526 /* in ID3DB mode it is a bad idea to call this function */
527 /* (only happens with `follow playlist') */
528 if( *tc
.dirfilter
== SHOW_ID3DB
)
532 struct entry
* dc
= tc
.dircache
;
533 struct entry
* e
= &dc
[tc
.selected_item
];
534 snprintf(buffer
, buffer_len
, "%s/%s", getcwd(NULL
,0),
535 tc
.dirlength
? e
->name
: "");
538 /* Allow apps to change our dirfilter directly (required for sub browsers)
539 if they're suddenly going to become a file browser for example */
540 void set_dirfilter(int l_dirfilter
)
542 *tc
.dirfilter
= l_dirfilter
;
545 /* Selects a file and update tree context properly */
546 void set_current_file(char *path
)
552 /* in ID3DB mode it is a bad idea to call this function */
553 /* (only happens with `follow playlist') */
554 if( *tc
.dirfilter
== SHOW_ID3DB
)
558 /* separate directory from filename */
559 /* gets the directory's name and put it into tc.currdir */
560 name
= strrchr(path
+1,'/');
564 strcpy(tc
.currdir
, path
);
570 strcpy(tc
.currdir
, "/");
574 strcpy(lastfile
, name
);
577 /* If we changed dir we must recalculate the dirlevel
578 and adjust the selected history properly */
579 if (strncmp(tc
.currdir
,lastdir
,sizeof(lastdir
)))
582 tc
.selected_item_history
[tc
.dirlevel
] = -1;
584 /* use '/' to calculate dirlevel */
585 for (i
= 1; path
[i
] != '\0'; i
++)
590 tc
.selected_item_history
[tc
.dirlevel
] = -1;
594 if (ft_load(&tc
, NULL
) >= 0)
596 tc
.selected_item
= tree_get_file_position(lastfile
);
601 /* main loop, handles key events */
602 static int dirbrowse()
606 unsigned button
, oldbutton
;
607 bool reload_root
= false;
608 int lastfilter
= *tc
.dirfilter
;
609 bool lastsortcase
= global_settings
.sort_case
;
610 bool exit_func
= false;
612 char* currdir
= tc
.currdir
; /* just a shortcut */
614 bool id3db
= *tc
.dirfilter
== SHOW_ID3DB
;
617 curr_context
=CONTEXT_ID3DB
;
620 curr_context
=CONTEXT_TREE
;
621 if (tc
.selected_item
< 0)
622 tc
.selected_item
= 0;
631 numentries
= update_dir();
633 if (numentries
== -1)
634 return GO_TO_PREVIOUS
; /* currdir is not a directory */
636 if (*tc
.dirfilter
> NUM_FILTER_MODES
&& numentries
==0)
638 gui_syncsplash(HZ
*2, ID2P(LANG_NO_FILES
));
639 return GO_TO_PREVIOUS
; /* No files found for rockbox_browser() */
643 struct entry
*dircache
= tc
.dircache
;
644 bool restore
= false;
646 tc
.dirlevel
= 0; /* shouldnt be needed.. this code needs work! */
649 static const char *lines
[]={ID2P(LANG_BOOT_CHANGED
), ID2P(LANG_REBOOT_NOW
)};
650 static const struct text_message message
={lines
, 2};
651 if(gui_syncyesno_run(&message
, NULL
, NULL
)==YESNO_YES
)
652 rolo_load("/" BOOTFILE
);
654 boot_changed
= false;
657 button
= get_action(CONTEXT_TREE
,
658 list_do_action_timeout(&tree_lists
, HZ
/2));
660 gui_synclist_do_button(&tree_lists
, &button
,LIST_WRAP_UNLESS_HELD
);
661 tc
.selected_item
= gui_synclist_get_sel_pos(&tree_lists
);
664 /* nothing to do if no files to display */
665 if ( numentries
== 0 )
669 switch (id3db
?tagtree_enter(&tc
):ft_enter(&tc
))
671 switch (ft_enter(&tc
))
674 case 1: reload_dir
= true; break;
675 case 2: start_wps
= true; break;
676 case 3: exit_func
= true; break;
682 case ACTION_STD_CANCEL
:
683 if (*tc
.dirfilter
> NUM_FILTER_MODES
&& tc
.dirlevel
< 1) {
687 if ((*tc
.dirfilter
== SHOW_ID3DB
&& tc
.dirlevel
== 0) ||
688 ((*tc
.dirfilter
!= SHOW_ID3DB
&& !strcmp(currdir
,"/"))))
690 #ifdef HAVE_LCD_BITMAP /* charcell doesnt have ACTION_TREE_PGLEFT so this isnt needed */
691 if (oldbutton
== ACTION_TREE_PGLEFT
)
703 if (ft_exit(&tc
) == 3)
709 case ACTION_TREE_STOP
:
710 if (list_stop_handler())
714 case ACTION_STD_MENU
:
718 #ifdef HAVE_RECORDING
720 return GO_TO_RECSCREEN
;
723 case ACTION_TREE_WPS
:
724 return GO_TO_PREVIOUS_MUSIC
;
726 #ifdef HAVE_QUICKSCREEN
727 case ACTION_STD_QUICKSCREEN
:
728 /* don't enter f2 from plugin browser */
729 if (*tc
.dirfilter
< NUM_FILTER_MODES
)
731 if (quick_screen_quick(button
))
739 /* don't enter f3 from plugin browser */
740 if (*tc
.dirfilter
< NUM_FILTER_MODES
)
742 if (quick_screen_f3(ACTION_F3
))
749 case ACTION_STD_CONTEXT
:
755 onplay_result
= onplay(NULL
, 0, curr_context
);
760 if (tagtree_get_attr(&tc
) == FILE_ATTR_AUDIO
)
762 attr
= FILE_ATTR_AUDIO
;
763 tagtree_get_filename(&tc
, buf
, sizeof(buf
));
766 attr
= ATTR_DIRECTORY
;
771 attr
= dircache
[tc
.selected_item
].attr
;
773 if (currdir
[1]) /* Not in / */
774 snprintf(buf
, sizeof buf
, "%s/%s",
776 dircache
[tc
.selected_item
].name
);
778 snprintf(buf
, sizeof buf
, "/%s",
779 dircache
[tc
.selected_item
].name
);
781 onplay_result
= onplay(buf
, attr
, curr_context
);
783 switch (onplay_result
)
785 case ONPLAY_MAINMENU
:
792 case ONPLAY_RELOAD_DIR
:
796 case ONPLAY_START_PLAY
:
804 gui_syncstatusbar_draw(&statusbars
, false);
813 /* The 'dir no longer valid' situation will be caught later
814 * by checking the showdir() result. */
819 if (default_event_handler(button
) == SYS_USB_CONNECTED
)
821 if(*tc
.dirfilter
> NUM_FILTER_MODES
)
822 /* leave sub-browsers after usb, doing otherwise
823 might be confusing to the user */
839 /* do we need to rescan dir? */
840 if (reload_dir
|| reload_root
||
841 lastfilter
!= *tc
.dirfilter
||
842 lastsortcase
!= global_settings
.sort_case
)
845 strcpy(currdir
, "/");
858 gui_synclist_select_item(&tree_lists
, 0);
859 gui_synclist_draw(&tree_lists
);
860 tc
.selected_item
= 0;
864 lastfilter
= *tc
.dirfilter
;
865 lastsortcase
= global_settings
.sort_case
;
870 return GO_TO_PREVIOUS
;
872 if (restore
|| reload_dir
) {
873 /* restore display */
874 numentries
= update_dir();
876 if (currdir
[1] && (numentries
< 0))
877 { /* not in root and reload failed */
878 reload_root
= true; /* try root */
886 bool create_playlist(void)
888 char filename
[MAX_PATH
];
890 snprintf(filename
, sizeof filename
, "%s.m3u8",
891 tc
.currdir
[1] ? tc
.currdir
: "/root");
892 gui_syncsplash(0, "%s %s", str(LANG_CREATING
), filename
);
895 catalog_add_to_a_playlist(tc
.currdir
, ATTR_DIRECTORY
, true, filename
);
901 int rockbox_browse(const char *root
, int dirfilter
)
904 int *last_filter
= tc
.dirfilter
;
905 tc
.dirfilter
= &dirfilter
;
908 if (dirfilter
>= NUM_FILTER_MODES
)
910 static struct tree_context backup
;
914 tc
.selected_item
= 0;
916 memcpy(tc
.currdir
, root
, sizeof(tc
.currdir
));
918 last_context
= curr_context
;
920 ret_val
= dirbrowse();
922 curr_context
= last_context
;
926 static char buf
[MAX_PATH
];
927 if (dirfilter
!= SHOW_ID3DB
)
928 tc
.dirfilter
= &global_settings
.dirfilter
;
930 set_current_file(buf
);
931 ret_val
= dirbrowse();
933 tc
.dirfilter
= last_filter
;
937 void tree_mem_init(void)
939 /* We copy the settings value in case it is changed by the user. We can't
940 use it until the next reboot. */
941 max_files
= global_settings
.max_files_in_dir
;
943 /* initialize tree context struct */
944 memset(&tc
, 0, sizeof(tc
));
945 tc
.dirfilter
= &global_settings
.dirfilter
;
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 char dirname_mp3_filename
[MAX_PATH
+1];
1053 #if CONFIG_CODEC != SWCODEC
1054 if (audio_status() & AUDIO_STATUS_PLAY
)
1058 snprintf(dirname_mp3_filename
, sizeof(dirname_mp3_filename
), "%s/%s/%s",
1059 tc
.currdir
[1] ? tc
.currdir
: "" , name
,
1060 dir_thumbnail_name
);
1062 DEBUGF("Checking for %s\n", dirname_mp3_filename
);
1064 if (!file_exists(dirname_mp3_filename
))
1066 DEBUGF("Failed to find: %s\n", dirname_mp3_filename
);
1070 DEBUGF("Found: %s\n", dirname_mp3_filename
);
1072 talk_file(dirname_mp3_filename
, false);
1073 if(global_settings
.talk_filetype
)
1074 talk_id(VOICE_DIR
, true);
1078 static void ft_play_filename(char *dir
, char *file
)
1080 char name_mp3_filename
[MAX_PATH
+1];
1082 #if CONFIG_CODEC != SWCODEC
1083 if (audio_status() & AUDIO_STATUS_PLAY
)
1087 if (strcasecmp(&file
[strlen(file
) - strlen(file_thumbnail_ext
)],
1088 file_thumbnail_ext
))
1089 { /* file has no .talk extension */
1090 snprintf(name_mp3_filename
, sizeof(name_mp3_filename
),
1091 "%s/%s%s", dir
, file
, file_thumbnail_ext
);
1093 talk_file(name_mp3_filename
, false);
1096 { /* it already is a .talk file, play this directly */
1097 snprintf(name_mp3_filename
, sizeof(name_mp3_filename
),
1098 "%s/%s", dir
, file
);
1099 talk_id(LANG_VOICE_DIR_HOVER
, false); /* prefix it */
1100 talk_file(name_mp3_filename
, true);
1104 /* These two functions are called by the USB and shutdown handlers */
1105 void tree_flush(void)
1107 scrobbler_shutdown();
1108 #ifdef HAVE_TAGCACHE
1109 tagcache_shutdown();
1111 playlist_shutdown();
1113 #ifdef HAVE_TC_RAMCACHE
1114 tagcache_unload_ramcache();
1117 #ifdef HAVE_DIRCACHE
1119 int old_val
= global_status
.dircache_size
;
1120 if (global_settings
.dircache
)
1122 if (!dircache_is_initializing())
1123 global_status
.dircache_size
= dircache_get_cache_size();
1124 # ifdef HAVE_EEPROM_SETTINGS
1125 if (firmware_settings
.initialized
)
1132 global_status
.dircache_size
= 0;
1134 if (old_val
!= global_status
.dircache_size
)
1140 void tree_restore(void)
1142 #ifdef HAVE_EEPROM_SETTINGS
1143 firmware_settings
.disk_clean
= false;
1146 #ifdef HAVE_TC_RAMCACHE
1147 remove(TAGCACHE_STATEFILE
);
1150 #ifdef HAVE_DIRCACHE
1151 remove(DIRCACHE_FILE
);
1152 if (global_settings
.dircache
)
1154 /* Print "Scanning disk..." to the display. */
1155 gui_syncsplash(0, str(LANG_SCANNING_DISK
));
1157 dircache_build(global_status
.dircache_size
);
1160 #ifdef HAVE_TAGCACHE
1161 tagcache_start_scan();