diff options
Diffstat (limited to 'apps/tree.c')
-rw-r--r-- | apps/tree.c | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/apps/tree.c b/apps/tree.c index b5c9ddc11d..ddaf955ce6 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -102,7 +102,7 @@ static int curr_context = false;/* id3db or tree*/ | |||
102 | 102 | ||
103 | static int dirbrowse(void); | 103 | static int dirbrowse(void); |
104 | static int ft_play_dirname(char* name); | 104 | static int ft_play_dirname(char* name); |
105 | static void ft_play_filename(char *dir, char *file); | 105 | static int ft_play_filename(char *dir, char *file, int attr); |
106 | static void say_filetype(int attr); | 106 | static void say_filetype(int attr); |
107 | 107 | ||
108 | struct entry* tree_get_entries(struct tree_context *t) | 108 | struct entry* tree_get_entries(struct tree_context *t) |
@@ -238,7 +238,7 @@ static int tree_voice_cb(int selected_item, void * data) | |||
238 | if(global_settings.talk_dir_clip) | 238 | if(global_settings.talk_dir_clip) |
239 | { | 239 | { |
240 | did_clip = true; | 240 | did_clip = true; |
241 | if(ft_play_dirname(name) <0) | 241 | if (ft_play_dirname(name) <= 0) |
242 | /* failed, not existing */ | 242 | /* failed, not existing */ |
243 | did_clip = false; | 243 | did_clip = false; |
244 | } | 244 | } |
@@ -246,7 +246,9 @@ static int tree_voice_cb(int selected_item, void * data) | |||
246 | if (global_settings.talk_file_clip && (attr & FILE_ATTR_THUMBNAIL)) | 246 | if (global_settings.talk_file_clip && (attr & FILE_ATTR_THUMBNAIL)) |
247 | { | 247 | { |
248 | did_clip = true; | 248 | did_clip = true; |
249 | ft_play_filename(local_tc->currdir, name); | 249 | if (ft_play_filename(local_tc->currdir, name, attr) <= 0) |
250 | /* failed, not existing */ | ||
251 | did_clip = false; | ||
250 | } | 252 | } |
251 | } | 253 | } |
252 | if(!did_clip) | 254 | if(!did_clip) |
@@ -1175,17 +1177,25 @@ bool bookmark_play(char *resume_file, int index, unsigned long elapsed, | |||
1175 | return started; | 1177 | return started; |
1176 | } | 1178 | } |
1177 | 1179 | ||
1178 | static void say_filetype(int attr) | 1180 | static long filetype_voiceclip(int attr) |
1179 | { | 1181 | { |
1180 | /* try to find a voice ID for the extension, if known */ | ||
1181 | int j; | 1182 | int j; |
1182 | attr &= FILE_ATTR_MASK; /* file type */ | 1183 | if (global_settings.talk_filetype) |
1183 | for (j=0; j<filetypes_count; j++) | 1184 | { |
1184 | if (attr == filetypes[j].tree_attr) | 1185 | /* try to find a voice ID for the extension, if known */ |
1185 | { | 1186 | attr &= FILE_ATTR_MASK; /* file type */ |
1186 | talk_id(filetypes[j].voiceclip, true); | 1187 | for (j=0; j<filetypes_count; j++) |
1187 | return; | 1188 | if (attr == filetypes[j].tree_attr) |
1188 | } | 1189 | { |
1190 | return filetypes[j].voiceclip; | ||
1191 | } | ||
1192 | } | ||
1193 | return -1; | ||
1194 | } | ||
1195 | |||
1196 | static void say_filetype(int attr) | ||
1197 | { | ||
1198 | talk_id(filetype_voiceclip(attr), true); | ||
1189 | } | 1199 | } |
1190 | 1200 | ||
1191 | static int ft_play_dirname(char* name) | 1201 | static int ft_play_dirname(char* name) |
@@ -1195,34 +1205,29 @@ static int ft_play_dirname(char* name) | |||
1195 | return 0; | 1205 | return 0; |
1196 | #endif | 1206 | #endif |
1197 | 1207 | ||
1198 | if(talk_file(tc.currdir, name, dir_thumbnail_name, NULL, | 1208 | return talk_file(tc.currdir, name, dir_thumbnail_name, NULL, |
1199 | NULL, false)) | 1209 | global_settings.talk_filetype ? |
1200 | { | 1210 | TALK_IDARRAY(VOICE_DIR) : NULL, |
1201 | if(global_settings.talk_filetype) | 1211 | false); |
1202 | talk_id(VOICE_DIR, true); | ||
1203 | return 1; | ||
1204 | } | ||
1205 | else | ||
1206 | return -1; | ||
1207 | } | 1212 | } |
1208 | 1213 | ||
1209 | static void ft_play_filename(char *dir, char *file) | 1214 | static int ft_play_filename(char *dir, char *file, int attr) |
1210 | { | 1215 | { |
1211 | #if CONFIG_CODEC != SWCODEC | 1216 | #if CONFIG_CODEC != SWCODEC |
1212 | if (audio_status() & AUDIO_STATUS_PLAY) | 1217 | if (audio_status() & AUDIO_STATUS_PLAY) |
1213 | return; | 1218 | return 0; |
1214 | #endif | 1219 | #endif |
1215 | 1220 | ||
1216 | if (strlen(file) >= strlen(file_thumbnail_ext) | 1221 | if (strlen(file) >= strlen(file_thumbnail_ext) |
1217 | && strcasecmp(&file[strlen(file) - strlen(file_thumbnail_ext)], | 1222 | && strcasecmp(&file[strlen(file) - strlen(file_thumbnail_ext)], |
1218 | file_thumbnail_ext)) | 1223 | file_thumbnail_ext)) |
1219 | /* file has no .talk extension */ | 1224 | /* file has no .talk extension */ |
1220 | talk_file(dir, NULL, file, file_thumbnail_ext, | 1225 | return talk_file(dir, NULL, file, file_thumbnail_ext, |
1221 | NULL, false); | 1226 | TALK_IDARRAY(filetype_voiceclip(attr)), false); |
1222 | else | 1227 | |
1223 | /* it already is a .talk file, play this directly, but prefix it. */ | 1228 | /* it already is a .talk file, play this directly, but prefix it. */ |
1224 | talk_file(dir, NULL, file, NULL, | 1229 | return talk_file(dir, NULL, file, NULL, |
1225 | TALK_IDARRAY(LANG_VOICE_DIR_HOVER), false); | 1230 | TALK_IDARRAY(LANG_VOICE_DIR_HOVER), false); |
1226 | } | 1231 | } |
1227 | 1232 | ||
1228 | /* These two functions are called by the USB and shutdown handlers */ | 1233 | /* These two functions are called by the USB and shutdown handlers */ |