A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

talk: Voice the volume name when browsing and when voicing full paths

Change-Id: I56660e168edd135a09cd5c021504a58ec9d40093

+68 -4
+28 -3
apps/talk.c
··· 44 44 #include "debug.h" 45 45 #include "panic.h" 46 46 #include "misc.h" /* time_split_units() */ 47 + #include "mv.h" 47 48 48 49 /***************** Constants *****************/ 49 50 ··· 1167 1168 return 0; 1168 1169 } 1169 1170 1171 + #ifdef HAVE_MULTIVOLUME 1172 + int talk_volume_id(int volume) 1173 + { 1174 + if (volume == -1) 1175 + return 0; 1176 + 1177 + int drive = volume_drive(volume); 1178 + // XXX voice "VOLUME" or something like that? 1179 + 1180 + talk_id(drive? LANG_DISK_NAME_MMC : LANG_DISK_NAME_INTERNAL, true); 1181 + talk_value(volume, UNIT_INT, true); 1182 + return 1; 1183 + } 1184 + #endif 1185 + 1170 1186 /* Play a directory's .talk thumbnail, fallback to spelling the filename, or 1171 1187 go straight to spelling depending on settings. */ 1172 1188 int talk_dir_or_spell(const char* dirname, ··· 1174 1190 { 1175 1191 if (global_settings.talk_dir_clip) 1176 1192 { /* .talk clips enabled */ 1177 - if(talk_file(dirname, NULL, dir_thumbnail_name, NULL, 1193 + if (talk_file(dirname, NULL, dir_thumbnail_name, NULL, 1178 1194 prefix_ids, enqueue) >0) 1179 1195 return 0; 1180 1196 } 1181 - if (global_settings.talk_dir == TALK_SPEAK_SPELL) 1197 + if (global_settings.talk_dir == TALK_SPEAK_SPELL) { 1182 1198 /* Either .talk clips disabled or as a fallback */ 1183 1199 return talk_spell_basename(dirname, prefix_ids, enqueue); 1200 + } 1184 1201 return 0; 1185 1202 } 1186 1203 ··· 1201 1218 while(ptr) { /* There are more slashes ahead */ 1202 1219 /* temporarily poke a NULL at end of component to truncate string */ 1203 1220 *ptr = '\0'; 1204 - talk_dir_or_spell(buf, NULL, true); 1221 + #ifdef HAVE_MULTIVOLUME 1222 + if (start == buf+1) { 1223 + int vol = path_get_volume_id(buf+1); 1224 + if (!talk_volume_id(vol)) 1225 + talk_dir_or_spell(buf, NULL, true); 1226 + } else 1227 + #endif 1228 + talk_dir_or_spell(buf, NULL, true); 1205 1229 *ptr = '/'; /* restore string */ 1206 1230 talk_id(VOICE_CHAR_SLASH, true); 1207 1231 start = ptr+1; /* setup for next component */ 1208 1232 ptr = strchr(start, '/'); 1209 1233 } 1234 + 1210 1235 /* no more slashes, final component is a filename */ 1211 1236 return talk_file_or_spell(NULL, buf, NULL, true); 1212 1237 }
+4
apps/talk.h
··· 145 145 void talk_time(const struct tm *tm, bool enqueue); 146 146 void talk_date(const struct tm *tm, bool enqueue); 147 147 148 + #ifdef HAVE_MULTIVOLUME 149 + int talk_volume_id(int volume); 150 + #endif 151 + 148 152 /* speaks hr, min, sec, ms; unit_idx is lowest or base unit of the time value */ 149 153 int talk_time_intervals(long time, int unit_idx, bool enqueue); 150 154
+6
apps/tree.c
··· 1252 1252 1253 1253 static int ft_play_dirname(char* name) 1254 1254 { 1255 + #ifdef HAVE_MULTIVOLUME 1256 + int vol = path_get_volume_id(name); 1257 + if (talk_volume_id(vol)) 1258 + return 1; 1259 + #endif 1260 + 1255 1261 return talk_file(tc.currdir, name, dir_thumbnail_name, NULL, 1256 1262 global_settings.talk_filetype ? 1257 1263 TALK_IDARRAY(VOICE_DIR) : NULL,
+29 -1
firmware/common/pathfuncs.c
··· 127 127 VOL_START_TOK, voldec, volume, VOL_END_TOK); 128 128 DEBUGF("vol<%d> = %s ", volume, buffer); 129 129 } 130 - DEBUGF("\n"); 130 + DEBUGF("\n"); 131 + } 132 + 133 + #include <stdio.h> 134 + 135 + int path_get_volume_id(const char *name) 136 + { 137 + int v = -1; 138 + 139 + if (!name || *name != VOL_START_TOK) 140 + goto bail; 141 + 142 + do { 143 + switch (*name) 144 + { 145 + case '0' ... '9': /* digit; parse volume number */ 146 + v = (v * 10 + *name - '0') % VOL_NUM_MAX; 147 + break; 148 + case '\0': 149 + case PATH_SEPCH: /* no closing bracket; no volume */ 150 + v = -1; 151 + goto bail; 152 + default: /* something else; reset volume */ 153 + v = 0; 154 + } 155 + } while (*++name != VOL_END_TOK); /* found end token? */ 156 + 157 + bail: 158 + return v; 131 159 } 132 160 133 161 /* Returns on which volume this is and sets *nameptr to the portion of the
+1
firmware/export/pathfuncs.h
··· 83 83 int get_volume_name(int volume, char *name); 84 84 int make_volume_root(int volume, char *dst); 85 85 void init_volume_names(void); 86 + int path_get_volume_id(const char *name); 86 87 #endif 87 88 88 89 int path_strip_drive(const char *name, const char **nameptr, bool greedy);