diff options
| author | 2009-07-13 09:27:44 -0700 | |
|---|---|---|
| committer | 2009-07-13 09:27:44 -0700 | |
| commit | c8050f8dd7dcfe97d2a61b5bcabe5a76a84a8123 (patch) | |
| tree | 8b754fdbdf2ccd67c4dbef7a8acbe3405facebbe | |
| parent | b0edcb1229b6ad4c1e5d8e6caaea807b29090de7 (diff) | |
| parent | 6cdc4f9c00eafcecec74dbd7f74202508830fdd3 (diff) | |
am 6cdc4f9c: Merge change 6880 into donut
Merge commit '6cdc4f9c00eafcecec74dbd7f74202508830fdd3'
* commit '6cdc4f9c00eafcecec74dbd7f74202508830fdd3':
Fixing TTS breakage.
| -rw-r--r-- | core/java/android/speech/tts/TextToSpeech.java | 144 | ||||
| -rwxr-xr-x | packages/TtsService/src/android/tts/TtsService.java | 39 |
2 files changed, 155 insertions, 28 deletions
diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java index 38b7b79c50d9..2369535cfcf1 100644 --- a/core/java/android/speech/tts/TextToSpeech.java +++ b/core/java/android/speech/tts/TextToSpeech.java @@ -281,14 +281,20 @@ public class TextToSpeech { return TTS_SUCCESS; } catch (RemoteException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - addSpeech", "RemoteException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - addSpeech", "NullPointerException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - addSpeech", "IllegalStateException"); + e.printStackTrace(); mStarted = false; initTts(); } @@ -319,14 +325,20 @@ public class TextToSpeech { return TTS_SUCCESS; } catch (RemoteException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - addSpeech", "RemoteException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - addSpeech", "NullPointerException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - addSpeech", "IllegalStateException"); + e.printStackTrace(); mStarted = false; initTts(); } @@ -361,25 +373,33 @@ public class TextToSpeech { return result; } try { - String extra = params.get(Engine.TTS_KEY_PARAM_STREAM); - if (extra != null) { - mCachedParams[Engine.TTS_PARAM_POSITION_STREAM + 1] = extra; - } - extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID); - if (extra != null) { - mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; + if ((params != null) && (!params.isEmpty())) { + String extra = params.get(Engine.TTS_KEY_PARAM_STREAM); + if (extra != null) { + mCachedParams[Engine.TTS_PARAM_POSITION_STREAM + 1] = extra; + } + extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID); + if (extra != null) { + mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; + } } result = mITts.speak(mPackageName, text, queueMode, mCachedParams); } catch (RemoteException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - speak", "RemoteException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - speak", "NullPointerException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - speak", "IllegalStateException"); + e.printStackTrace(); mStarted = false; initTts(); } finally { @@ -423,14 +443,20 @@ public class TextToSpeech { result = mITts.playEarcon(mPackageName, earcon, queueMode, null); } catch (RemoteException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - playEarcon", "RemoteException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - playEarcon", "NullPointerException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - playEarcon", "IllegalStateException"); + e.printStackTrace(); mStarted = false; initTts(); } finally { @@ -461,14 +487,20 @@ public class TextToSpeech { result = mITts.playSilence(mPackageName, durationInMs, queueMode, mCachedParams); } catch (RemoteException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - playSilence", "RemoteException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - playSilence", "NullPointerException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - playSilence", "IllegalStateException"); + e.printStackTrace(); mStarted = false; initTts(); } finally { @@ -492,14 +524,20 @@ public class TextToSpeech { return mITts.isSpeaking(); } catch (RemoteException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - isSpeaking", "RemoteException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - isSpeaking", "NullPointerException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - isSpeaking", "IllegalStateException"); + e.printStackTrace(); mStarted = false; initTts(); } @@ -523,14 +561,20 @@ public class TextToSpeech { result = mITts.stop(mPackageName); } catch (RemoteException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - stop", "RemoteException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - stop", "NullPointerException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - stop", "IllegalStateException"); + e.printStackTrace(); mStarted = false; initTts(); } finally { @@ -569,6 +613,20 @@ public class TextToSpeech { } } catch (RemoteException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - setSpeechRate", "RemoteException"); + e.printStackTrace(); + mStarted = false; + initTts(); + } catch (NullPointerException e) { + // TTS died; restart it. + Log.e("TextToSpeech.java - setSpeechRate", "NullPointerException"); + e.printStackTrace(); + mStarted = false; + initTts(); + } catch (IllegalStateException e) { + // TTS died; restart it. + Log.e("TextToSpeech.java - setSpeechRate", "IllegalStateException"); + e.printStackTrace(); mStarted = false; initTts(); } finally { @@ -605,6 +663,20 @@ public class TextToSpeech { } } catch (RemoteException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - setPitch", "RemoteException"); + e.printStackTrace(); + mStarted = false; + initTts(); + } catch (NullPointerException e) { + // TTS died; restart it. + Log.e("TextToSpeech.java - setPitch", "NullPointerException"); + e.printStackTrace(); + mStarted = false; + initTts(); + } catch (IllegalStateException e) { + // TTS died; restart it. + Log.e("TextToSpeech.java - setPitch", "IllegalStateException"); + e.printStackTrace(); mStarted = false; initTts(); } finally { @@ -642,6 +714,20 @@ public class TextToSpeech { mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT + 1] ); } catch (RemoteException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - setLanguage", "RemoteException"); + e.printStackTrace(); + mStarted = false; + initTts(); + } catch (NullPointerException e) { + // TTS died; restart it. + Log.e("TextToSpeech.java - setLanguage", "NullPointerException"); + e.printStackTrace(); + mStarted = false; + initTts(); + } catch (IllegalStateException e) { + // TTS died; restart it. + Log.e("TextToSpeech.java - setLanguage", "IllegalStateException"); + e.printStackTrace(); mStarted = false; initTts(); } finally { @@ -670,6 +756,20 @@ public class TextToSpeech { } } catch (RemoteException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - getLanguage", "RemoteException"); + e.printStackTrace(); + mStarted = false; + initTts(); + } catch (NullPointerException e) { + // TTS died; restart it. + Log.e("TextToSpeech.java - getLanguage", "NullPointerException"); + e.printStackTrace(); + mStarted = false; + initTts(); + } catch (IllegalStateException e) { + // TTS died; restart it. + Log.e("TextToSpeech.java - getLanguage", "IllegalStateException"); + e.printStackTrace(); mStarted = false; initTts(); } @@ -697,6 +797,20 @@ public class TextToSpeech { loc.getISO3Country(), loc.getVariant()); } catch (RemoteException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - isLanguageAvailable", "RemoteException"); + e.printStackTrace(); + mStarted = false; + initTts(); + } catch (NullPointerException e) { + // TTS died; restart it. + Log.e("TextToSpeech.java - isLanguageAvailable", "NullPointerException"); + e.printStackTrace(); + mStarted = false; + initTts(); + } catch (IllegalStateException e) { + // TTS died; restart it. + Log.e("TextToSpeech.java - isLanguageAvailable", "IllegalStateException"); + e.printStackTrace(); mStarted = false; initTts(); } finally { @@ -727,24 +841,32 @@ public class TextToSpeech { return result; } try { - // no need to read the stream type here - String extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID); - if (extra != null) { - mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; + if ((params != null) && (!params.isEmpty())) { + // no need to read the stream type here + String extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID); + if (extra != null) { + mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; + } } if (mITts.synthesizeToFile(mPackageName, text, mCachedParams, filename)){ result = TTS_SUCCESS; } } catch (RemoteException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - synthesizeToFile", "RemoteException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - synthesizeToFile", "NullPointerException"); + e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. + Log.e("TextToSpeech.java - synthesizeToFile", "IllegalStateException"); + e.printStackTrace(); mStarted = false; initTts(); } finally { diff --git a/packages/TtsService/src/android/tts/TtsService.java b/packages/TtsService/src/android/tts/TtsService.java index ea224103d741..60c30b2b84e4 100755 --- a/packages/TtsService/src/android/tts/TtsService.java +++ b/packages/TtsService/src/android/tts/TtsService.java @@ -132,7 +132,7 @@ public class TtsService extends Service implements OnCompletionListener { @Override public void onCreate() { super.onCreate(); - //Log.i("TTS", "TTS starting"); + Log.i("TTS", "TTS starting"); mResolver = getContentResolver(); @@ -326,6 +326,7 @@ public class TtsService extends Service implements OnCompletionListener { * engines. */ private int speak(String callingApp, String text, int queueMode, ArrayList<String> params) { + Log.i("TTS service received", text); if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) { stop(callingApp); } @@ -455,14 +456,16 @@ public class TtsService extends Service implements OnCompletionListener { String variant = ""; for (int i = 0; i < params.size() - 1; i = i + 2){ String param = params.get(i); - if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ - setSpeechRate("", Integer.parseInt(params.get(i+1))); - } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ - language = params.get(i+1); - } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){ - country = params.get(i+1); - } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){ - variant = params.get(i+1); + if (param != null){ + if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ + setSpeechRate("", Integer.parseInt(params.get(i+1))); + } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ + language = params.get(i+1); + } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){ + country = params.get(i+1); + } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){ + variant = params.get(i+1); + } } } if (language.length() > 0){ @@ -510,14 +513,16 @@ public class TtsService extends Service implements OnCompletionListener { String variant = ""; for (int i = 0; i < params.size() - 1; i = i + 2){ String param = params.get(i); - if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ - setSpeechRate("", Integer.parseInt(params.get(i+1))); - } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ - language = params.get(i+1); - } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){ - country = params.get(i+1); - } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){ - variant = params.get(i+1); + if (param != null){ + if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ + setSpeechRate("", Integer.parseInt(params.get(i+1))); + } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ + language = params.get(i+1); + } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){ + country = params.get(i+1); + } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){ + variant = params.get(i+1); + } } } if (language.length() > 0){ |