diff options
| author | 2009-07-14 18:22:15 -0700 | |
|---|---|---|
| committer | 2009-07-14 18:22:15 -0700 | |
| commit | b197021e160091897391cd27093c35bd3c22a7fc (patch) | |
| tree | 728210bbb1fa93a834b8eaca4c62dfc1e654c3f5 | |
| parent | 211aef308bc6ca55d99777d19227f412492db9c2 (diff) | |
| parent | 4a3368ffe87378ec9b62065fb5255d85c7552ccf (diff) | |
Merge change 7335 into donut
* changes:
Making sure that the audio buffers for speech are cleared so that there are no leftovers which could cause mangled output.
| -rw-r--r-- | packages/TtsService/jni/android_tts_SynthProxy.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/packages/TtsService/jni/android_tts_SynthProxy.cpp b/packages/TtsService/jni/android_tts_SynthProxy.cpp index 424748364fda..64cdb5b80160 100644 --- a/packages/TtsService/jni/android_tts_SynthProxy.cpp +++ b/packages/TtsService/jni/android_tts_SynthProxy.cpp @@ -84,6 +84,7 @@ class SynthProxyJniStorage { mNbChannels = DEFAULT_TTS_NB_CHANNELS; mBufferSize = DEFAULT_TTS_BUFFERSIZE; mBuffer = new int8_t[mBufferSize]; + memset(mBuffer, 0, mBufferSize); } ~SynthProxyJniStorage() { @@ -194,6 +195,7 @@ static tts_callback_status ttsSynthDoneCB(void *& userdata, uint32_t rate, prepAudioTrack(pJniData, pForAfter->streamType, rate, format, channel); if (pJniData->mAudioOut) { pJniData->mAudioOut->write(wav, bufferSize); + memset(wav, 0, bufferSize); //LOGV("AudioTrack wrote: %d bytes", bufferSize); } else { LOGE("Can't play, null audiotrack"); @@ -208,6 +210,7 @@ static tts_callback_status ttsSynthDoneCB(void *& userdata, uint32_t rate, } if (bufferSize > 0){ fwrite(wav, 1, bufferSize, pForAfter->outputFile); + memset(wav, 0, bufferSize); } } // Future update: @@ -473,6 +476,7 @@ android_tts_SynthProxy_synthesizeToFile(JNIEnv *env, jobject thiz, jint jniData, unsigned int unique_identifier; + memset(pSynthData->mBuffer, 0, pSynthData->mBufferSize); result = pSynthData->mNativeSynthInterface->synthesizeText(textNativeString, pSynthData->mBuffer, pSynthData->mBufferSize, (void *)pForAfter); @@ -554,6 +558,7 @@ android_tts_SynthProxy_speak(JNIEnv *env, jobject thiz, jint jniData, if (pSynthData->mNativeSynthInterface) { const char *textNativeString = env->GetStringUTFChars(textJavaString, 0); + memset(pSynthData->mBuffer, 0, pSynthData->mBufferSize); result = pSynthData->mNativeSynthInterface->synthesizeText(textNativeString, pSynthData->mBuffer, pSynthData->mBufferSize, (void *)pForAfter); env->ReleaseStringUTFChars(textJavaString, textNativeString); @@ -575,12 +580,12 @@ android_tts_SynthProxy_stop(JNIEnv *env, jobject thiz, jint jniData) SynthProxyJniStorage* pSynthData = (SynthProxyJniStorage*)jniData; - if (pSynthData->mNativeSynthInterface) { - result = pSynthData->mNativeSynthInterface->stop(); - } if (pSynthData->mAudioOut) { pSynthData->mAudioOut->stop(); } + if (pSynthData->mNativeSynthInterface) { + result = pSynthData->mNativeSynthInterface->stop(); + } return result; } |