public void run() {
try {
Thread thisThread = Thread.currentThread();
running = true;
while (thisThread == blinker) {
SpeechRequest request = queue.take();
// If we aren't blocking and we aren't speaking or this is
// of greater priority, send off to the TTS engine.
// Otherwise, we ignore te request.
if (!block && (!speech.isSpeaking() ||
request.getPriority().compareTo(lastRequest.getPriority()) <= 0)) {
SpeechProcessor proc = request.getProcessor();
String textToSpeak = request.getText();
if (proc != null)
textToSpeak = proc.process();
if (textToSpeak != null && !textToSpeak.trim().isEmpty() && speechEnabled)
speech.speak(textToSpeak, request.getPriority(), request.getType());
// We don't want to log CHARACTER requests.
if (request.getType() != RequestType.CHARACTER)
lastRequest = request;
}
}
running = false;
blinker = null;