summaryrefslogtreecommitdiffstats
path: root/apps/tree.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2018-10-30 09:45:26 -0400
committerSolomon Peachy <pizza@shaftnet.org>2018-12-15 18:00:23 +0100
commit4adad0bc1f508360999de176048f89025ce84b3e (patch)
tree46fed2ec12b60df2d94ba54950c2da798aa9445a /apps/tree.c
parentf061330c3d7b17cc770a8eb2c699b5e44995ad1e (diff)
downloadrockbox-4adad0bc1f508360999de176048f89025ce84b3e.tar.gz
rockbox-4adad0bc1f508360999de176048f89025ce84b3e.tar.bz2
rockbox-4adad0bc1f508360999de176048f89025ce84b3e.zip
FS#6323: Speech for ID3 viewer, playlist catalog and playlist viewer
Modified from original ticket, Taken from Igor Poretsky's tree, and further modified by myself to incorporate feedback. Change-Id: Ibc2180e52af76890b1448d23f79386fd0f88f709
Diffstat (limited to 'apps/tree.c')
-rw-r--r--apps/tree.c63
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*/
static int dirbrowse(void);
static int ft_play_dirname(char* name);
-static void ft_play_filename(char *dir, char *file);
+static int ft_play_filename(char *dir, char *file, int attr);
static void say_filetype(int attr);
struct entry* tree_get_entries(struct tree_context *t)
@@ -238,7 +238,7 @@ static int tree_voice_cb(int selected_item, void * data)
if(global_settings.talk_dir_clip)
{
did_clip = true;
- if(ft_play_dirname(name) <0)
+ if (ft_play_dirname(name) <= 0)
/* failed, not existing */
did_clip = false;
}
@@ -246,7 +246,9 @@ static int tree_voice_cb(int selected_item, void * data)
if (global_settings.talk_file_clip && (attr & FILE_ATTR_THUMBNAIL))
{
did_clip = true;
- ft_play_filename(local_tc->currdir, name);
+ if (ft_play_filename(local_tc->currdir, name, attr) <= 0)
+ /* failed, not existing */
+ did_clip = false;
}
}
if(!did_clip)
@@ -1175,17 +1177,25 @@ bool bookmark_play(char *resume_file, int index, unsigned long elapsed,
return started;
}
-static void say_filetype(int attr)
+static long filetype_voiceclip(int attr)
{
- /* try to find a voice ID for the extension, if known */
int j;
- attr &= FILE_ATTR_MASK; /* file type */
- for (j=0; j<filetypes_count; j++)
- if (attr == filetypes[j].tree_attr)
- {
- talk_id(filetypes[j].voiceclip, true);
- return;
- }
+ if (global_settings.talk_filetype)
+ {
+ /* try to find a voice ID for the extension, if known */
+ attr &= FILE_ATTR_MASK; /* file type */
+ for (j=0; j<filetypes_count; j++)
+ if (attr == filetypes[j].tree_attr)
+ {
+ return filetypes[j].voiceclip;
+ }
+ }
+ return -1;
+}
+
+static void say_filetype(int attr)
+{
+ talk_id(filetype_voiceclip(attr), true);
}
static int ft_play_dirname(char* name)
@@ -1195,34 +1205,29 @@ static int ft_play_dirname(char* name)
return 0;
#endif
- if(talk_file(tc.currdir, name, dir_thumbnail_name, NULL,
- NULL, false))
- {
- if(global_settings.talk_filetype)
- talk_id(VOICE_DIR, true);
- return 1;
- }
- else
- return -1;
+ return talk_file(tc.currdir, name, dir_thumbnail_name, NULL,
+ global_settings.talk_filetype ?
+ TALK_IDARRAY(VOICE_DIR) : NULL,
+ false);
}
-static void ft_play_filename(char *dir, char *file)
+static int ft_play_filename(char *dir, char *file, int attr)
{
#if CONFIG_CODEC != SWCODEC
if (audio_status() & AUDIO_STATUS_PLAY)
- return;
+ return 0;
#endif
if (strlen(file) >= strlen(file_thumbnail_ext)
&& strcasecmp(&file[strlen(file) - strlen(file_thumbnail_ext)],
file_thumbnail_ext))
/* file has no .talk extension */
- talk_file(dir, NULL, file, file_thumbnail_ext,
- NULL, false);
- else
- /* it already is a .talk file, play this directly, but prefix it. */
- talk_file(dir, NULL, file, NULL,
- TALK_IDARRAY(LANG_VOICE_DIR_HOVER), false);
+ return talk_file(dir, NULL, file, file_thumbnail_ext,
+ TALK_IDARRAY(filetype_voiceclip(attr)), false);
+
+ /* it already is a .talk file, play this directly, but prefix it. */
+ return talk_file(dir, NULL, file, NULL,
+ TALK_IDARRAY(LANG_VOICE_DIR_HOVER), false);
}
/* These two functions are called by the USB and shutdown handlers */