From dd1501a7191f7be46c119296ae5bcf2c3dc6e5e8 Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Wed, 29 Jul 2009 15:07:38 -0700 Subject: 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). --- pico/tts/com_svox_picottsengine.cpp | 45 +++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'pico') 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; -- cgit v1.1