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

Commit 453c13f7 authored by Niels Egberts's avatar Niels Egberts
Browse files

Small refactoring for FileSynthesisCallback.

Removed unused callerIdentity member and removed null checks
for the dispatcher.

Change-Id: I2983f5d48a7a593bc998ba4e033f1e815fa61819
parent 5b0efb55
Loading
Loading
Loading
Loading
+7 −15
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package android.speech.tts;

import android.annotation.NonNull;
import android.media.AudioFormat;
import android.speech.tts.TextToSpeechService.UtteranceProgressDispatcher;
import android.util.Log;
@@ -46,7 +47,6 @@ class FileSynthesisCallback extends AbstractSynthesisCallback {
    private FileChannel mFileChannel;

    private final UtteranceProgressDispatcher mDispatcher;
    private final Object mCallerIdentity;

    private boolean mStarted = false;
    private boolean mDone = false;
@@ -54,12 +54,11 @@ class FileSynthesisCallback extends AbstractSynthesisCallback {
    /** Status code of synthesis */
    protected int mStatusCode;

    FileSynthesisCallback(FileChannel fileChannel, UtteranceProgressDispatcher dispatcher,
            Object callerIdentity, boolean clientIsUsingV2) {
    FileSynthesisCallback(@NonNull FileChannel fileChannel,
            @NonNull UtteranceProgressDispatcher dispatcher, boolean clientIsUsingV2) {
        super(clientIsUsingV2);
        mFileChannel = fileChannel;
        mDispatcher = dispatcher;
        mCallerIdentity = callerIdentity;
        mStatusCode = TextToSpeech.SUCCESS;
    }

@@ -75,11 +74,9 @@ class FileSynthesisCallback extends AbstractSynthesisCallback {

            mStatusCode = TextToSpeech.STOPPED;
            cleanUp();
            if (mDispatcher != null) {
            mDispatcher.dispatchOnStop();
        }
    }
    }

    /**
     * Must be called while holding the monitor on {@link #mStateLock}.
@@ -134,9 +131,7 @@ class FileSynthesisCallback extends AbstractSynthesisCallback {
            mAudioFormat = audioFormat;
            mChannelCount = channelCount;

            if (mDispatcher != null) {
            mDispatcher.dispatchOnStart();
            }
            fileChannel = mFileChannel;
        }

@@ -214,8 +209,7 @@ class FileSynthesisCallback extends AbstractSynthesisCallback {
                if (DBG) Log.d(TAG, "Request has been aborted.");
                return errorCodeOnStop();
            }
            if (mDispatcher != null && mStatusCode != TextToSpeech.SUCCESS &&
                    mStatusCode != TextToSpeech.STOPPED) {
            if (mStatusCode != TextToSpeech.SUCCESS && mStatusCode != TextToSpeech.STOPPED) {
                mDispatcher.dispatchOnError(mStatusCode);
                return TextToSpeech.ERROR;
            }
@@ -239,9 +233,7 @@ class FileSynthesisCallback extends AbstractSynthesisCallback {

            synchronized (mStateLock) {
                closeFile();
                if (mDispatcher != null) {
                mDispatcher.dispatchOnSuccess();
                }
                return TextToSpeech.SUCCESS;
            }
        } catch (IOException ex) {
+1 −2
Original line number Diff line number Diff line
@@ -1032,8 +1032,7 @@ public abstract class TextToSpeechService extends Service {

        @Override
        protected AbstractSynthesisCallback createSynthesisCallback() {
            return new FileSynthesisCallback(mFileOutputStream.getChannel(),
                    this, getCallerIdentity(), false);
            return new FileSynthesisCallback(mFileOutputStream.getChannel(), this, false);
        }

        @Override