forked from len0rd/rockbox
talk: Voice the volume name when browsing and when voicing full paths
Change-Id: I56660e168edd135a09cd5c021504a58ec9d40093
This commit is contained in:
parent
70b96193e7
commit
78283bda64
5 changed files with 68 additions and 4 deletions
27
apps/talk.c
27
apps/talk.c
|
@ -44,6 +44,7 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "panic.h"
|
#include "panic.h"
|
||||||
#include "misc.h" /* time_split_units() */
|
#include "misc.h" /* time_split_units() */
|
||||||
|
#include "mv.h"
|
||||||
|
|
||||||
/***************** Constants *****************/
|
/***************** Constants *****************/
|
||||||
|
|
||||||
|
@ -1167,6 +1168,21 @@ int talk_file_or_spell(const char *dirname, const char *filename,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_MULTIVOLUME
|
||||||
|
int talk_volume_id(int volume)
|
||||||
|
{
|
||||||
|
if (volume == -1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int drive = volume_drive(volume);
|
||||||
|
// XXX voice "VOLUME" or something like that?
|
||||||
|
|
||||||
|
talk_id(drive? LANG_DISK_NAME_MMC : LANG_DISK_NAME_INTERNAL, true);
|
||||||
|
talk_value(volume, UNIT_INT, true);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Play a directory's .talk thumbnail, fallback to spelling the filename, or
|
/* Play a directory's .talk thumbnail, fallback to spelling the filename, or
|
||||||
go straight to spelling depending on settings. */
|
go straight to spelling depending on settings. */
|
||||||
int talk_dir_or_spell(const char* dirname,
|
int talk_dir_or_spell(const char* dirname,
|
||||||
|
@ -1178,9 +1194,10 @@ int talk_dir_or_spell(const char* dirname,
|
||||||
prefix_ids, enqueue) >0)
|
prefix_ids, enqueue) >0)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (global_settings.talk_dir == TALK_SPEAK_SPELL)
|
if (global_settings.talk_dir == TALK_SPEAK_SPELL) {
|
||||||
/* Either .talk clips disabled or as a fallback */
|
/* Either .talk clips disabled or as a fallback */
|
||||||
return talk_spell_basename(dirname, prefix_ids, enqueue);
|
return talk_spell_basename(dirname, prefix_ids, enqueue);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1201,12 +1218,20 @@ int talk_fullpath(const char* path, bool enqueue)
|
||||||
while(ptr) { /* There are more slashes ahead */
|
while(ptr) { /* There are more slashes ahead */
|
||||||
/* temporarily poke a NULL at end of component to truncate string */
|
/* temporarily poke a NULL at end of component to truncate string */
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
|
#ifdef HAVE_MULTIVOLUME
|
||||||
|
if (start == buf+1) {
|
||||||
|
int vol = path_get_volume_id(buf+1);
|
||||||
|
if (!talk_volume_id(vol))
|
||||||
|
talk_dir_or_spell(buf, NULL, true);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
talk_dir_or_spell(buf, NULL, true);
|
talk_dir_or_spell(buf, NULL, true);
|
||||||
*ptr = '/'; /* restore string */
|
*ptr = '/'; /* restore string */
|
||||||
talk_id(VOICE_CHAR_SLASH, true);
|
talk_id(VOICE_CHAR_SLASH, true);
|
||||||
start = ptr+1; /* setup for next component */
|
start = ptr+1; /* setup for next component */
|
||||||
ptr = strchr(start, '/');
|
ptr = strchr(start, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no more slashes, final component is a filename */
|
/* no more slashes, final component is a filename */
|
||||||
return talk_file_or_spell(NULL, buf, NULL, true);
|
return talk_file_or_spell(NULL, buf, NULL, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,10 @@ void talk_fractional(char *tbuf, int value, int unit);
|
||||||
void talk_time(const struct tm *tm, bool enqueue);
|
void talk_time(const struct tm *tm, bool enqueue);
|
||||||
void talk_date(const struct tm *tm, bool enqueue);
|
void talk_date(const struct tm *tm, bool enqueue);
|
||||||
|
|
||||||
|
#ifdef HAVE_MULTIVOLUME
|
||||||
|
int talk_volume_id(int volume);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* speaks hr, min, sec, ms; unit_idx is lowest or base unit of the time value */
|
/* speaks hr, min, sec, ms; unit_idx is lowest or base unit of the time value */
|
||||||
int talk_time_intervals(long time, int unit_idx, bool enqueue);
|
int talk_time_intervals(long time, int unit_idx, bool enqueue);
|
||||||
|
|
||||||
|
|
|
@ -1252,6 +1252,12 @@ static void say_filetype(int attr)
|
||||||
|
|
||||||
static int ft_play_dirname(char* name)
|
static int ft_play_dirname(char* name)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_MULTIVOLUME
|
||||||
|
int vol = path_get_volume_id(name);
|
||||||
|
if (talk_volume_id(vol))
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
return talk_file(tc.currdir, name, dir_thumbnail_name, NULL,
|
return talk_file(tc.currdir, name, dir_thumbnail_name, NULL,
|
||||||
global_settings.talk_filetype ?
|
global_settings.talk_filetype ?
|
||||||
TALK_IDARRAY(VOICE_DIR) : NULL,
|
TALK_IDARRAY(VOICE_DIR) : NULL,
|
||||||
|
|
|
@ -130,6 +130,34 @@ void init_volume_names(void)
|
||||||
DEBUGF("\n");
|
DEBUGF("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int path_get_volume_id(const char *name)
|
||||||
|
{
|
||||||
|
int v = -1;
|
||||||
|
|
||||||
|
if (!name || *name != VOL_START_TOK)
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
do {
|
||||||
|
switch (*name)
|
||||||
|
{
|
||||||
|
case '0' ... '9': /* digit; parse volume number */
|
||||||
|
v = (v * 10 + *name - '0') % VOL_NUM_MAX;
|
||||||
|
break;
|
||||||
|
case '\0':
|
||||||
|
case PATH_SEPCH: /* no closing bracket; no volume */
|
||||||
|
v = -1;
|
||||||
|
goto bail;
|
||||||
|
default: /* something else; reset volume */
|
||||||
|
v = 0;
|
||||||
|
}
|
||||||
|
} while (*++name != VOL_END_TOK); /* found end token? */
|
||||||
|
|
||||||
|
bail:
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns on which volume this is and sets *nameptr to the portion of the
|
/* Returns on which volume this is and sets *nameptr to the portion of the
|
||||||
* path after the volume specifier, which could be the null if the path is
|
* path after the volume specifier, which could be the null if the path is
|
||||||
* just a volume root. If *nameptr > name, then a volume specifier was
|
* just a volume root. If *nameptr > name, then a volume specifier was
|
||||||
|
|
|
@ -83,6 +83,7 @@ int path_strip_last_volume(const char *name, const char **nameptr, bool greedy);
|
||||||
int get_volume_name(int volume, char *name);
|
int get_volume_name(int volume, char *name);
|
||||||
int make_volume_root(int volume, char *dst);
|
int make_volume_root(int volume, char *dst);
|
||||||
void init_volume_names(void);
|
void init_volume_names(void);
|
||||||
|
int path_get_volume_id(const char *name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int path_strip_drive(const char *name, const char **nameptr, bool greedy);
|
int path_strip_drive(const char *name, const char **nameptr, bool greedy);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue