Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5fe1b30 authored by Narayan Kamath's avatar Narayan Kamath Committed by Android Git Automerger
Browse files

am 405fcc87: am 754c72ed: Notifiy callers when a speech synthesis error occurs.

* commit '405fcc87':
  Notifiy callers when a speech synthesis error occurs.
parents 99164b42 405fcc87
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -18892,7 +18892,8 @@ package android.speech.tts {
    method public int playSilence(long, int, java.util.HashMap<java.lang.String, java.lang.String>);
    method public deprecated int setEngineByPackageName(java.lang.String);
    method public int setLanguage(java.util.Locale);
    method public int setOnUtteranceCompletedListener(android.speech.tts.TextToSpeech.OnUtteranceCompletedListener);
    method public deprecated int setOnUtteranceCompletedListener(android.speech.tts.TextToSpeech.OnUtteranceCompletedListener);
    method public int setOnUtteranceProgressListener(android.speech.tts.UtteranceProgressListener);
    method public int setPitch(float);
    method public int setSpeechRate(float);
    method public void shutdown();
@@ -18965,6 +18966,13 @@ package android.speech.tts {
    method protected abstract void onSynthesizeText(android.speech.tts.SynthesisRequest, android.speech.tts.SynthesisCallback);
  }
  public abstract class UtteranceProgressListener {
    ctor public UtteranceProgressListener();
    method public abstract void onDone(java.lang.String);
    method public abstract void onError(java.lang.String);
    method public abstract void onStart(java.lang.String);
  }
}
package android.telephony {
+2 −2
Original line number Diff line number Diff line
@@ -15,12 +15,12 @@
 */
package android.speech.tts;

import android.speech.tts.TextToSpeechService.UtteranceCompletedDispatcher;
import android.speech.tts.TextToSpeechService.UtteranceProgressDispatcher;

class AudioMessageParams extends MessageParams {
    private final BlockingMediaPlayer mPlayer;

    AudioMessageParams(UtteranceCompletedDispatcher dispatcher,
    AudioMessageParams(UtteranceProgressDispatcher dispatcher,
            String callingApp, BlockingMediaPlayer player) {
        super(dispatcher, callingApp);
        mPlayer = player;
+7 −3
Original line number Diff line number Diff line
@@ -312,10 +312,11 @@ class AudioPlaybackHandler {
    private void handleSilence(MessageParams msg) {
        if (DBG) Log.d(TAG, "handleSilence()");
        SilenceMessageParams params = (SilenceMessageParams) msg;
        params.getDispatcher().dispatchOnStart();
        if (params.getSilenceDurationMs() > 0) {
            params.getConditionVariable().block(params.getSilenceDurationMs());
        }
        params.getDispatcher().dispatchUtteranceCompleted();
        params.getDispatcher().dispatchOnDone();
        if (DBG) Log.d(TAG, "handleSilence() done.");
    }

@@ -323,11 +324,12 @@ class AudioPlaybackHandler {
    private void handleAudio(MessageParams msg) {
        if (DBG) Log.d(TAG, "handleAudio()");
        AudioMessageParams params = (AudioMessageParams) msg;
        params.getDispatcher().dispatchOnStart();
        // Note that the BlockingMediaPlayer spawns a separate thread.
        //
        // TODO: This can be avoided.
        params.getPlayer().startAndWait();
        params.getDispatcher().dispatchUtteranceCompleted();
        params.getDispatcher().dispatchOnDone();
        if (DBG) Log.d(TAG, "handleAudio() done.");
    }

@@ -361,6 +363,7 @@ class AudioPlaybackHandler {
        if (DBG) Log.d(TAG, "Created audio track [" + audioTrack.hashCode() + "]");

        param.setAudioTrack(audioTrack);
        msg.getDispatcher().dispatchOnStart();
    }

    // More data available to be flushed to the audio track.
@@ -411,6 +414,7 @@ class AudioPlaybackHandler {
        final AudioTrack audioTrack = params.getAudioTrack();

        if (audioTrack == null) {
            params.getDispatcher().dispatchOnError();
            return;
        }

@@ -439,7 +443,7 @@ class AudioPlaybackHandler {
            audioTrack.release();
            params.setAudioTrack(null);
        }
        params.getDispatcher().dispatchUtteranceCompleted();
        params.getDispatcher().dispatchOnDone();
        mLastSynthesisRequest = null;
        params.mLogger.onWriteData();
    }
+3 −1
Original line number Diff line number Diff line
@@ -21,5 +21,7 @@ package android.speech.tts;
 * {@hide}
 */
oneway interface ITextToSpeechCallback {
    void utteranceCompleted(String utteranceId);
    void onStart(String utteranceId);
    void onDone(String utteranceId);
    void onError(String utteranceId);
}
+4 −4
Original line number Diff line number Diff line
@@ -15,22 +15,22 @@
 */
package android.speech.tts;

import android.speech.tts.TextToSpeechService.UtteranceCompletedDispatcher;
import android.speech.tts.TextToSpeechService.UtteranceProgressDispatcher;

abstract class MessageParams {
    static final int TYPE_SYNTHESIS = 1;
    static final int TYPE_AUDIO = 2;
    static final int TYPE_SILENCE = 3;

    private final UtteranceCompletedDispatcher mDispatcher;
    private final UtteranceProgressDispatcher mDispatcher;
    private final String mCallingApp;

    MessageParams(UtteranceCompletedDispatcher dispatcher, String callingApp) {
    MessageParams(UtteranceProgressDispatcher dispatcher, String callingApp) {
        mDispatcher = dispatcher;
        mCallingApp = callingApp;
    }

    UtteranceCompletedDispatcher getDispatcher() {
    UtteranceProgressDispatcher getDispatcher() {
        return mDispatcher;
    }

Loading