Merge change Iab089078 into eclair-mr2

* changes:
  Fix for a race condition that can occur if an utterance is stopped right when it completes.
This commit is contained in:
Android (Google) Code Review
2009-12-22 17:39:57 -08:00

View File

@@ -596,22 +596,27 @@ 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.
String utteranceId = ""; SpeechItem currentSpeechItemCopy = mCurrentSpeechItem;
if (params != null){ if (currentSpeechItemCopy != null) {
for (int i = 0; i < params.size() - 1; i = i + 2){ String callingApp = currentSpeechItemCopy.mCallingApp;
String param = params.get(i); ArrayList<String> params = currentSpeechItemCopy.mParams;
if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)){ String utteranceId = "";
utteranceId = params.get(i+1); if (params != null) {
} for (int i = 0; i < params.size() - 1; i = i + 2) {
} String param = params.get(i);
} if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)) {
if (utteranceId.length() > 0){ utteranceId = params.get(i + 1);
dispatchUtteranceCompletedCallback(utteranceId, callingApp); }
} }
processSpeechQueue(); }
if (utteranceId.length() > 0) {
dispatchUtteranceCompletedCallback(utteranceId, callingApp);
}
}
processSpeechQueue();
} }
private int playSilence(String callingApp, long duration, int queueMode, private int playSilence(String callingApp, long duration, int queueMode,