summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2011-07-18 02:52:35 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-07-18 02:52:35 -0700
commitf564ed8792b9d92f7f3dee8928caa7380d330836 (patch)
treeaba9ba153deccad6cc9bb2d5515fcc7d85f0824e /core/java/android
parent3bfa72b119f1e701aeb9a80c59ba1d8e65f263c6 (diff)
parentc34f76fe89b5a31d01d63067c2f24b9a6a76df18 (diff)
downloadframeworks_base-f564ed8792b9d92f7f3dee8928caa7380d330836.zip
frameworks_base-f564ed8792b9d92f7f3dee8928caa7380d330836.tar.gz
frameworks_base-f564ed8792b9d92f7f3dee8928caa7380d330836.tar.bz2
Merge "Improve TextToSpeech#isSpeaking()"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/speech/tts/AudioPlaybackHandler.java8
-rwxr-xr-xcore/java/android/speech/tts/TextToSpeech.java10
-rw-r--r--core/java/android/speech/tts/TextToSpeechService.java2
3 files changed, 18 insertions, 2 deletions
diff --git a/core/java/android/speech/tts/AudioPlaybackHandler.java b/core/java/android/speech/tts/AudioPlaybackHandler.java
index dea708a..d6e16a5 100644
--- a/core/java/android/speech/tts/AudioPlaybackHandler.java
+++ b/core/java/android/speech/tts/AudioPlaybackHandler.java
@@ -104,6 +104,14 @@ class AudioPlaybackHandler {
}
/**
+ * @return false iff the queue is empty and no queue item is currently
+ * being handled, true otherwise.
+ */
+ public boolean isSpeaking() {
+ return (mQueue.peek() != null) || (mCurrentParams != null);
+ }
+
+ /**
* Shut down the audio playback thread.
*/
synchronized public void quit() {
diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java
index 32ca226..a9e5bbb 100755
--- a/core/java/android/speech/tts/TextToSpeech.java
+++ b/core/java/android/speech/tts/TextToSpeech.java
@@ -109,6 +109,11 @@ public class TextToSpeech {
/**
* Broadcast Action: The TextToSpeech synthesizer has completed processing
* of all the text in the speech queue.
+ *
+ * Note that this notifies callers when the <b>engine</b> has finished has
+ * processing text data. Audio playback might not have completed (or even started)
+ * at this point. If you wish to be notified when this happens, see
+ * {@link OnUtteranceCompletedListener}.
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_TTS_QUEUE_PROCESSING_COMPLETED =
@@ -796,7 +801,10 @@ public class TextToSpeech {
}
/**
- * Checks whether the TTS engine is busy speaking.
+ * Checks whether the TTS engine is busy speaking. Note that a speech item is
+ * considered complete once it's audio data has been sent to the audio mixer, or
+ * written to a file. There might be a finite lag between this point, and when
+ * the audio hardware completes playback.
*
* @return {@code true} if the TTS engine is speaking.
*/
diff --git a/core/java/android/speech/tts/TextToSpeechService.java b/core/java/android/speech/tts/TextToSpeechService.java
index 010c155..cf56e03 100644
--- a/core/java/android/speech/tts/TextToSpeechService.java
+++ b/core/java/android/speech/tts/TextToSpeechService.java
@@ -719,7 +719,7 @@ public abstract class TextToSpeechService extends Service {
}
public boolean isSpeaking() {
- return mSynthHandler.isSpeaking();
+ return mSynthHandler.isSpeaking() || mAudioPlaybackHandler.isSpeaking();
}
public int stop(String callingApp) {