Make utterance_id 64-bit.
This commit is contained in:
@ -109,7 +109,7 @@ TypedArray<Dictionary> DisplayServerAndroid::tts_get_voices() const {
|
||||
return TTS_Android::get_voices();
|
||||
}
|
||||
|
||||
void DisplayServerAndroid::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) {
|
||||
void DisplayServerAndroid::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int64_t p_utterance_id, bool p_interrupt) {
|
||||
TTS_Android::speak(p_text, p_voice, p_volume, p_pitch, p_rate, p_utterance_id, p_interrupt);
|
||||
}
|
||||
|
||||
|
||||
@ -110,7 +110,7 @@ public:
|
||||
virtual bool tts_is_paused() const override;
|
||||
virtual TypedArray<Dictionary> tts_get_voices() const override;
|
||||
|
||||
virtual void tts_speak(const String &p_text, const String &p_voice, int p_volume = 50, float p_pitch = 1.f, float p_rate = 1.f, int p_utterance_id = 0, bool p_interrupt = false) override;
|
||||
virtual void tts_speak(const String &p_text, const String &p_voice, int p_volume = 50, float p_pitch = 1.f, float p_rate = 1.f, int64_t p_utterance_id = 0, bool p_interrupt = false) override;
|
||||
virtual void tts_pause() override;
|
||||
virtual void tts_resume() override;
|
||||
virtual void tts_stop() override;
|
||||
|
||||
@ -105,7 +105,7 @@ public class GodotLib {
|
||||
/**
|
||||
* TTS callback.
|
||||
*/
|
||||
public static native void ttsCallback(int event, int id, int pos);
|
||||
public static native void ttsCallback(int event, long id, int pos);
|
||||
|
||||
/**
|
||||
* Forward touch events.
|
||||
|
||||
@ -119,7 +119,7 @@ public class GodotTTS extends UtteranceProgressListener implements TextToSpeech.
|
||||
@Override
|
||||
public void onRangeStart(String utteranceId, int start, int end, int frame) {
|
||||
synchronized (lock) {
|
||||
if (lastUtterance != null && Integer.parseInt(utteranceId) == lastUtterance.id) {
|
||||
if (lastUtterance != null && Long.parseLong(utteranceId) == lastUtterance.id) {
|
||||
lastUtterance.offset = start;
|
||||
GodotLib.ttsCallback(EVENT_BOUNDARY, lastUtterance.id, start + lastUtterance.start);
|
||||
}
|
||||
@ -132,7 +132,7 @@ public class GodotTTS extends UtteranceProgressListener implements TextToSpeech.
|
||||
@Override
|
||||
public void onStop(String utteranceId, boolean interrupted) {
|
||||
synchronized (lock) {
|
||||
if (lastUtterance != null && !paused && Integer.parseInt(utteranceId) == lastUtterance.id) {
|
||||
if (lastUtterance != null && !paused && Long.parseLong(utteranceId) == lastUtterance.id) {
|
||||
GodotLib.ttsCallback(EVENT_CANCEL, lastUtterance.id, 0);
|
||||
speaking = false;
|
||||
updateTTS();
|
||||
@ -146,7 +146,7 @@ public class GodotTTS extends UtteranceProgressListener implements TextToSpeech.
|
||||
@Override
|
||||
public void onStart(String utteranceId) {
|
||||
synchronized (lock) {
|
||||
if (lastUtterance != null && lastUtterance.start == 0 && Integer.parseInt(utteranceId) == lastUtterance.id) {
|
||||
if (lastUtterance != null && lastUtterance.start == 0 && Long.parseLong(utteranceId) == lastUtterance.id) {
|
||||
GodotLib.ttsCallback(EVENT_START, lastUtterance.id, 0);
|
||||
}
|
||||
}
|
||||
@ -158,7 +158,7 @@ public class GodotTTS extends UtteranceProgressListener implements TextToSpeech.
|
||||
@Override
|
||||
public void onDone(String utteranceId) {
|
||||
synchronized (lock) {
|
||||
if (lastUtterance != null && !paused && Integer.parseInt(utteranceId) == lastUtterance.id) {
|
||||
if (lastUtterance != null && !paused && Long.parseLong(utteranceId) == lastUtterance.id) {
|
||||
GodotLib.ttsCallback(EVENT_END, lastUtterance.id, 0);
|
||||
speaking = false;
|
||||
updateTTS();
|
||||
@ -172,7 +172,7 @@ public class GodotTTS extends UtteranceProgressListener implements TextToSpeech.
|
||||
@Override
|
||||
public void onError(String utteranceId, int errorCode) {
|
||||
synchronized (lock) {
|
||||
if (lastUtterance != null && !paused && Integer.parseInt(utteranceId) == lastUtterance.id) {
|
||||
if (lastUtterance != null && !paused && Long.parseLong(utteranceId) == lastUtterance.id) {
|
||||
GodotLib.ttsCallback(EVENT_CANCEL, lastUtterance.id, 0);
|
||||
speaking = false;
|
||||
updateTTS();
|
||||
@ -186,7 +186,7 @@ public class GodotTTS extends UtteranceProgressListener implements TextToSpeech.
|
||||
@Override
|
||||
public void onError(String utteranceId) {
|
||||
synchronized (lock) {
|
||||
if (lastUtterance != null && !paused && Integer.parseInt(utteranceId) == lastUtterance.id) {
|
||||
if (lastUtterance != null && !paused && Long.parseLong(utteranceId) == lastUtterance.id) {
|
||||
GodotLib.ttsCallback(EVENT_CANCEL, lastUtterance.id, 0);
|
||||
speaking = false;
|
||||
updateTTS();
|
||||
@ -222,7 +222,7 @@ public class GodotTTS extends UtteranceProgressListener implements TextToSpeech.
|
||||
/**
|
||||
* Adds an utterance to the queue.
|
||||
*/
|
||||
public void speak(String text, String voice, int volume, float pitch, float rate, int utterance_id, boolean interrupt) {
|
||||
public void speak(String text, String voice, int volume, float pitch, float rate, long utterance_id, boolean interrupt) {
|
||||
synchronized (lock) {
|
||||
if (state != INIT_STATE_SUCCESS) {
|
||||
return;
|
||||
|
||||
@ -39,12 +39,12 @@ class GodotUtterance {
|
||||
final int volume;
|
||||
final float pitch;
|
||||
final float rate;
|
||||
final int id;
|
||||
final long id;
|
||||
|
||||
int offset = -1;
|
||||
int start = 0;
|
||||
|
||||
GodotUtterance(String text, String voice, int volume, float pitch, float rate, int id) {
|
||||
GodotUtterance(String text, String voice, int volume, float pitch, float rate, long id) {
|
||||
this.text = text;
|
||||
this.voice = voice;
|
||||
this.volume = volume;
|
||||
|
||||
@ -263,7 +263,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jcl
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ttsCallback(JNIEnv *env, jclass clazz, jint event, jint id, jint pos) {
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ttsCallback(JNIEnv *env, jclass clazz, jint event, jlong id, jint pos) {
|
||||
TTS_Android::_java_utterance_callback(event, id, pos);
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jclass clazz, jobject p_surface, jint p_width, jint p_height);
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface);
|
||||
JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz);
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ttsCallback(JNIEnv *env, jclass clazz, jint event, jint id, jint pos);
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ttsCallback(JNIEnv *env, jclass clazz, jint event, jlong id, jint pos);
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jclass clazz);
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchMouseEvent(JNIEnv *env, jclass clazz, jint p_event_type, jint p_button_mask, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y, jboolean p_double_click, jboolean p_source_mouse_relative, jfloat p_pressure, jfloat p_tilt_x, jfloat p_tilt_y);
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchTouchEvent(JNIEnv *env, jclass clazz, jint ev, jint pointer, jint pointer_count, jfloatArray positions, jboolean p_double_tap);
|
||||
|
||||
@ -52,7 +52,7 @@ jmethodID TTS_Android::_pause_speaking = nullptr;
|
||||
jmethodID TTS_Android::_resume_speaking = nullptr;
|
||||
jmethodID TTS_Android::_stop_speaking = nullptr;
|
||||
|
||||
HashMap<int, Char16String> TTS_Android::ids;
|
||||
HashMap<int64_t, Char16String> TTS_Android::ids;
|
||||
|
||||
void TTS_Android::_thread_function(void *self) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
@ -117,7 +117,7 @@ void TTS_Android::setup(jobject p_tts) {
|
||||
_is_paused = env->GetMethodID(cls, "isPaused", "()Z");
|
||||
_get_state = env->GetMethodID(cls, "getState", "()I");
|
||||
_get_voices = env->GetMethodID(cls, "getVoices", "()[Ljava/lang/String;");
|
||||
_speak = env->GetMethodID(cls, "speak", "(Ljava/lang/String;Ljava/lang/String;IFFIZ)V");
|
||||
_speak = env->GetMethodID(cls, "speak", "(Ljava/lang/String;Ljava/lang/String;IFFJZ)V");
|
||||
_pause_speaking = env->GetMethodID(cls, "pauseSpeaking", "()V");
|
||||
_resume_speaking = env->GetMethodID(cls, "resumeSpeaking", "()V");
|
||||
_stop_speaking = env->GetMethodID(cls, "stopSpeaking", "()V");
|
||||
@ -145,7 +145,7 @@ void TTS_Android::terminate() {
|
||||
}
|
||||
}
|
||||
|
||||
void TTS_Android::_java_utterance_callback(int p_event, int p_id, int p_pos) {
|
||||
void TTS_Android::_java_utterance_callback(int p_event, int64_t p_id, int p_pos) {
|
||||
if (unlikely(!initialized)) {
|
||||
initialize_tts();
|
||||
}
|
||||
@ -230,7 +230,7 @@ Array TTS_Android::get_voices() {
|
||||
return list;
|
||||
}
|
||||
|
||||
void TTS_Android::speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) {
|
||||
void TTS_Android::speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int64_t p_utterance_id, bool p_interrupt) {
|
||||
if (unlikely(!initialized)) {
|
||||
initialize_tts();
|
||||
}
|
||||
@ -289,7 +289,7 @@ void TTS_Android::stop() {
|
||||
initialize_tts();
|
||||
}
|
||||
ERR_FAIL_COND_MSG(!initialized || tts == nullptr, "Text to Speech not initialized.");
|
||||
for (const KeyValue<int, Char16String> &E : ids) {
|
||||
for (const KeyValue<int64_t, Char16String> &E : ids) {
|
||||
DisplayServer::get_singleton()->tts_post_utterance_event(DisplayServer::TTS_UTTERANCE_CANCELED, E.key);
|
||||
}
|
||||
ids.clear();
|
||||
|
||||
@ -63,19 +63,19 @@ class TTS_Android {
|
||||
|
||||
static void _thread_function(void *self);
|
||||
|
||||
static HashMap<int, Char16String> ids;
|
||||
static HashMap<int64_t, Char16String> ids;
|
||||
|
||||
static void initialize_tts(bool p_wait = true);
|
||||
|
||||
public:
|
||||
static void setup(jobject p_tts);
|
||||
static void terminate();
|
||||
static void _java_utterance_callback(int p_event, int p_id, int p_pos);
|
||||
static void _java_utterance_callback(int p_event, int64_t p_id, int p_pos);
|
||||
|
||||
static bool is_speaking();
|
||||
static bool is_paused();
|
||||
static Array get_voices();
|
||||
static void speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt);
|
||||
static void speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int64_t p_utterance_id, bool p_interrupt);
|
||||
static void pause();
|
||||
static void resume();
|
||||
static void stop();
|
||||
|
||||
Reference in New Issue
Block a user