summaryrefslogtreecommitdiffstats
path: root/pico
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2009-07-29 15:07:38 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2009-07-29 15:07:38 -0700
commitdd1501a7191f7be46c119296ae5bcf2c3dc6e5e8 (patch)
tree0d043b0d65d21b7cd14cb2a1cd3690cc5967fcb5 /pico
parentb641dea8fc113cbb6976eed9e073381a024ec224 (diff)
downloadexternal_svox-dd1501a7191f7be46c119296ae5bcf2c3dc6e5e8.zip
external_svox-dd1501a7191f7be46c119296ae5bcf2c3dc6e5e8.tar.gz
external_svox-dd1501a7191f7be46c119296ae5bcf2c3dc6e5e8.tar.bz2
Fix bug 1997567. Integrate the latest SVOX code drop which fixes the
issue where a language couldn't be successfully loaded if the first loaded language was not eng-USA (language 0).
Diffstat (limited to 'pico')
-rw-r--r--pico/tts/com_svox_picottsengine.cpp45
1 files changed, 33 insertions, 12 deletions
diff --git a/pico/tts/com_svox_picottsengine.cpp b/pico/tts/com_svox_picottsengine.cpp
index 5dbcb3f..e5c6994 100644
--- a/pico/tts/com_svox_picottsengine.cpp
+++ b/pico/tts/com_svox_picottsengine.cpp
@@ -178,6 +178,11 @@ static void cleanResources( void )
pico_unloadResource( picoSystem, &picoSgResource );
picoSgResource = NULL;
}
+
+ if (picoSystem) {
+ pico_terminate(&picoSystem);
+ picoSystem = NULL;
+ }
picoCurrentLangIndex = -1;
}
@@ -268,17 +273,30 @@ static tts_result doLanguageSwitchFromLangIndex( int langIndex )
{
int ret; /* function result code */
- /* If we already have a loaded locale, check whether it is the same one as requested. */
- if (picoProp_currLang && (strcmp(picoProp_currLang, picoSupportedLang[langIndex]) == 0)) {
- LOGI("Language already loaded (%s == %s)", picoProp_currLang, picoSupportedLang[langIndex]);
- return TTS_SUCCESS;
+ if (langIndex>=0) {
+ /* If we already have a loaded locale, check whether it is the same one as requested. */
+ if (picoProp_currLang && (strcmp(picoProp_currLang, picoSupportedLang[langIndex]) == 0)) {
+ LOGI("Language already loaded (%s == %s)", picoProp_currLang,
+ picoSupportedLang[langIndex]);
+ return TTS_SUCCESS;
+ }
}
- /* It is not the same locale; unload the current one first. */
+ /* It is not the same locale; unload the current one first. Also invalidates the system object*/
cleanResources();
/* Allocate memory for file and resource names. */
cleanFiles();
+
+ if (picoSystem==NULL) {
+ /*re-init system object*/
+ ret = pico_initialize( picoMemArea, PICO_MEM_SIZE, &picoSystem );
+ if (PICO_OK != ret) {
+ LOGE("Failed to initialize the pico system object\n");
+ return TTS_FAILURE;
+ }
+ }
+
picoProp_currLang = (char *) malloc( 10 );
picoTaFileName = (pico_Char *) malloc( PICO_MAX_DATAPATH_NAME_SIZE + PICO_MAX_FILE_NAME_SIZE );
picoSgFileName = (pico_Char *) malloc( PICO_MAX_DATAPATH_NAME_SIZE + PICO_MAX_FILE_NAME_SIZE );
@@ -287,6 +305,16 @@ static tts_result doLanguageSwitchFromLangIndex( int langIndex )
picoSgResourceName = (pico_Char *) malloc( PICO_MAX_RESOURCE_NAME_SIZE );
picoUtppResourceName =(pico_Char *) malloc( PICO_MAX_RESOURCE_NAME_SIZE );
+ if (
+ (picoProp_currLang==NULL) || (picoTaFileName==NULL) || (picoSgFileName==NULL) ||
+ (picoUtppFileName==NULL) || (picoTaResourceName==NULL) || (picoSgResourceName==NULL) ||
+ (picoUtppResourceName==NULL)
+ ) {
+ LOGE("Failed to allocate memory for internal strings\n");
+ cleanResources();
+ return TTS_FAILURE;
+ }
+
/* Set the path and file names for resource files. */
strcpy((char *) picoTaFileName, PICO_LINGWARE_PATH);
strcat((char *) picoTaFileName, (const char *) picoInternalTaLingware[langIndex]);
@@ -815,13 +843,6 @@ tts_result TtsEngine::init( synthDoneCB_t synthDoneCBPtr )
picoSynthDoneCBPtr = synthDoneCBPtr;
- // TODO: Remove this workaround once a proper fix is made to the underlying
- // Pico engine. This workaround is currently needed as there is a problem
- // switching languages if the first language that the engine is set to is
- // not English. As long as the first language is English, switching to other
- // languages after that will work fine.
- doLanguageSwitchFromLangIndex(0);
-
picoCurrentLangIndex = -1;
return TTS_SUCCESS;