summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-12-22 17:39:57 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-12-22 17:39:57 -0800
commit4bc95d19c9ccf9cfe4c51b1e697db8cc1d86a579 (patch)
treef6a1b600a25d609f4c9095c13d811f5f4f0198a7 /packages
parent484d2888680e18e6ad8c3fcc51e3b70a705a096e (diff)
parentab089078b1d42f8ecf549669847b47c0c2c5854b (diff)
downloadframeworks_base-4bc95d19c9ccf9cfe4c51b1e697db8cc1d86a579.zip
frameworks_base-4bc95d19c9ccf9cfe4c51b1e697db8cc1d86a579.tar.gz
frameworks_base-4bc95d19c9ccf9cfe4c51b1e697db8cc1d86a579.tar.bz2
Merge change Iab089078 into eclair-mr2
* changes: Fix for a race condition that can occur if an utterance is stopped right when it completes.
Diffstat (limited to 'packages')
-rwxr-xr-xpackages/TtsService/src/android/tts/TtsService.java37
1 files changed, 21 insertions, 16 deletions
diff --git a/packages/TtsService/src/android/tts/TtsService.java b/packages/TtsService/src/android/tts/TtsService.java
index 217d3bb..5c4bbb8 100755
--- a/packages/TtsService/src/android/tts/TtsService.java
+++ b/packages/TtsService/src/android/tts/TtsService.java
@@ -596,22 +596,27 @@ public class TtsService extends Service implements OnCompletionListener {
}
}
- public void onCompletion(MediaPlayer arg0) {
- String callingApp = mCurrentSpeechItem.mCallingApp;
- ArrayList<String> params = mCurrentSpeechItem.mParams;
- String utteranceId = "";
- 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)){
- utteranceId = params.get(i+1);
- }
- }
- }
- if (utteranceId.length() > 0){
- dispatchUtteranceCompletedCallback(utteranceId, callingApp);
- }
- processSpeechQueue();
+ public void onCompletion(MediaPlayer arg0) {
+ // mCurrentSpeechItem may become null if it is stopped at the same
+ // time it completes.
+ SpeechItem currentSpeechItemCopy = mCurrentSpeechItem;
+ if (currentSpeechItemCopy != null) {
+ String callingApp = currentSpeechItemCopy.mCallingApp;
+ ArrayList<String> params = currentSpeechItemCopy.mParams;
+ String utteranceId = "";
+ 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)) {
+ utteranceId = params.get(i + 1);
+ }
+ }
+ }
+ if (utteranceId.length() > 0) {
+ dispatchUtteranceCompletedCallback(utteranceId, callingApp);
+ }
+ }
+ processSpeechQueue();
}
private int playSilence(String callingApp, long duration, int queueMode,