| | |
| | | #include <pthread.h> |
| | | #include <unistd.h> |
| | | #include <cstdlib> |
| | | #include <map> |
| | | #include "common/serial_port.h" |
| | | #include "jni_log.h" |
| | | #include "common/net.h" |
| | |
| | | static int ttsSeq = 1; |
| | | |
| | | static void SendBootIndicate(union sigval sig); |
| | | |
| | | static std::map<int, void (*)(int)> TTSCallBack; |
| | | |
| | | int DESEncrypt(const uint8_t *key, int key_length, |
| | | const uint8_t *plaintext, int plaintext_length, |
| | |
| | | return seq; |
| | | } |
| | | |
| | | int PlayTTS(const char *string) |
| | | int PlayTTS(const char *string, void (*callback)(int)) |
| | | { |
| | | DEBUG("PlayTTS: %s", string); |
| | | |
| | |
| | | LOGE("%s: DetachCurrentThread() failed", __FUNCTION__); |
| | | } |
| | | } |
| | | |
| | | TTSCallBack.insert(pair<int, void (*)(int)>(id, callback)); |
| | | |
| | | return id; |
| | | } |
| | |
| | | JNIEXPORT void JNICALL |
| | | Java_com_anyun_exam_lib_RemoteService_TextSpeakEnd(JNIEnv *env, jobject thiz, jint id) { |
| | | // TODO: implement TextSpeakEnd() |
| | | PlatformStatusChanged(PLAY_TTS_DONE_EVT, (uint8_t *)&id, sizeof(id)); |
| | | |
| | | auto it = TTSCallBack.find(id); |
| | | |
| | | if (it != TTSCallBack.end()) { |
| | | if (it->second != NULL) { |
| | | tts_back_t tb; |
| | | |
| | | tb.seq = id; |
| | | tb.callback = (void (*)(int)) it->second; |
| | | PlatformStatusChanged(PLAY_TTS_DONE_EVT, (uint8_t *)&tb, sizeof(tb)); |
| | | } |
| | | TTSCallBack.erase(it); |
| | | } |
| | | } |