am 4bc95d19: Merge change Iab089078 into eclair-mr2

Merge commit '4bc95d19c9ccf9cfe4c51b1e697db8cc1d86a579' into eclair-mr2-plus-aosp

* commit '4bc95d19c9ccf9cfe4c51b1e697db8cc1d86a579':
  Fix for a race condition that can occur if an utterance
This commit is contained in:
Charles Chen
2009-12-22 17:42:25 -08:00
committed by Android Git Automerger

View File

@@ -597,20 +597,25 @@ public class TtsService extends Service implements OnCompletionListener {
} }
public void onCompletion(MediaPlayer arg0) { public void onCompletion(MediaPlayer arg0) {
String callingApp = mCurrentSpeechItem.mCallingApp; // mCurrentSpeechItem may become null if it is stopped at the same
ArrayList<String> params = mCurrentSpeechItem.mParams; // time it completes.
SpeechItem currentSpeechItemCopy = mCurrentSpeechItem;
if (currentSpeechItemCopy != null) {
String callingApp = currentSpeechItemCopy.mCallingApp;
ArrayList<String> params = currentSpeechItemCopy.mParams;
String utteranceId = ""; String utteranceId = "";
if (params != null){ if (params != null) {
for (int i = 0; i < params.size() - 1; i = i + 2){ for (int i = 0; i < params.size() - 1; i = i + 2) {
String param = params.get(i); String param = params.get(i);
if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)){ if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)) {
utteranceId = params.get(i+1); utteranceId = params.get(i + 1);
} }
} }
} }
if (utteranceId.length() > 0){ if (utteranceId.length() > 0) {
dispatchUtteranceCompletedCallback(utteranceId, callingApp); dispatchUtteranceCompletedCallback(utteranceId, callingApp);
} }
}
processSpeechQueue(); processSpeechQueue();
} }