Index: tools/configure =================================================================== --- tools/configure (revision 13496) +++ tools/configure (working copy) @@ -1687,7 +1687,7 @@ html txt rockbox-manual*.zip sysfont.h rockbox-info.txt voice: tools - \$(TOOLSDIR)/genvoice.sh \$(ROOTDIR) \$(LANGUAGE) \$(ARCHOS) voicesettings.sh + \$(TOOLSDIR)/genvoice.sh \$(ROOTDIR) \$(LANGUAGE) \$(ARCHOS) \$(TARGET_ID) voicesettings.sh tools: \$(SILENT)\$(MAKE) -C \$(TOOLSDIR) CC=\$(HOSTCC) @TOOLSET@ @@ -1703,20 +1703,20 @@ \$(SILENT)\$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(ARCHOS)\" -r "\$(ROOTDIR)" -f 1 -o rockbox-fonts.zip \$(TARGET) \$(BINARY) zip: - \$(SILENT)\$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(ARCHOS)\" -r "\$(ROOTDIR)" \$(TARGET) \$(BINARY) + \$(SILENT)\$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(ARCHOS)\" -i \"\$(TARGET_ID)\" -r "\$(ROOTDIR)" \$(TARGET) \$(BINARY) mapzip: \$(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip fullzip: - \$(SILENT)\$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(ARCHOS)\" -r "\$(ROOTDIR)" -f 2 -o rockbox-full.zip \$(TARGET) \$(BINARY) + \$(SILENT)\$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(ARCHOS)\" -i \"\$(TARGET_ID)\" -r "\$(ROOTDIR)" -f 2 -o rockbox-full.zip \$(TARGET) \$(BINARY) 7zip: - \$(SILENT)\$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(ARCHOS)\" -o "rockbox.7z" -z "7za a" -r "\$(ROOTDIR)" \$(TARGET) \$(BINARY) + \$(SILENT)\$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(ARCHOS)\" -i \"\$(TARGET_ID)\" -o "rockbox.7z" -z "7za a" -r "\$(ROOTDIR)" \$(TARGET) \$(BINARY) tar: \$(SILENT)rm -f rockbox.tar - \$(SILENT)\$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(ARCHOS)\" -o "rockbox.tar" -z "tar --no-recursion -uf" -r "\$(ROOTDIR)" \$(TARGET) \$(BINARY) + \$(SILENT)\$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(ARCHOS)\" -i \"\$(TARGET_ID)\" -o "rockbox.tar" -z "tar --no-recursion -uf" -r "\$(ROOTDIR)" \$(TARGET) \$(BINARY) bzip2: tar \$(SILENT)bzip2 -f9 rockbox.tar Index: tools/buildzip.pl =================================================================== --- tools/buildzip.pl (revision 13496) +++ tools/buildzip.pl (working copy) @@ -37,6 +37,12 @@ shift @ARGV; shift @ARGV; } + elsif($ARGV[0] eq "-i") { + # The target id name as used in TARGET_ID in the root makefile + $target_id=$ARGV[1]; + shift @ARGV; + shift @ARGV; + } elsif($ARGV[0] eq "-o") { $output=$ARGV[1]; shift @ARGV; @@ -151,8 +157,8 @@ for(@files) { my $output = $_; $output =~ s/(.*)\.lang/$1.lng/; - print "$ROOT/tools/genlang -e=$dir/english.lang -t=$archos -b=$outputlang/$output $dir/$_\n" if($verbose); - system ("$ROOT/tools/genlang -e=$dir/english.lang -t=$archos -b=$outputlang/$output $dir/$_ >/dev/null 2>&1"); + print "$ROOT/tools/genlang -e=$dir/english.lang -t=$archos -i=$target_id -b=$outputlang/$output $dir/$_\n" if($verbose); + system ("$ROOT/tools/genlang -e=$dir/english.lang -t=$archos -i=$target_id -b=$outputlang/$output $dir/$_ >/dev/null 2>&1"); } } Index: tools/genvoice.sh =================================================================== --- tools/genvoice.sh (revision 13496) +++ tools/genvoice.sh (working copy) @@ -39,8 +39,9 @@ # End of settings # ################### +TARGET_ID="$4" createvoicefile() { - $VOICEFONT "$LANG_FILE" "$TEMPDIR/" "./$RLANG.voice" + $VOICEFONT "$LANG_FILE" "$TARGET_ID" "$TEMPDIR/" "./$RLANG.voice" } deletefiles() { @@ -117,12 +118,12 @@ echo "Error: $2 is not a valid language" exit 34 fi - if [ ! -z "$4" ]; then - if [ -f "$4" ]; then + if [ ! -z "$5" ]; then + if [ -f "$5" ]; then # Read settings from file - source "$4" + source "$5" else - echo "Error: $4 does not exist" + echo "Error: $5 does not exist" exit 36 fi fi Index: tools/voicefont.c =================================================================== --- tools/voicefont.c (revision 13496) +++ tools/voicefont.c (working copy) @@ -90,7 +90,7 @@ if (argc < 2) { printf("Makes a Rockbox voicefont from a collection of mp3 clips.\n"); - printf("Usage: voicefont \n"); + printf("Usage: voicefont \n"); printf("\n"); printf("Example: \n"); printf("voicefont english.lang voice\\ voicefont.bin\n"); @@ -123,10 +123,10 @@ } fclose(pFile); - pFile = fopen(argv[3], "wb"); + pFile = fopen(argv[4], "wb"); if (pFile == NULL) { - printf("Error opening output file %s\n", argv[3]); + printf("Error opening output file %s\n", argv[4]); return -2; } fseek(pFile, 16 + count*8, SEEK_SET); /* space for header */ @@ -137,8 +137,8 @@ count_voiceonly++; pos[i] = ftell(pFile); - sprintf(mp3filename1, "%s%s.mp3", argv[2], names[i]); - sprintf(mp3filename2, "%s%s.wav.mp3", argv[2], names[i]); + sprintf(mp3filename1, "%s%s.mp3", argv[3], names[i]); + sprintf(mp3filename2, "%s%s.wav.mp3", argv[3], names[i]); mp3filename = mp3filename1; pMp3File = fopen(mp3filename, "rb"); if (pMp3File == NULL) @@ -168,18 +168,23 @@ /* Create the file format: */ /* 1st 32 bit value in the file is the version number */ - value = SWAP4(200); /* 2.00 */ + value = SWAP4(300); /* 3.00 */ fwrite(&value, sizeof(value), 1, pFile); - /* 2nd 32 bit value in the file is the header size (= 1st table position) */ - value = SWAP4(16); /* 16 bytes: for version, header size, number1, number2 */ + /* 2nd 32 bit value in the file is the id number for the target + we made the voce file for */ + value = SWAP4(atoi(argv[2])); fwrite(&value, sizeof(value), 1, pFile); - /* 3rd 32 bit value in the file is the number of clips in 1st table */ + /* 3rd 32 bit value in the file is the header size (= 1st table position) */ + value = SWAP4(20); /* 16 bytes: for version, header size, number1, number2 */ + fwrite(&value, sizeof(value), 1, pFile); + + /* 4th 32 bit value in the file is the number of clips in 1st table */ value = SWAP4(count-count_voiceonly); fwrite(&value, sizeof(value), 1, pFile); - /* 4th bit value in the file is the number of clips in 2nd table */ + /* 5th bit value in the file is the number of clips in 2nd table */ value = SWAP4(count_voiceonly); fwrite(&value, sizeof(value), 1, pFile); Index: tools/genlang =================================================================== --- tools/genlang (revision 13496) +++ tools/genlang (working copy) @@ -11,7 +11,7 @@ # # binary version for the binary lang file -my $langversion = 3; # 3 was the latest one used in the v1 format +my $langversion = 4; # 3 was the latest one used in the v1 format # A note for future users and readers: The original v1 language system allowed # the build to create and use a different language than english built-in. We @@ -48,6 +48,9 @@ separated with colons. This will make genlang to use all the specified strings when searching for a matching phrase. + -i= + The target id number, needed for -b. + -o Voice mode output. Outputs all id: and voice: lines for the given target! @@ -92,7 +95,11 @@ print "Please use -e too when you use -b, -o or -u\n"; exit; } - +my $target_id = $i; +if($binary && !$target_id) { + print "Please specify a target id number\n"; + exit; +} my $target = $t; if(!$target && !$update) { print "Please specify a target (with -t)!\n"; @@ -577,7 +584,7 @@ open(OUTF, ">$binary") or die "Can't create $binary"; binmode OUTF; - printf OUTF ("\x1a%c", $langversion); # magic lang file header + printf OUTF ("\x1a%c%c", $langversion, $target_id); # magic lang file header # loop over the target phrases for $i (1 .. $idcount) { Index: apps/language.c =================================================================== --- apps/language.c (revision 13496) +++ apps/language.c (working copy) @@ -45,14 +45,15 @@ int fsize; int fd = open(filename, O_RDONLY); int retcode=0; - unsigned char lang_header[2]; + unsigned char lang_header[3]; if(fd == -1) return 1; fsize = filesize(fd) - 2; if(fsize <= MAX_LANGUAGE_SIZE) { - read(fd, lang_header, 2); + read(fd, lang_header, 3); if((lang_header[0] == LANGUAGE_COOKIE) && - (lang_header[1] == LANGUAGE_VERSION)) { + (lang_header[1] == LANGUAGE_VERSION) && + (lang_header[2] == TARGET_ID)) { read(fd, language_buffer, MAX_LANGUAGE_SIZE); unsigned char *ptr = language_buffer; int id; Index: apps/language.h =================================================================== --- apps/language.h (revision 13496) +++ apps/language.h (working copy) @@ -22,7 +22,7 @@ /* both these must match the two initial bytes in the binary lang file */ #define LANGUAGE_COOKIE 0x1a -#define LANGUAGE_VERSION 0x03 +#define LANGUAGE_VERSION 0x04 /* Initialize language array with the builtin strings */ void lang_init(void); Index: apps/talk.c =================================================================== --- apps/talk.c (revision 13496) +++ apps/talk.c (working copy) @@ -95,6 +95,7 @@ struct voicefile /* file format of our voice file */ { int version; /* version of the voicefile */ + int target_id; /* the rockbox target the file was made for */ int table; /* offset to index table, (=header size) */ int id1_max; /* number of "normal" clips contained in above index */ int id2_max; /* number of "voice only" clips contained in above index */ @@ -196,6 +197,11 @@ { p_voicefile = (struct voicefile*)audiobuf; + if (p_voicefile->target_id != TARGET_ID) + { + logf("Incompatible voice file (wrong target)"); + goto load_err; + } #if CONFIG_CODEC != SWCODEC /* MASCODEC: now use audiobuf for voice then thumbnail */ p_thumbnail = audiobuf + file_size; Index: apps/features.txt ===================================================================