From d48442039ed399c0ba5ae51bc42d56b5b23f1bc4 Mon Sep 17 00:00:00 2001 From: Jörg Hohensohn Date: Wed, 6 Oct 2004 21:37:46 +0000 Subject: patch #978765 by Carsten Tschach, new option for voice filenames: every file may have an optional .talk companion, with a filename clip. While at it, I removed the "on enter" directory talking, nobody used it. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5194 a1c6a512-1295-4272-9138-f99709370657 --- apps/lang/deutsch.lang | 16 +++---- apps/lang/english.lang | 12 ++--- apps/settings.c | 7 +-- apps/settings_menu.c | 24 +++++----- apps/talk.h | 4 +- apps/tree.c | 118 ++++++++++++++++++++++++++++++++++--------------- 6 files changed, 112 insertions(+), 69 deletions(-) (limited to 'apps') diff --git a/apps/lang/deutsch.lang b/apps/lang/deutsch.lang index db4ccc053e..f4cfa864af 100644 --- a/apps/lang/deutsch.lang +++ b/apps/lang/deutsch.lang @@ -2390,16 +2390,16 @@ voice: "als Zahl" new: "als Zahl" id: LANG_VOICE_DIR_ENTER -desc: "talkbox" mode for directories -eng: "on enter" -voice: "beim Betreten" -new: "beim Betreten" +desc: DEPRECATED +eng: "" +voice: "" +new: "" id: LANG_VOICE_DIR_HOVER -desc: "talkbox" mode for directories -eng: "while hovering" -voice: "mit Zeiger" -new: "mit Cursor" +desc: "talkbox" mode for directories + files +eng: ".talk mp3 clip" +voice: "Sprachdatei" +new: ".talk mp3 Datei" id: VOICE_FILE desc: spoken only, prefix for file number diff --git a/apps/lang/english.lang b/apps/lang/english.lang index d93920dab8..facbe7eaf9 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -2404,15 +2404,15 @@ voice: "Numbers" new: id: LANG_VOICE_DIR_ENTER -desc: "talkbox" mode for directories -eng: "on enter" -voice: "on enter" +desc: DEPRECATED +eng: "" +voice: "" new: id: LANG_VOICE_DIR_HOVER -desc: "talkbox" mode for directories -eng: "while hovering" -voice: "while hovering" +desc: "talkbox" mode for directories + files +eng: ".talk mp3 clip" +voice: "talk mp3 clip" new: id: VOICE_FILE diff --git a/apps/settings.c b/apps/settings.c index 45ea7de072..10333b15c1 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -71,7 +71,7 @@ const char rec_base_directory[] = REC_BASE_DIR; -#define CONFIG_BLOCK_VERSION 16 +#define CONFIG_BLOCK_VERSION 17 #define CONFIG_BLOCK_SIZE 512 #define RTC_BLOCK_SIZE 44 @@ -150,6 +150,7 @@ Rest of config block, only saved to disk: static const char off_on[] = "off,on"; static const char off_on_ask[] = "off,on,ask"; static const char graphic_numeric[] = "graphic,numeric"; +static const char off_number_spell_hover[] = "off,number,spell,hover"; /* the part of the settings which ends up in the RTC RAM, where available (those we either need early, save frequently, or without spinup) */ @@ -319,8 +320,8 @@ static const struct bit_entry hd_bits[] = {1, S_O(line_in), false, "line in", off_on }, #endif /* voice */ - {3, S_O(talk_dir), 0, "talk dir", "off,number,spell,enter,hover" }, - {2, S_O(talk_file), 0, "talk file", "off,number,spell" }, + {2, S_O(talk_dir), 0, "talk dir", off_number_spell_hover }, + {2, S_O(talk_file), 0, "talk file", off_number_spell_hover }, {1, S_O(talk_menu), true, "talk menu", off_on }, /* If values are just added to the end, no need to bump the version. */ diff --git a/apps/settings_menu.c b/apps/settings_menu.c index 624274520f..4e9ec25d79 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c @@ -898,28 +898,24 @@ static bool voice_menus(void) return ret; } +/* this is used 2 times below, so it saves memory to put it in global scope */ +static const struct opt_items voice_names[] = { + { STR(LANG_OFF) }, + { STR(LANG_VOICE_NUMBER) }, + { STR(LANG_VOICE_SPELL) }, + { STR(LANG_VOICE_DIR_HOVER) } +}; + static bool voice_dirs(void) { - static const struct opt_items names[] = { - { STR(LANG_OFF) }, - { STR(LANG_VOICE_NUMBER) }, - { STR(LANG_VOICE_SPELL) }, - { STR(LANG_VOICE_DIR_ENTER) }, - { STR(LANG_VOICE_DIR_HOVER) } - }; return set_option( str(LANG_VOICE_DIR), - &global_settings.talk_dir, INT, names, 5, NULL); + &global_settings.talk_dir, INT, voice_names, 4, NULL); } static bool voice_files(void) { - static const struct opt_items names[] = { - { STR(LANG_OFF) }, - { STR(LANG_VOICE_NUMBER) }, - { STR(LANG_VOICE_SPELL) } - }; return set_option( str(LANG_VOICE_FILE), - &global_settings.talk_file, INT, names, 3, NULL); + &global_settings.talk_file, INT, voice_names, 4, NULL); } static bool voice_menu(void) diff --git a/apps/talk.h b/apps/talk.h index c4c8bc7285..09d71866b0 100644 --- a/apps/talk.h +++ b/apps/talk.h @@ -55,8 +55,8 @@ enum { #define STR(id) ID2P(id), id /* publish this string, so it's stored only once (better than #define) */ -extern const char* const dir_thumbnail_name; - +extern const char* const dir_thumbnail_name; /* "_dirname.talk" */ +#define TALK_EXT ".talk" /* extra extension for file voicing */ void talk_init(void); int talk_buffer_steal(void); /* claim the mp3 buffer e.g. for play/record */ diff --git a/apps/tree.c b/apps/tree.c index 90ae159418..effb093b41 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -221,6 +221,25 @@ static int build_playlist(int start_index) return start_index; } +static int play_filenumber(int pos, int attr) +{ + /* try to find a voice ID for the extension, if known */ + unsigned int j; + int ext_id = -1; /* default to none */ + for (j=0; jname); if (file->attr & ATTR_DIRECTORY) { - if (global_settings.talk_dir == 3) /* enter */ - { - /* play_dirname */ - DEBUGF("Playing directory thumbnail: %s", currdir); - play_dirname(dircursor+dirstart); - /* avoid reading getting cut by next filename */ - enqueue_next = true; - } memcpy(currdir,buf,sizeof(currdir)); if ( dirlevel < MAX_DIR_LEVELS ) { dirpos[dirlevel] = dirstart; @@ -1306,12 +1351,26 @@ static bool dirbrowse(const char *root, const int *dirfilter) TIME_AFTER(current_tick, thumbnail_time)) { /* a delayed hovering thumbnail is due now */ int res; - DEBUGF("Playing directory thumbnail: %s", currdir); - res = play_dirname(lasti); - if (res < 0) /* failed, not existing */ - { /* say the number instead, as a fallback */ - talk_id(VOICE_DIR, false); - talk_number(lasti+1, true); + if (dircache[lasti].attr & ATTR_DIRECTORY) + { + DEBUGF("Playing directory thumbnail: %s", currdir); + res = play_dirname(lasti); + if (res < 0) /* failed, not existing */ + { /* say the number instead, as a fallback */ + talk_id(VOICE_DIR, false); + talk_number(lasti+1, true); + } + } + else + { + DEBUGF("Playing file thumbnail: %s/%s%s\n", + currdir, dircache[lasti].name, TALK_EXT); + res = play_filename(currdir, dircache[lasti].name); + if (res < 0) /* failed, not existing */ + { /* say the number instead, as a fallback */ + play_filenumber(lasti-dirsindir+1, + dircache[lasti].attr); + } } thumbnail_time = -1; /* job done */ } @@ -1417,7 +1476,7 @@ static bool dirbrowse(const char *root, const int *dirfilter) if (dircache[i].attr & ATTR_DIRECTORY) /* directory? */ { /* play directory thumbnail */ - if (global_settings.talk_dir == 4) /* hover */ + if (global_settings.talk_dir == 3) /* hover */ { /* "schedule" a thumbnail, to have a little dalay */ thumbnail_time = current_tick + HOVER_DELAY; } @@ -1433,29 +1492,16 @@ static bool dirbrowse(const char *root, const int *dirfilter) } else if (global_settings.talk_file == 1) /* files as numbers */ { - /* try to find a voice ID for the extension, if known */ - unsigned int j; - int ext_id = -1; /* default to none */ - for (j=0; j