Revert "Fix bug 2025765."

This reverts commit 9ebb59b8aa.
This commit is contained in:
Jean-Michel Trivi
2009-08-04 09:23:18 -07:00
parent 0781f7ace1
commit fbe89ec640

View File

@@ -142,8 +142,6 @@ public class TtsService extends Service implements OnCompletionListener {
private final ReentrantLock synthesizerLock = new ReentrantLock(); private final ReentrantLock synthesizerLock = new ReentrantLock();
private static SynthProxy sNativeSynth = null; private static SynthProxy sNativeSynth = null;
private static Boolean sIsKillingSynth = true;
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
@@ -154,7 +152,6 @@ public class TtsService extends Service implements OnCompletionListener {
String soLibPath = "/system/lib/libttspico.so"; String soLibPath = "/system/lib/libttspico.so";
if (sNativeSynth == null) { if (sNativeSynth == null) {
sNativeSynth = new SynthProxy(soLibPath); sNativeSynth = new SynthProxy(soLibPath);
sIsKillingSynth = false;
} }
mSelf = this; mSelf = this;
@@ -175,9 +172,6 @@ public class TtsService extends Service implements OnCompletionListener {
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
sIsKillingSynth = true;
Log.i("TtsService", "TtsService.onDestroy()");
// Don't hog the media player // Don't hog the media player
cleanUpPlayer(); cleanUpPlayer();
@@ -186,7 +180,6 @@ public class TtsService extends Service implements OnCompletionListener {
// Unregister all callbacks. // Unregister all callbacks.
mCallbacks.kill(); mCallbacks.kill();
//Log.i("TtsService", "TtsService.onDestroy() ended");
} }
@@ -250,9 +243,6 @@ public class TtsService extends Service implements OnCompletionListener {
private int setSpeechRate(String callingApp, int rate) { private int setSpeechRate(String callingApp, int rate) {
if (sIsKillingSynth) {
return TextToSpeech.ERROR;
}
if (isDefaultEnforced()) { if (isDefaultEnforced()) {
return sNativeSynth.setSpeechRate(getDefaultRate()); return sNativeSynth.setSpeechRate(getDefaultRate());
} else { } else {
@@ -262,37 +252,23 @@ public class TtsService extends Service implements OnCompletionListener {
private int setPitch(String callingApp, int pitch) { private int setPitch(String callingApp, int pitch) {
if (sIsKillingSynth) {
return TextToSpeech.ERROR;
}
return sNativeSynth.setPitch(pitch); return sNativeSynth.setPitch(pitch);
} }
private int isLanguageAvailable(String lang, String country, String variant) { private int isLanguageAvailable(String lang, String country, String variant) {
if (sIsKillingSynth) {
return TextToSpeech.LANG_NOT_SUPPORTED;
}
//Log.v("TtsService", "TtsService.isLanguageAvailable(" + lang + ", " + country + ", " +variant+")"); //Log.v("TtsService", "TtsService.isLanguageAvailable(" + lang + ", " + country + ", " +variant+")");
return sNativeSynth.isLanguageAvailable(lang, country, variant); return sNativeSynth.isLanguageAvailable(lang, country, variant);
} }
private String[] getLanguage() { private String[] getLanguage() {
if (sIsKillingSynth) {
Log.v("TtsService", "killing synth:: aborting getLanguage()");
return null;
}
return sNativeSynth.getLanguage(); return sNativeSynth.getLanguage();
} }
private int setLanguage(String callingApp, String lang, String country, String variant) { private int setLanguage(String callingApp, String lang, String country, String variant) {
Log.v("TtsService", "TtsService.setLanguage(" + lang + ", " + country + ", " + variant + ")"); Log.v("TtsService", "TtsService.setLanguage(" + lang + ", " + country + ", " + variant + ")");
if (sIsKillingSynth) {
Log.v("TtsService", "killing synth:: aborting setLanguage()");
return TextToSpeech.ERROR;
}
if (isDefaultEnforced()) { if (isDefaultEnforced()) {
return sNativeSynth.setLanguage(getDefaultLanguage(), getDefaultCountry(), return sNativeSynth.setLanguage(getDefaultLanguage(), getDefaultCountry(),
getDefaultLocVariant()); getDefaultLocVariant());
@@ -426,12 +402,7 @@ public class TtsService extends Service implements OnCompletionListener {
} }
if ((mCurrentSpeechItem != null) && if ((mCurrentSpeechItem != null) &&
mCurrentSpeechItem.mCallingApp.equals(callingApp)) { mCurrentSpeechItem.mCallingApp.equals(callingApp)) {
if (sIsKillingSynth) { result = sNativeSynth.stop();
Log.v("TtsService", "killing synth:: aborting stop()");
result = TextToSpeech.ERROR;
} else {
result = sNativeSynth.stop();
}
mKillList.put(mCurrentSpeechItem, true); mKillList.put(mCurrentSpeechItem, true);
if (mPlayer != null) { if (mPlayer != null) {
try { try {
@@ -480,12 +451,7 @@ public class TtsService extends Service implements OnCompletionListener {
if ((mCurrentSpeechItem != null) && if ((mCurrentSpeechItem != null) &&
((mCurrentSpeechItem.mType != SpeechItem.TEXT_TO_FILE) || ((mCurrentSpeechItem.mType != SpeechItem.TEXT_TO_FILE) ||
mCurrentSpeechItem.mCallingApp.equals(callingApp))) { mCurrentSpeechItem.mCallingApp.equals(callingApp))) {
if (sIsKillingSynth) { result = sNativeSynth.stop();
Log.v("TtsService", "killing synth:: aborting stop()");
result = TextToSpeech.ERROR;
} else {
result = sNativeSynth.stop();
}
mKillList.put(mCurrentSpeechItem, true); mKillList.put(mCurrentSpeechItem, true);
if (mPlayer != null) { if (mPlayer != null) {
try { try {
@@ -625,9 +591,7 @@ public class TtsService extends Service implements OnCompletionListener {
if (speechRate.length() > 0){ if (speechRate.length() > 0){
setSpeechRate("", Integer.parseInt(speechRate)); setSpeechRate("", Integer.parseInt(speechRate));
} }
if (!sIsKillingSynth) { sNativeSynth.speak(speechItem.mText, streamType);
sNativeSynth.speak(speechItem.mText, streamType);
}
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e("TtsService", "TTS speakInternalOnly(): tryLock interrupted"); Log.e("TtsService", "TTS speakInternalOnly(): tryLock interrupted");
@@ -696,9 +660,7 @@ public class TtsService extends Service implements OnCompletionListener {
if (speechRate.length() > 0){ if (speechRate.length() > 0){
setSpeechRate("", Integer.parseInt(speechRate)); setSpeechRate("", Integer.parseInt(speechRate));
} }
if (!sIsKillingSynth) { sNativeSynth.synthesizeToFile(speechItem.mText, speechItem.mFilename);
sNativeSynth.synthesizeToFile(speechItem.mText, speechItem.mFilename);
}
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e("TtsService", "TTS synthToFileInternalOnly(): tryLock interrupted"); Log.e("TtsService", "TTS synthToFileInternalOnly(): tryLock interrupted");