blob: 91e119b63439b5ba84b1caf67fdee8f74eebb647 [file] [log] [blame]
Narayan Kamathe22b69a2011-06-08 11:41:47 +01001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16package android.speech.tts;
17
Przemyslaw Szczepaniak90d15d22013-06-14 12:02:53 +010018
Narayan Kamathe22b69a2011-06-08 11:41:47 +010019/**
20 * Defines additional methods the synthesis callback must implement that
21 * are private to the TTS service implementation.
Przemyslaw Szczepaniak90d15d22013-06-14 12:02:53 +010022 *
23 * All of these class methods (with the exception of {@link #stop()}) can be only called on the
24 * synthesis thread, while inside
25 * {@link TextToSpeechService#onSynthesizeText} or {@link TextToSpeechService#onSynthesizeTextV2}.
26 * {@link #stop()} is the exception, it may be called from multiple threads.
Narayan Kamathe22b69a2011-06-08 11:41:47 +010027 */
28abstract class AbstractSynthesisCallback implements SynthesisCallback {
Przemyslaw Szczepaniak90d15d22013-06-14 12:02:53 +010029 /** If true, request comes from V2 TTS interface */
30 protected final boolean mClientIsUsingV2;
31
Narayan Kamathe22b69a2011-06-08 11:41:47 +010032 /**
Przemyslaw Szczepaniak90d15d22013-06-14 12:02:53 +010033 * Constructor.
34 * @param clientIsUsingV2 If true, this callback will be used inside
35 * {@link TextToSpeechService#onSynthesizeTextV2} method.
Narayan Kamathe22b69a2011-06-08 11:41:47 +010036 */
Przemyslaw Szczepaniak90d15d22013-06-14 12:02:53 +010037 AbstractSynthesisCallback(boolean clientIsUsingV2) {
38 mClientIsUsingV2 = clientIsUsingV2;
39 }
Narayan Kamathe22b69a2011-06-08 11:41:47 +010040
41 /**
42 * Aborts the speech request.
43 *
44 * Can be called from multiple threads.
45 */
46 abstract void stop();
Przemyslaw Szczepaniak90d15d22013-06-14 12:02:53 +010047
48 /**
49 * Get status code for a "stop".
50 *
51 * V2 Clients will receive special status, V1 clients will receive standard error.
52 *
53 * This method should only be called on the synthesis thread,
54 * while in {@link TextToSpeechService#onSynthesizeText}.
55 */
56 int errorCodeOnStop() {
57 return mClientIsUsingV2 ? TextToSpeechClient.Status.STOPPED : TextToSpeech.ERROR;
58 }
Narayan Kamathe22b69a2011-06-08 11:41:47 +010059}