1
0
Fork 0
forked from len0rd/rockbox

Voice UI searches for <mylanguage>.voice, no hard-coded "english.voice" any more. We can localize the voice now.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4471 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jörg Hohensohn 2004-04-06 07:06:59 +00:00
parent 4af9331ed2
commit 6e77d1fe39
3 changed files with 27 additions and 3 deletions

View file

@ -587,6 +587,7 @@ void settings_apply(void)
snprintf(buf, sizeof buf, ROCKBOX_DIR LANG_DIR "/%s.lng", snprintf(buf, sizeof buf, ROCKBOX_DIR LANG_DIR "/%s.lng",
global_settings.lang_file); global_settings.lang_file);
lang_load(buf); lang_load(buf);
talk_init(); /* use voice of same language */
} }
set_car_adapter_mode(global_settings.car_adapter_mode); set_car_adapter_mode(global_settings.car_adapter_mode);
@ -974,7 +975,10 @@ bool settings_load_config(char* file)
} }
else if (!strcasecmp(name, "lang")) { else if (!strcasecmp(name, "lang")) {
if (!lang_load(value)) if (!lang_load(value))
{
set_file(value, global_settings.lang_file, MAX_FILENAME); set_file(value, global_settings.lang_file, MAX_FILENAME);
talk_init(); /* use voice of same language */
}
} }
else if (!strcasecmp(name, "bidir limit")) else if (!strcasecmp(name, "bidir limit"))
set_cfg_int(&global_settings.bidir_limit, value, 0, 200); set_cfg_int(&global_settings.bidir_limit, value, 0, 200);

View file

@ -26,6 +26,7 @@
#include "file.h" #include "file.h"
#include "buffer.h" #include "buffer.h"
#include "system.h" #include "system.h"
#include "settings.h"
#include "mp3_playback.h" #include "mp3_playback.h"
#include "mpeg.h" #include "mpeg.h"
#include "lang.h" #include "lang.h"
@ -36,7 +37,6 @@ extern void bitswap(unsigned char *data, int length); /* no header for this */
/***************** Constants *****************/ /***************** Constants *****************/
#define QUEUE_SIZE 50 #define QUEUE_SIZE 50
const char* voicefont_file = "/.rockbox/langs/english.voice";
const char* dir_thumbnail_name = ".dirname.mp3"; const char* dir_thumbnail_name = ".dirname.mp3";
@ -84,10 +84,29 @@ static int load_voicefont(void);
static void mp3_callback(unsigned char** start, int* size); static void mp3_callback(unsigned char** start, int* size);
static int shutup(void); static int shutup(void);
static int queue_clip(unsigned char* buf, int size, bool enqueue); static int queue_clip(unsigned char* buf, int size, bool enqueue);
static int open_voicefile(void);
/***************** Private implementation *****************/ /***************** Private implementation *****************/
static int open_voicefile(void)
{
char buf[64];
char* p_lang = "english"; /* default */
if ( global_settings.lang_file[0] &&
global_settings.lang_file[0] != 0xff )
{ /* try to open the voice file of the selected language */
p_lang = global_settings.lang_file;
}
snprintf(buf, sizeof(buf), ROCKBOX_DIR LANG_DIR "/%s.voice", p_lang);
return open(buf, O_RDONLY);
}
static int load_voicefont(void) static int load_voicefont(void)
{ {
int fd; int fd;
@ -95,7 +114,7 @@ static int load_voicefont(void)
p_voicefont = NULL; /* indicate no voicefont if we fail below */ p_voicefont = NULL; /* indicate no voicefont if we fail below */
fd = open(voicefont_file, O_RDONLY); fd = open_voicefile();
if (fd < 0) /* failed to open */ if (fd < 0) /* failed to open */
{ {
p_voicefont = NULL; /* indicate no voicefont */ p_voicefont = NULL; /* indicate no voicefont */
@ -253,7 +272,7 @@ void talk_init(void)
{ {
int fd; int fd;
fd = open(voicefont_file, O_RDONLY); fd = open_voicefile();
if (fd >= 0) /* success */ if (fd >= 0) /* success */
{ {
close(fd); close(fd);

View file

@ -1176,6 +1176,7 @@ static bool dirbrowse(char *root, int *dirfilter)
if(!lang_load(buf)) { if(!lang_load(buf)) {
set_file(buf, global_settings.lang_file, set_file(buf, global_settings.lang_file,
MAX_FILENAME); MAX_FILENAME);
talk_init(); /* use voice of same language */
splash(HZ, true, str(LANG_LANGUAGE_LOADED)); splash(HZ, true, str(LANG_LANGUAGE_LOADED));
restore = true; restore = true;
} }