ScummVM API documentation
android-text-to-speech.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef BACKENDS_TEXT_TO_SPEECH_ANDROID_H
23 #define BACKENDS_TEXT_TO_SPEECH_ANDROID_H
24 
25 #include <jni.h>
26 
27 #include "common/scummsys.h"
28 
29 #if defined(USE_TTS)
30 
31 #include "common/text-to-speech.h"
32 #include "common/str.h"
33 #include "common/ustr.h"
34 #include "common/list.h"
35 
36 
38 public:
39  enum SpeechState {
40  BROKEN,
41  READY,
42  SPEAKING,
43  PAUSED,
44  };
45 
46  static void initJNI(JNIEnv *env);
47 
49  ~AndroidTextToSpeechManager() override;
50 
51  bool say(const Common::U32String &str, Action action) override;
52 
53  bool stop() override;
54  bool pause() override;
55  bool resume() override;
56 
57  bool isSpeaking() override { return getState() == SPEAKING; }
58  bool isPaused() override { return getState() == PAUSED; }
59  bool isReady() override { return getState() == READY; }
60 
61  void setVoice(unsigned index) override;
62  void freeVoiceData(void *data) override { delete (int *)data; }
63 
64  void setLanguage(Common::String language) override;
65 
66 private:
67  static void updateVoices(JNIEnv *env, jobject obj, jobjectArray voices);
68  void updateVoices() override { setLanguage(_ttsState->_language); }
69 
70  int getState() const;
71 
72  jobject _tts;
73 
74  static jmethodID _MID_shutdown;
75  static jmethodID _MID_getState;
76  static jmethodID _MID_setLanguage;
77  static jmethodID _MID_stop;
78  static jmethodID _MID_pause;
79  static jmethodID _MID_resume;
80  static jmethodID _MID_say;
81 
82  static const JNINativeMethod _natives[];
83 
84  static bool _init;
85 };
86 
87 
88 #endif
89 
90 #endif // BACKENDS_UPDATES_ANDROID_H
Definition: str.h:59
void freeVoiceData(void *data) override
Definition: android-text-to-speech.h:62
void setVoice(unsigned index) override
bool isReady() override
Definition: android-text-to-speech.h:59
bool say(const Common::U32String &str, Action action) override
bool isPaused() override
Definition: android-text-to-speech.h:58
void setLanguage(Common::String language) override
bool isSpeaking() override
Definition: android-text-to-speech.h:57
Definition: ustr.h:57
Definition: android-text-to-speech.h:37
Definition: text-to-speech.h:150