am 0d430593: Merge change 23108 into eclair

Merge commit '0d430593ee07b78894eff8b78f559d2591a94287' into eclair-plus-aosp

* commit '0d430593ee07b78894eff8b78f559d2591a94287':
  Launch synthesis thread at max priority to prevent hicups in playback.
This commit is contained in:
Jean-Michel Trivi
2009-08-28 10:46:00 -07:00
committed by Android Git Automerger

View File

@@ -148,7 +148,7 @@ public class TtsService extends Service implements OnCompletionListener {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
Log.i("TtsService", "TtsService.onCreate()"); Log.v("TtsService", "TtsService.onCreate()");
mResolver = getContentResolver(); mResolver = getContentResolver();
@@ -279,7 +279,6 @@ public class TtsService extends Service implements OnCompletionListener {
private int isLanguageAvailable(String lang, String country, String variant) { private int isLanguageAvailable(String lang, String country, String variant) {
//Log.v("TtsService", "TtsService.isLanguageAvailable(" + lang + ", " + country + ", " +variant+")");
int res = TextToSpeech.LANG_NOT_SUPPORTED; int res = TextToSpeech.LANG_NOT_SUPPORTED;
try { try {
res = sNativeSynth.isLanguageAvailable(lang, country, variant); res = sNativeSynth.isLanguageAvailable(lang, country, variant);
@@ -462,6 +461,9 @@ public class TtsService extends Service implements OnCompletionListener {
result = TextToSpeech.SUCCESS; result = TextToSpeech.SUCCESS;
} }
Log.i("TtsService", "Stopped"); Log.i("TtsService", "Stopped");
} else {
Log.e("TtsService", "TTS stop(): queue locked longer than expected");
result = TextToSpeech.ERROR;
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e("TtsService", "TTS stop: tryLock interrupted"); Log.e("TtsService", "TTS stop: tryLock interrupted");
@@ -575,6 +577,9 @@ public class TtsService extends Service implements OnCompletionListener {
result = TextToSpeech.SUCCESS; result = TextToSpeech.SUCCESS;
} }
Log.i("TtsService", "Stopped all"); Log.i("TtsService", "Stopped all");
} else {
Log.e("TtsService", "TTS stopAll(): queue locked longer than expected");
result = TextToSpeech.ERROR;
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e("TtsService", "TTS stopAll: tryLock interrupted"); Log.e("TtsService", "TTS stopAll: tryLock interrupted");
@@ -725,7 +730,7 @@ public class TtsService extends Service implements OnCompletionListener {
} }
} }
Thread synth = (new Thread(new SynthThread())); Thread synth = (new Thread(new SynthThread()));
//synth.setPriority(Thread.MIN_PRIORITY); synth.setPriority(Thread.MAX_PRIORITY);
synth.start(); synth.start();
} }
@@ -799,7 +804,7 @@ public class TtsService extends Service implements OnCompletionListener {
} }
} }
Thread synth = (new Thread(new SynthThread())); Thread synth = (new Thread(new SynthThread()));
//synth.setPriority(Thread.MIN_PRIORITY); synth.setPriority(Thread.MAX_PRIORITY);
synth.start(); synth.start();
} }
@@ -827,7 +832,7 @@ public class TtsService extends Service implements OnCompletionListener {
if (cb == null){ if (cb == null){
return; return;
} }
Log.i("TtsService", "TTS callback: dispatch started"); Log.v("TtsService", "TTS callback: dispatch started");
// Broadcast to all clients the new value. // Broadcast to all clients the new value.
final int N = mCallbacks.beginBroadcast(); final int N = mCallbacks.beginBroadcast();
try { try {
@@ -837,7 +842,7 @@ public class TtsService extends Service implements OnCompletionListener {
// the dead object for us. // the dead object for us.
} }
mCallbacks.finishBroadcast(); mCallbacks.finishBroadcast();
Log.i("TtsService", "TTS callback: dispatch completed to " + N); Log.v("TtsService", "TTS callback: dispatch completed to " + N);
} }
private SpeechItem splitCurrentTextIfNeeded(SpeechItem currentSpeechItem){ private SpeechItem splitCurrentTextIfNeeded(SpeechItem currentSpeechItem){
@@ -888,7 +893,7 @@ public class TtsService extends Service implements OnCompletionListener {
SoundResource sr = getSoundResource(mCurrentSpeechItem); SoundResource sr = getSoundResource(mCurrentSpeechItem);
// Synth speech as needed - synthesizer should call // Synth speech as needed - synthesizer should call
// processSpeechQueue to continue running the queue // processSpeechQueue to continue running the queue
Log.i("TtsService", "TTS processing: " + mCurrentSpeechItem.mText); Log.v("TtsService", "TTS processing: " + mCurrentSpeechItem.mText);
if (sr == null) { if (sr == null) {
if (mCurrentSpeechItem.mType == SpeechItem.TEXT) { if (mCurrentSpeechItem.mType == SpeechItem.TEXT) {
mCurrentSpeechItem = splitCurrentTextIfNeeded(mCurrentSpeechItem); mCurrentSpeechItem = splitCurrentTextIfNeeded(mCurrentSpeechItem);