Now uses a queue of runnables, one per synthesis. Also
introduce an abstraction that wraps AudioTrack that implements
the blocking semantics that we desire.
bug:5680699
Change-Id: I34a1248ff05766a7d9b3002055fb5b24aa9f230b
When stop() is called twice or after done().This relates
to bug 5662598 because users using the old deprecated API
will see two calls to onUtteranceCompleted.
bug:5662598
Change-Id: I5d59cf66b4f4c8650d3f8f9e503ac3f33132c0d0
We now use an IBinder object as an identity token of the
caller instead of Context#getPackageName.
bug:5680696
Change-Id: I1ca29e7161f709d2a85218206f3f117dfa620282
The TTS instantiated from here shouldn't clobber any
existing TTS objects opened within the same package context.
Ideally, the TTS API should work fine with multiple TTS object
instances within the same package context but making that happen
correctly is a larger change.
bug:5659758
Change-Id: Ia1f63c61b9f12ac92ff42a427a004d414e42a759
(a) onUtteranceCompleted should be called on errors too. Also,
fix up the error handling so that onUtteranceCompleted is
always called.
(b) Don't treat empty utterances as errors, and let the engine
synthesize them, as before.
bug:5662598
Change-Id: I9223592bc6fe5f47d71103f4f02f046b54a655a8
When synthesized files are written to app private data dirs,
they are written with owner/grp set to the TTS engine and
are inaccessible by the app itself. This is a reported regression
from gingerbread behaviour. Note that the dir in which the
engine writes files is itself already world writable.
bug:5523587
Change-Id: I2cb26c6f3c3d9cb3cedd60fab32c99a85a27f4b1
Also explicitly disallow locales with empty countries. This
is required to match them against the set of engine supported
locales.
bug:5309930
Change-Id: Ie9714fdc09d3081081a2393d97c31e3a42bca294
(a) Fix a null pointer exception, caused by a race condition
between stop / start calls.
(b) Fix a deadlock observed when multiple apps call stop() when
an item from one of those apps is currently being processed.
bug:5253061
Change-Id: I78533aecfda028588ce6aedb041009bc0a6f4620
This is made necessary by a bug when the utterance is smaller
than the audio buffer size. In that case, we call stop() to
flush the audio to the mixer, but that causes the playstate to
be set to stopped though some audio is still being mixed. This
breaks our waiting loop.
We now wait a fixed amount of time for such short utterances
and do not observe the playback head position.
bug:5220048
Change-Id: Ic81dec751c1faca0b14164caeda6305c8f9815fe
For each synthesis request, we inspect the number of
bytes of audio that have not been written to the mixer yet
and if that is above a certain threshold (currently 500ms),
we block the synthesis thread.
bug:5214603
Change-Id: I24c64c48466bdb96ce47b34cee7da2523ee5f0eb
It's at a very high priority currently - and will trump
foreground processes (and UI threads) which it shouldnt.
bug:5076001
Change-Id: I0d71c2941950782491ae31526a47ea6f97c38ffb
(a) Call stop() when we've written less than the
AudioTrack buffer. This forces pending buffers to
get mixed.
(b) Introduce a minimum sleep time to avoid spinlocks
if they system is busy
Change-Id: If70937e8b4e8c5d02d7dadc0d3086f97a10eb7ef
Also fixes a bug where PlaybackSynthesisCallback would
continue to pump audio to the audio playback thread after
being stopped.
Change-Id: I3233eb4858245b6e7c7df72e241a0708c668f1b4
Measurements have shown that the audio track in streaming mode
is pretty efficient as is, thanks to dalvik's JNI implementation.
Also, in streaming mode write( ) blocks until all data has been
copied to the mixer, which is the kind of behaviour we want so
that we don't have to explicitly block in our code. Also,
the java AudioTrack is thread-safe with respect to stop( ) calls
during write, which means we can do everything completeAudioAvailable
did, just as efficiently without it.
Change-Id: I70a8a108d94c7260676673979b5ea29f37fa5db4
(a) Fix an NPE reported when no TTS engine is installed.
(b) Fix a bad link, and some javadoc typos.
bug: 5004015
Change-Id: I38b97dbb5d7d4065a5ee408fae9138638ed48f40
Engines must declare a <meta-data> attribute in their
manifest with name "android.speech.tts". This must reference
an XML resource as per
com.android.internal.R.styleable.TextToSpeechEngine.
Change-Id: I56a6b9f1a360174f98c9f39da901ade83d0f38a7
This has been discussed in an email thread. This brings the
text to speech API in line with other android APIs.
The user can set default speech rates / languages and
engine preferences, which the API obeys BUT these can be
overriden by individual apps (much like intent.setComponent
and intent.setClassName can be used to launch a specific
handler for a given intent).
Also, all installed engines are enabled by default. The
user is shown the "data privacy" warning every time an
installed engine is set to the default.
Change-Id: I24f5f331b3a7cc7ce1a62962192e3a452bdca9d4
This makes it a lot easier for engine implementers
to test their engine. This is a dumb data object, and
contains no logic whatsoever.
Change-Id: I2a8bea134a8ff6b962508cfed67ea6085a682b23
(a) ensure that onInit is called exactly once per call to initTts().
(b) TtsEngines should never return an engine that is not installed.
Change-Id: Ic1ef63a9339e6d1050e3302445ca40d3ae481f61
One point to note is that no TTS engine will be selected
by default if there are no system TTS engines.
Change-Id: I397061e3cf29b8a1c66e7864262b43621ef5100d
(a) Document the undocumented queue mode (mode == 2)
(b) intern strings to fix a bug in removeCallbacksAndMessages
(c) remove an unnecessarly lock object, change the field it
guarded to volatile.
Change-Id: If46bbfe2afb047b3ba5b3cb9a90c292656379ec1
Note that this change is slightly more flexible, it defines
a priority for each playback request. We needn't really throw
away synthesis requests from other apps. We could just play
them after higher priority ones (for e.g from talkback).
Change-Id: I6c7dd9abe4871e87da08d9aaa4c55225a69078e5
This ended up making the implementation a lot cleaner
as well. See the bug listed below for some background.
bug:4553470
Change-Id: If16476a57e389c2f9b228f6548e426642d292b49
There is no point loading a language that will never be used.
It is in fact harmful, because the engine might load it and
then receive a request for the default voice and have to load
the default voice again.
Change-Id: I8082f28d15b6e325d6a39d439b66753711a2c244
Now, SynthesisRequest.audioAvailable( ) will not block
until all data has been written to the audiotrack.
Change-Id: Ie24c0b6873ae44659e88646fb7ef821750dc314e