2 * Copyright 2020 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <service_app.h>
31 #include "service_main.h"
32 #include "service_plugin.h"
33 #include "service_ipc_dbus.h"
35 /* Sound buf save for test */
40 #ifdef PRINT_DETAILED_TIMEINFO
41 static long long int get_time_interval_count(
42 std::chrono::time_point<std::chrono::steady_clock> time_point_1,
43 std::chrono::time_point<std::chrono::steady_clock> time_point_2) {
44 auto interval = time_point_2 - time_point_1;
45 return static_cast<long long int>(
46 std::chrono::duration_cast<std::chrono::milliseconds>(interval).count());
50 static int g_last_wakeup_event_id = 0;
54 char* wakeup_word{nullptr};
55 char* wakeup_appid{nullptr};
56 unsigned char* extra_data{nullptr};
57 size_t extra_data_length{0};
58 char* extra_data_desc{nullptr};
59 CServicePlugin* plugin{nullptr};
62 bool CServicePlugin::is_ui_panel_enabled()
64 /* By default we assume the ui panel is always enabled unless explicitly turned off */
66 if (mPluginSettings) {
67 ret = mPluginSettings->ui_panel_enabled;
69 MAS_LOGD("UI Panel Enabled : %d", ret);
73 #if 0 /* + TEST_CODE */
74 Eina_Bool __send_asr_result(void *data)
78 if (!strcmp((char*)data, "Today's")) {
79 masc_ui_dbus_send_asr_result(-1, 1, "Today's");
81 if (!strcmp((char*)data, "weather.")) {
82 masc_ui_dbus_send_asr_result(-1, 0, "Today's weather.");
89 Eina_Bool __send_result(void *data)
93 int ret = masc_ui_dbus_send_result(-1, (const char*)data, (const char*)data, "test");
95 MAS_LOGE("[ERROR] Fail to stop recording(%d)", ret);
102 #endif /* -TEST_CODE */
104 static void process_wakeup_event_by_appid_timer(void* data)
106 if (nullptr == data) return;
108 AsyncParam* param = static_cast<AsyncParam*>(data);
110 char* wakeup_word = param->wakeup_word;
111 char* wakeup_appid = param->wakeup_appid;
112 unsigned char *extra_data = param->extra_data;
113 size_t extra_data_length = param->extra_data_length;
114 char* extra_data_desc = param->extra_data_desc;
115 MAS_LOGI("[ENTER] appid(%s), word(%s), id(%d), g_last_wakeup_event_id(%d)",
116 wakeup_appid, wakeup_word, param->id, g_last_wakeup_event_id);
119 if (param->wakeup_word) free(param->wakeup_word);
120 if (param->extra_data) free(param->extra_data);
121 if (param->extra_data_desc) free(param->extra_data_desc);
126 if (param->id < g_last_wakeup_event_id) {
127 if (param->wakeup_word) free(param->wakeup_word);
128 if (param->wakeup_appid) free(param->wakeup_appid);
129 if (param->extra_data) free(param->extra_data);
130 if (param->extra_data_desc) free(param->extra_data_desc);
137 CServicePlugin* plugin = param->plugin;
138 CServiceIpcDbus* service_ipc = nullptr;
139 CServiceMain* service_main = nullptr;
141 service_ipc = plugin->get_service_ipc();
142 service_main = plugin->get_service_main();
145 if (service_ipc && service_main) {
146 bool use_custom_ui = service_main->get_client_custom_ui_option_by_appid(wakeup_appid);
147 bool ui_panel_enabled = false;
148 if (param->plugin) ui_panel_enabled = param->plugin->is_ui_panel_enabled();
149 if (ui_panel_enabled) {
150 service_ipc->masc_ui_dbus_enable_common_ui(!use_custom_ui);
151 service_ipc->masc_ui_dbus_change_assistant(wakeup_appid);
154 service_main->set_current_client_by_appid(wakeup_appid);
155 if ((pid = service_main->get_client_pid_by_appid(wakeup_appid)) != -1) {
156 service_main->client_send_preprocessing_information(pid);
157 service_ipc->change_active_state(pid, MA_ACTIVE_STATE_ACTIVE, wakeup_word,
158 extra_data, extra_data_length, extra_data_desc);
159 service_main->process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
161 // Appropriate MA Client not available, trying to launch new one
162 MAS_LOGI("MA Client with appid %s does not exist, launching client", wakeup_appid);
163 service_main->launch_client_by_appid(wakeup_appid, wakeup_word,
164 extra_data, extra_data_length, extra_data_desc, CLIENT_LAUNCH_MODE_ACTIVATION);
168 if (param->wakeup_word) free(param->wakeup_word);
169 if (param->wakeup_appid) free(param->wakeup_appid);
170 if (param->extra_data) free(param->extra_data);
171 if (param->extra_data_desc) free(param->extra_data_desc);
175 static void process_wakeup_event_by_word_timer(void* data)
177 if (nullptr == data) return;
179 AsyncParam* param = static_cast<AsyncParam*>(data);
180 MAS_LOGI("[ENTER] wakeword(%s), id(%d)", (const char*)(param->wakeup_word), param->id);
182 if (!param->wakeup_word) {
183 if (param->wakeup_appid) free(param->wakeup_appid);
184 if (param->extra_data) free(param->extra_data);
185 if (param->extra_data_desc) free(param->extra_data_desc);
190 std::string wakeup_word{param->wakeup_word};
191 unsigned char *extra_data = nullptr;
192 size_t extra_data_length = param->extra_data_length;
193 if (param->extra_data && extra_data_length > 0) {
194 extra_data = (unsigned char*)malloc(extra_data_length);
196 memcpy(extra_data, param->extra_data, extra_data_length);
198 std::string extra_data_desc{param->extra_data_desc ? param->extra_data_desc : ""};
199 const char* appid = nullptr;
201 CServicePlugin* plugin = param->plugin;
202 CServiceMain* service_main = nullptr;
205 service_main = plugin->get_service_main();
207 appid = service_main->get_client_appid_by_wakeup_word(param->wakeup_word);
211 if (param->wakeup_word) free(param->wakeup_word);
212 if (param->wakeup_appid) free(param->wakeup_appid);
213 if (param->extra_data) free(param->extra_data);
214 if (param->extra_data_desc) free(param->extra_data_desc);
218 if (service_main && appid) {
219 param = new(std::nothrow) AsyncParam;
222 param->wakeup_word = strdup(wakeup_word.c_str());
223 param->wakeup_appid = strdup(appid);
224 if (extra_data && extra_data_length > 0) {
225 param->extra_data = (unsigned char*)malloc(extra_data_length);
226 if (param->extra_data)
227 memcpy(param->extra_data, extra_data, extra_data_length);
229 param->extra_data_length = extra_data_length;
230 param->extra_data_desc = strdup(extra_data_desc.c_str());
231 param->plugin = plugin;
232 process_wakeup_event_by_appid_timer(static_cast<void*>(param));
237 extra_data = nullptr;
243 static void __wakeup_event_cb(mas_wakeup_event_info wakeup_info, void* user_data)
245 MAS_LOGI("[SUCCESS] __wakeup_event_cb is called, wakeup_word(%s)", wakeup_info.wakeup_word);
248 CServiceMain* service_main = nullptr;
249 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
251 service_main = plugin->get_service_main();
252 CServiceIpcDbus* service_ipc = plugin->get_service_ipc();
253 if (plugin->is_ui_panel_enabled() && service_ipc) {
256 ret = service_ipc->masc_ui_dbus_send_hello();
259 MAS_LOGE("[ERROR] Fail to receive reply for hello, ret(%d)", ret);
271 MAS_LOGD("[Recorder Info] File not found!");
275 snprintf(mDumpFilename, sizeof(mDumpFilename), "/tmp/ma_service_%d_%d", getpid(), mDumpCount);
276 int ret = access(mDumpFilename, 0);
279 MAS_LOGD("[Recorder ERROR] File is already exist");
280 if (0 == remove(mDumpFilename)) {
281 MAS_LOGD("[Recorder] Remove file");
291 MAS_LOGD("[Recorder] Temp file name=[%s]", mDumpFilename);
294 mDumpFile = fopen(mDumpFilename, "wb+x");
296 MAS_LOGD("[Recorder ERROR] File not found!");
302 #if 0 /* + TEST_CODE */
303 if (WAKEUP_EVENT_SUCCESS == event) {
304 ecore_thread_main_loop_begin();
305 ecore_timer_add(1.0, __send_asr_result, "Today's");
306 ecore_thread_main_loop_end();
308 ecore_thread_main_loop_begin();
309 ecore_timer_add(2.0, __send_asr_result, "weather.");
310 ecore_thread_main_loop_end();
312 ecore_thread_main_loop_begin();
313 ecore_timer_add(3.0, __send_result, "Partly cloudy with temperatures from 75 to 88");
314 ecore_thread_main_loop_end();
316 #endif /* - TEST_CODE */
318 if (wakeup_info.wakeup_appid) {
319 AsyncParam* param = new(std::nothrow) AsyncParam;
321 param->id = ++g_last_wakeup_event_id;
323 wakeup_info.wakeup_word ? strdup(wakeup_info.wakeup_word) : nullptr;
324 param->wakeup_appid = strdup(wakeup_info.wakeup_appid);
325 if (wakeup_info.extra_data && wakeup_info.extra_data_length > 0) {
326 param->extra_data = (unsigned char*)malloc(wakeup_info.extra_data_length);
327 if (param->extra_data)
328 memcpy(param->extra_data, wakeup_info.extra_data, wakeup_info.extra_data_length);
329 param->extra_data_length = wakeup_info.extra_data_length;
331 param->extra_data = nullptr;
332 param->extra_data_length = 0;
334 param->extra_data_desc =
335 wakeup_info.extra_data_description ? strdup(wakeup_info.extra_data_description) : nullptr;
336 param->plugin = static_cast<CServicePlugin*>(user_data);
337 ecore_main_loop_thread_safe_call_async(process_wakeup_event_by_appid_timer,
338 static_cast<void*>(param));
340 } else if (wakeup_info.wakeup_word) {
341 AsyncParam* param = new(std::nothrow) AsyncParam;
343 param->id = ++g_last_wakeup_event_id;
344 param->wakeup_word = strdup(wakeup_info.wakeup_word);
345 param->wakeup_appid = nullptr;
346 if (wakeup_info.extra_data && wakeup_info.extra_data_length) {
347 param->extra_data = (unsigned char*)malloc(wakeup_info.extra_data_length);
348 if (param->extra_data)
349 memcpy(param->extra_data, wakeup_info.extra_data, wakeup_info.extra_data_length);
350 param->extra_data_length = wakeup_info.extra_data_length;
352 param->extra_data = nullptr;
353 param->extra_data_length = 0;
355 param->extra_data_desc =
356 wakeup_info.extra_data_description ? strdup(wakeup_info.extra_data_description) : nullptr;
357 param->plugin = static_cast<CServicePlugin*>(user_data);
358 ecore_main_loop_thread_safe_call_async(process_wakeup_event_by_word_timer,
359 static_cast<void*>(param));
364 static bool __validate_streaming_event_order(std::string appid, mas_speech_streaming_event_e *event)
368 static std::string previous_appid;
369 static mas_speech_streaming_event_e previous_event = MAS_SPEECH_STREAMING_EVENT_FINISH;
371 if (NULL == event) return false;
373 mas_speech_streaming_event_e expected_sequence[][2] = {
374 {MAS_SPEECH_STREAMING_EVENT_START, MAS_SPEECH_STREAMING_EVENT_CONTINUE},
375 {MAS_SPEECH_STREAMING_EVENT_START, MAS_SPEECH_STREAMING_EVENT_FINISH},
376 {MAS_SPEECH_STREAMING_EVENT_CONTINUE, MAS_SPEECH_STREAMING_EVENT_CONTINUE},
377 {MAS_SPEECH_STREAMING_EVENT_CONTINUE, MAS_SPEECH_STREAMING_EVENT_FINISH},
378 {MAS_SPEECH_STREAMING_EVENT_FINISH, MAS_SPEECH_STREAMING_EVENT_START},
379 /* If there is no audio data even after the start streaming request */
380 {MAS_SPEECH_STREAMING_EVENT_FINISH, MAS_SPEECH_STREAMING_EVENT_FINISH},
383 if (appid != previous_appid) {
384 /* When sending streaming event to a new client, it always sends START message first */
385 previous_event = MAS_SPEECH_STREAMING_EVENT_FINISH;
388 for (int loop = 0;loop < sizeof(expected_sequence) / sizeof(expected_sequence[0]);loop++) {
389 if (previous_event == expected_sequence[loop][0] &&
390 *event == expected_sequence[loop][1]) {
395 /* In case of FINISH -> CONTINUE without START, simply modify current event value */
396 if (MAS_SPEECH_STREAMING_EVENT_FINISH == previous_event &&
397 MAS_SPEECH_STREAMING_EVENT_CONTINUE == *event) {
398 *event = MAS_SPEECH_STREAMING_EVENT_START;
401 MAS_LOGD("[WARNING] forcibly changed CONTINUE to START : %d -> %d (PID %s -> %s)",
402 previous_event, *event, previous_appid.c_str(), appid.c_str());
407 previous_appid = appid;
408 previous_event = *event;
410 MAS_LOGE("[ERROR] State sequence validation failed : %d -> %d (APPID %s -> %s)",
411 previous_event, *event, previous_appid.c_str(), appid.c_str());
416 void handle_speech_streaming_event_failure(void* data)
418 AsyncParam* param = static_cast<AsyncParam*>(data);
419 if (NULL == param) return;
421 CServicePlugin* plugin = param->plugin;
422 CServiceMain* service_main = nullptr;
423 if (plugin) service_main = plugin->get_service_main();
426 pid_t pid = service_main->get_current_client_pid();
427 service_main->client_send_recognition_result(pid, MA_RECOGNITION_RESULT_EVENT_ERROR);
433 static void __audio_streaming_cb(mas_speech_streaming_event_e event, void* buffer, int len, void *user_data)
435 #ifdef PRINT_DETAILED_TIMEINFO
436 auto started = std::chrono::steady_clock::now();
437 auto checkpoint_1 = started;
438 auto checkpoint_2 = started;
439 auto checkpoint_3 = started;
442 CServicePlugin* plugin = static_cast<CServicePlugin*>(user_data);
444 if (event == MAS_SPEECH_STREAMING_EVENT_FAIL) {
445 AsyncParam* param = new(std::nothrow) AsyncParam;
447 param->plugin = plugin;
448 param->wakeup_word = nullptr;
449 param->wakeup_appid = nullptr;
450 param->extra_data = nullptr;
451 param->extra_data_length = 0;
452 param->extra_data_desc = nullptr;
453 ecore_main_loop_thread_safe_call_async(
454 handle_speech_streaming_event_failure, static_cast<void*>(param));
458 static int count = 0;
459 if (event != MAS_SPEECH_STREAMING_EVENT_CONTINUE || count % 100 == 0) {
460 MAS_LOGI("[SUCCESS] __audio_streaming_cb is called, event(%d), buffer(%p), len(%d)",
465 CServiceIpcDbus* service_ipc = nullptr;
466 CServiceMain* service_main = nullptr;
468 service_ipc = plugin->get_service_ipc();
469 service_main = plugin->get_service_main();
472 #ifdef PRINT_DETAILED_TIMEINFO
473 checkpoint_1 = std::chrono::steady_clock::now();
476 if (service_ipc && service_main) {
477 /* First check if we have dedicated audio processing app for current client */
478 boost::optional<std::string> appid =
479 service_main->get_current_audio_processing_appid();
481 /* If not, send audio data to the main client */
482 if (!appid) appid = service_main->get_current_client_appid();
484 boost::optional<std::string> preprocessing_appid =
485 service_main->get_current_preprocessing_client_appid();
488 MAS_LOGE("[ERROR] Fail to retrieve target appid of current MA client");
490 if (__validate_streaming_event_order(*appid, &event)) {
491 #ifdef PRINT_DETAILED_TIMEINFO
492 checkpoint_2 = std::chrono::steady_clock::now();
494 int ret = service_ipc->send_streaming_audio_data(*appid,
497 MAS_LOGE("[ERROR] Fail to send speech data, ret(%d)", ret);
499 if (preprocessing_appid && (*appid).compare(*preprocessing_appid) != 0) {
500 int ret = service_ipc->send_streaming_audio_data(*preprocessing_appid,
503 MAS_LOGE("[ERROR] Fail to send speech data to preprocessing client, ret(%d)", ret);
506 #ifdef PRINT_DETAILED_TIMEINFO
507 checkpoint_3 = std::chrono::steady_clock::now();
514 fwrite(speech_data->buffer, 1, speech_data->len, mDumpFile);
516 if (MAS_SPEECH_STREAMING_EVENT_FINISH == event) {
518 MAS_LOGE("[Recorder SUCCESS] File Close");
522 MAS_LOGE("[Recorder ERROR] File not found!");
527 #ifdef PRINT_DETAILED_TIMEINFO
528 auto finished = std::chrono::steady_clock::now();
529 long long int total_count = get_time_interval_count(started, finished);
531 if(total_count > 30) {
532 long long int count1 = get_time_interval_count(started, checkpoint_1);
533 long long int count2 = get_time_interval_count(checkpoint_1, checkpoint_2);
534 long long int count3 = get_time_interval_count(checkpoint_2, checkpoint_3);
535 long long int count4 = get_time_interval_count(checkpoint_3, finished);
537 MAS_LOGE("Spent audio streaming callback time : %lld ms [%lld %lld %lld %lld]",
538 total_count, count1, count2, count3, count4);
543 static void __speech_status_cb(mas_speech_status_e status, void *user_data)
545 MAS_LOGD("[SUCCESS] __speech_status_cb is called, status(%d)", status);
548 static void __error_cb(int error, const char* err_msg, void* user_data)
550 MAS_LOGE("[SUCCESS] __error_cb is called, error(%d), err_msg(%s)", error, err_msg);
552 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
553 if (nullptr == plugin) return;
555 CServiceIpcDbus* service_ipc = plugin->get_service_ipc();
556 if (plugin->is_ui_panel_enabled() && service_ipc) {
557 int ret = service_ipc->masc_ui_dbus_send_error_message(error, err_msg);
559 MAS_LOGE("[ERROR] Fail to send error message, ret(%d)", ret);
564 static void __setting_changed_cb(void *user_data)
566 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
567 if (nullptr == plugin) return;
569 CServiceMain* service_main = plugin->get_service_main();
571 service_main->prelaunch_default_assistant();
572 service_main->update_voice_key_support_mode();
574 MAS_LOGD("[SUCCESS] __setting_changed_cb is called");
577 static void __streaming_section_changed_cb(ma_audio_streaming_data_section_e section, void* user_data)
579 MAS_LOGI("[SUCCESS] __streaming_section_changed_cb is called, section(%d)", section);
581 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
582 if (nullptr == plugin) return;
584 CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
585 CServiceMain* service_main = plugin->get_service_main();
586 if (service_ipc && service_main) {
587 pid_t pid = service_main->get_current_client_pid();
588 int ret = service_ipc->send_streaming_section_changed(pid, (int)section);
590 MAS_LOGE("[ERROR] Fail to send streaming section changed information, ret(%d)", ret);
595 static void __wakeup_engine_command_cb(mas_wakeup_engine_command_target_e target, const char* assistant_name, const char* command, void* user_data)
597 MAS_LOGD("[SUCCESS] __wakeup_engine_command_cb is called, command(%s)", command);
599 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
600 if (nullptr == plugin) return;
602 CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
603 CServiceMain* service_main = plugin->get_service_main();
604 if (service_ipc && service_main) {
605 pid_t pid = service_main->get_client_pid_by_appid(assistant_name);
607 int ret = service_ipc->send_wakeup_engine_command(pid, command);
609 MAS_LOGE("[ERROR] Fail to send wakeup engine command, ret(%d)", ret);
615 static void __wakeup_service_state_changed_cb(ma_service_state_e state, void* user_data)
617 MAS_LOGD("[SUCCESS] __wakeup_service_state_changed_cb is called, state(%d)", state);
619 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
620 if (nullptr == plugin) return;
622 CServiceMain* service_main = plugin->get_service_main();
624 service_main->set_current_service_state(state);
628 static void __wakeup_service_voice_key_status_changed_cb(ma_voice_key_status_e status, void* user_data)
630 MAS_LOGD("[SUCCESS] __wakeup_service_voice_key_status_changed_cb is called, state(%d)", status);
632 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
633 if (nullptr == plugin) return;
635 CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
636 CServiceMain* service_main = plugin->get_service_main();
637 if (service_ipc && service_main) {
638 pid_t pid = service_main->get_current_client_pid();
639 int ret = service_ipc->change_voice_key_status(pid, status);
641 MAS_LOGE("[ERROR] Fail to send voice key status changed information, ret(%d)", ret);
646 static Eina_Bool app_restart_timer_func(void *user_data)
648 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
650 CServiceMain* service_main = plugin->get_service_main();
652 ma_service_state_e service_state = service_main->get_current_service_state();
653 if (service_state != MA_SERVICE_STATE_UTTERANCE) {
654 MAS_LOGE("[SUCCESS] Restarting service");
655 service_main->app_restart();
660 return ECORE_CALLBACK_RENEW;
663 void CServicePlugin::stop_app_restart_timer()
665 if (mAppRestartTimer) {
666 ecore_timer_del(mAppRestartTimer);
667 mAppRestartTimer = nullptr;
671 void CServicePlugin::start_app_restart_timer()
673 stop_app_restart_timer();
674 mAppRestartTimer = ecore_timer_add(1.0f, app_restart_timer_func, this);
677 static void __loaded_engine_changed_cb(void* user_data)
679 MAS_LOGD("[SUCCESS] __loaded_engine_changed_cb is called");
681 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
682 if (nullptr == plugin) return;
684 CServiceMain* service_main = plugin->get_service_main();
686 /* Make sure the app doesn't restart within a conversation session */
687 ma_service_state_e service_state = service_main->get_current_service_state();
688 if (service_state != MA_SERVICE_STATE_UTTERANCE) {
689 MAS_LOGE("[SUCCESS] Restarting service");
690 service_main->app_restart();
692 MAS_LOGE("Cannot restart service when service_state is %d", service_state);
693 plugin->start_app_restart_timer();
698 int CServicePlugin::initialize(void)
702 char filepath[512] = {'\0', };
703 const char *default_engine_path = MA_WAKEUP_MANAGER_PATH;
704 snprintf(filepath, 512, "%s/%s", default_engine_path, MA_DEFAULT_WAKEUP_MANAGER_FILENAME);
707 mPluginHandle = nullptr;
708 mPluginHandle = dlopen(filepath, RTLD_LAZY);
709 if (nullptr != (error = dlerror())) {
710 MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error);
711 if (mPluginHandle) dlclose(mPluginHandle);
712 mPluginHandle = nullptr;
713 return -1; //MAS_ERROR_OPERATION_FAILED;
715 if (nullptr == mPluginHandle) {
716 MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error);
717 return -1; //MAS_ERROR_OPERATION_FAILED;
720 mWakeupManagerInterface.initialize =
721 (wakeup_manager_initialize)dlsym(mPluginHandle,
722 MA_WAKEUP_MANAGER_FUNC_INITIALIZE);
723 mWakeupManagerInterface.deinitialize =
724 (wakeup_manager_deinitialize)dlsym(mPluginHandle,
725 MA_WAKEUP_MANAGER_FUNC_DEINITIALIZE);
726 mWakeupManagerInterface.get_settings =
727 (wakeup_manager_get_settings)dlsym(mPluginHandle,
728 MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
729 mWakeupManagerInterface.add_assistant_wakeup_word =
730 (wakeup_manager_add_assistant_wakeup_word)dlsym(mPluginHandle,
731 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_WORD);
732 mWakeupManagerInterface.remove_assistant_wakeup_word =
733 (wakeup_manager_remove_assistant_wakeup_word)dlsym(mPluginHandle,
734 MA_WAKEUP_MANAGER_FUNC_REMOVE_ASSISTANT_WAKEUP_WORD);
735 mWakeupManagerInterface.add_assistant_language =
736 (wakeup_manager_add_assistant_language)dlsym(mPluginHandle,
737 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE);
738 mWakeupManagerInterface.add_assistant_wakeup_engine =
739 (wakeup_manager_add_assistant_wakeup_engine)dlsym(mPluginHandle,
740 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_ENGINE);
741 mWakeupManagerInterface.set_default_assistant =
742 (wakeup_manager_set_default_assistant)dlsym(mPluginHandle,
743 MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT);
744 mWakeupManagerInterface.get_default_assistant =
745 (wakeup_manager_get_default_assistant)dlsym(mPluginHandle,
746 MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT);
747 mWakeupManagerInterface.set_language =
748 (wakeup_manager_set_language)dlsym(mPluginHandle,
749 MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE);
750 mWakeupManagerInterface.activate =
751 (wakeup_manager_activate)dlsym(mPluginHandle,
752 MA_WAKEUP_MANAGER_FUNC_ACTIVATE);
753 mWakeupManagerInterface.deactivate =
754 (wakeup_manager_deactivate)dlsym(mPluginHandle,
755 MA_WAKEUP_MANAGER_FUNC_DEACTIVATE);
756 mWakeupManagerInterface.update_voice_feedback_state =
757 (wakeup_manager_update_voice_feedback_state)dlsym(mPluginHandle,
758 MA_WAKEUP_MANAGER_FUNC_UPDATE_VOICE_FEEDBACK_STATE);
759 mWakeupManagerInterface.set_assistant_specific_command =
760 (wakeup_manager_set_assistant_specific_command)dlsym(mPluginHandle,
761 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_SPECIFIC_COMMAND);
762 mWakeupManagerInterface.set_background_volume =
763 (wakeup_manager_set_background_volume)dlsym(mPluginHandle,
764 MA_WAKEUP_MANAGER_FUNC_SET_BACKGROUND_VOLUME);
765 mWakeupManagerInterface.update_recognition_result =
766 (wakeup_manager_update_recognition_result)dlsym(mPluginHandle,
767 MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
768 mWakeupManagerInterface.process_plugin_event =
769 (wakeup_manager_process_plugin_event)dlsym(mPluginHandle,
770 MA_WAKEUP_MANAGER_FUNC_PROCESS_PLUGIN_EVENT);
771 mWakeupManagerInterface.start_streaming_utterance_data =
772 (wakeup_manager_start_streaming_utterance_data)dlsym(mPluginHandle,
773 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA);
774 mWakeupManagerInterface.stop_streaming_utterance_data =
775 (wakeup_manager_stop_streaming_utterance_data)dlsym(mPluginHandle,
776 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_UTTERANCE_DATA);
777 mWakeupManagerInterface.start_streaming_previous_utterance_data =
778 (wakeup_manager_start_streaming_previous_utterance_data)dlsym(mPluginHandle,
779 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_PREVIOUS_UTTERANCE_DATA);
780 mWakeupManagerInterface.stop_streaming_previous_utterance_data =
781 (wakeup_manager_stop_streaming_previous_utterance_data)dlsym(mPluginHandle,
782 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_PREVIOUS_UTTERANCE_DATA);
783 mWakeupManagerInterface.start_streaming_follow_up_data =
784 (wakeup_manager_start_streaming_follow_up_data)dlsym(mPluginHandle,
785 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_FOLLOW_UP_DATA);
786 mWakeupManagerInterface.stop_streaming_follow_up_data =
787 (wakeup_manager_stop_streaming_follow_up_data)dlsym(mPluginHandle,
788 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_FOLLOW_UP_DATA);
789 mWakeupManagerInterface.get_audio_format =
790 (wakeup_manager_get_audio_format)dlsym(mPluginHandle,
791 MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT);
792 mWakeupManagerInterface.get_audio_source_type =
793 (wakeup_manager_get_audio_source_type)dlsym(mPluginHandle,
794 MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
795 mWakeupManagerInterface.set_wake_word_audio_require_flag =
796 (wakeup_manager_set_wake_word_audio_require_flag)dlsym(mPluginHandle,
797 MA_WAKEUP_MANAGER_FUNC_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG);
798 mWakeupManagerInterface.set_assistant_language =
799 (wakeup_manager_set_assistant_language)dlsym(mPluginHandle,
800 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_LANGUAGE);
801 mWakeupManagerInterface.set_voice_key_tap_duration =
802 (wakeup_manager_set_voice_key_tap_duration)dlsym(mPluginHandle,
803 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_TAP_DURATION);
804 mWakeupManagerInterface.unset_voice_key_tap_duration =
805 (wakeup_manager_unset_voice_key_tap_duration)dlsym(mPluginHandle,
806 MA_WAKEUP_MANAGER_FUNC_UNSET_VOICE_KEY_TAP_DURATION);
807 mWakeupManagerInterface.set_voice_key_support_mode =
808 (wakeup_manager_set_voice_key_support_mode)dlsym(mPluginHandle,
809 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_SUPPORT_MODE);
810 mWakeupManagerInterface.set_wakeup_event_callback =
811 (wakeup_manager_set_wakeup_event_callback)dlsym(mPluginHandle,
812 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
813 mWakeupManagerInterface.set_utterance_streaming_callback =
814 (wakeup_manager_set_utterance_streaming_callback)dlsym(mPluginHandle,
815 MA_WAKEUP_MANAGER_FUNC_SET_UTTERANCE_STREAMING_CALLBACK);
816 mWakeupManagerInterface.set_previous_utterance_streaming_callback =
817 (wakeup_manager_set_previous_utterance_streaming_callback)dlsym(mPluginHandle,
818 MA_WAKEUP_MANAGER_FUNC_SET_PREVIOUS_UTTERANCE_STREAMING_CALLBACK);
819 mWakeupManagerInterface.set_follow_up_streaming_callback =
820 (wakeup_manager_set_follow_up_streaming_callback)dlsym(mPluginHandle,
821 MA_WAKEUP_MANAGER_FUNC_SET_FOLLOW_UP_STREAMING_CALLBACK);
822 mWakeupManagerInterface.set_speech_status_callback =
823 (wakeup_manager_set_speech_status_callback)dlsym(mPluginHandle,
824 MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK);
825 mWakeupManagerInterface.set_setting_changed_callback =
826 (wakeup_manager_set_setting_changed_callback)dlsym(mPluginHandle,
827 MA_WAKEUP_MANAGER_FUNC_SET_SETTING_CHANGED_CALLBACK);
828 mWakeupManagerInterface.set_error_callback =
829 (wakeup_manager_set_error_callback)dlsym(mPluginHandle,
830 MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK);
831 mWakeupManagerInterface.set_streaming_section_changed_callback =
832 (wakeup_manager_set_streaming_section_changed_callback)dlsym(mPluginHandle,
833 MA_WAKEUP_MANAGER_FUNC_SET_STREAMING_SECTION_CHANGED_CALLBACK);
834 mWakeupManagerInterface.set_wakeup_engine_command_callback =
835 (wakeup_manager_set_wakeup_engine_command_callback)dlsym(mPluginHandle,
836 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_ENGINE_COMMAND_CALLBACK);
837 mWakeupManagerInterface.set_wakeup_service_state_changed_callback =
838 (wakeup_manager_set_wakeup_service_state_changed_callback)dlsym(mPluginHandle,
839 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_SERVICE_STATE_CHANGED_CALLBACK);
840 mWakeupManagerInterface.set_voice_key_status_changed_callback =
841 (wakeup_manager_set_voice_key_status_changed_callback)dlsym(mPluginHandle,
842 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_STATUS_CHANGED_CALLBACK);
843 mWakeupManagerInterface.set_loaded_engine_changed_callback =
844 (wakeup_manager_set_loaded_engine_changed_callback)dlsym(mPluginHandle,
845 MA_WAKEUP_MANAGER_FUNC_SET_LOADED_ENGINE_CHANGED_CALLBACK);
848 if (NULL != mPluginHandle) {
849 wakeup_manager_initialize func = mWakeupManagerInterface.initialize;
852 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_INITIALIZE);
856 MAS_LOGE("[ERROR] Fail to initialize, ret(%d)", ret);
860 wakeup_manager_get_settings get_settings_func = mWakeupManagerInterface.get_settings;
862 if (NULL == get_settings_func) {
863 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
866 ret = get_settings_func(&mPluginSettings, &struct_size);
867 if (0 != ret || struct_size != sizeof(ma_plugin_settings)) {
868 MAS_LOGE("[ERROR] Fail to get settings, ret(%d), size %zu", ret, struct_size);
869 mPluginSettings = NULL;
873 MAS_LOGE("[ERROR] mPluginHandle is not valid");
878 int CServicePlugin::deinitialize(void)
885 MAS_LOGD("[Recorder ERROR] File not found!");
889 if (mAppRestartTimer) {
890 ecore_timer_del(mAppRestartTimer);
891 mAppRestartTimer = nullptr;
895 if (NULL != mPluginHandle) {
896 wakeup_manager_deinitialize func = mWakeupManagerInterface.deinitialize;
898 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_DEINITIALIZE);
902 MAS_LOGE("[ERROR] Fail to deinitialize, ret(%d)", ret);
906 dlclose(mPluginHandle);
907 mPluginHandle = NULL;
909 MAS_LOGE("[ERROR] mPluginHandle is not valid");
915 int CServicePlugin::get_settings(ma_plugin_settings **settings, size_t *struct_size)
918 if (NULL != mPluginHandle) {
919 wakeup_manager_get_settings func = mWakeupManagerInterface.get_settings;
921 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
923 ret = func(settings, struct_size);
925 MAS_LOGE("[ERROR] Fail to get settings, ret(%d)", ret);
929 MAS_LOGE("[ERROR] mPluginHandle is not valid");
934 int CServicePlugin::set_language(const char* language)
937 if (NULL != mPluginHandle) {
938 wakeup_manager_set_language func = mWakeupManagerInterface.set_language;
940 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE);
942 ret = func(language);
944 MAS_LOGE("[ERROR] Fail to set langauge(%s), ret(%d)", language, ret);
948 MAS_LOGE("[ERROR] mPluginHandle is not valid");
953 int CServicePlugin::add_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
956 if (NULL != mPluginHandle) {
957 wakeup_manager_add_assistant_wakeup_word func = mWakeupManagerInterface.add_assistant_wakeup_word;
959 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_WORD);
961 ret = func(appid, wakeup_word, language);
963 MAS_LOGE("[ERROR] Fail to add wakeup word(%s)(%s)(%s), ret(%d)", appid, wakeup_word, language, ret);
967 MAS_LOGE("[ERROR] mPluginHandle is not valid");
972 int CServicePlugin::remove_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
975 if (NULL != mPluginHandle) {
976 wakeup_manager_remove_assistant_wakeup_word func = mWakeupManagerInterface.remove_assistant_wakeup_word;
978 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_REMOVE_ASSISTANT_WAKEUP_WORD);
980 ret = func(appid, wakeup_word, language);
982 MAS_LOGE("[ERROR] Fail to remove wakeup word(%s)(%s)(%s), ret(%d)", appid, wakeup_word, language, ret);
986 MAS_LOGE("[ERROR] mPluginHandle is not valid");
991 int CServicePlugin::add_assistant_language(const char* appid, const char* language)
994 if (NULL != mPluginHandle) {
995 wakeup_manager_add_assistant_language func = mWakeupManagerInterface.add_assistant_language;
997 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE);
999 ret = func(appid, language);
1001 MAS_LOGE("[ERROR] Fail to set wakeup word(%s)(%s), ret(%d)", appid, language, ret);
1005 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1010 int CServicePlugin::add_assistant_wakeup_engine(const char* appid, const char* engine)
1013 if (NULL != mPluginHandle) {
1014 wakeup_manager_add_assistant_wakeup_engine func = mWakeupManagerInterface.add_assistant_wakeup_engine;
1016 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_ENGINE);
1018 ret = func(appid, engine);
1020 MAS_LOGE("[ERROR] Fail to set wakeup engine(%s)(%s), ret(%d)", appid, engine, ret);
1024 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1029 int CServicePlugin::set_default_assistant(const char* appid)
1032 if (NULL != mPluginHandle) {
1033 wakeup_manager_set_default_assistant func = mWakeupManagerInterface.set_default_assistant;
1035 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT);
1039 MAS_LOGE("[ERROR] Fail to set default assistant(%s), ret(%d)", appid, ret);
1043 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1048 int CServicePlugin::get_default_assistant(const char** appid)
1051 if (NULL == appid) {
1052 MAS_LOGE("[ERROR] appid is not valid");
1055 if (NULL != mPluginHandle) {
1056 wakeup_manager_get_default_assistant func = mWakeupManagerInterface.get_default_assistant;
1058 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT);
1062 MAS_LOGE("[ERROR] Fail to get default assistant, ret(%d)", ret);
1066 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1071 int CServicePlugin::activate(void)
1074 if (NULL != mPluginHandle) {
1075 wakeup_manager_activate func = mWakeupManagerInterface.activate;
1077 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ACTIVATE);
1081 MAS_LOGE("[ERROR] Fail to start recording, ret(%d)", ret);
1085 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1090 int CServicePlugin::deactivate(void)
1093 if (NULL != mPluginHandle) {
1094 wakeup_manager_deactivate func = mWakeupManagerInterface.deactivate;
1096 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_DEACTIVATE);
1100 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
1104 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1109 int CServicePlugin::update_voice_feedback_state(const char* appid, int state)
1112 if (NULL != mPluginHandle) {
1113 wakeup_manager_update_voice_feedback_state func = mWakeupManagerInterface.update_voice_feedback_state;
1115 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_VOICE_FEEDBACK_STATE);
1117 ret = func(appid, state);
1119 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
1123 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1128 int CServicePlugin::set_assistant_specific_command(const char* appid, const char* command)
1131 if (NULL != mPluginHandle) {
1132 wakeup_manager_set_assistant_specific_command func = mWakeupManagerInterface.set_assistant_specific_command;
1134 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_SPECIFIC_COMMAND);
1136 ret = func(appid, command);
1138 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
1142 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1147 int CServicePlugin::set_background_volume(const char* appid, double ratio)
1150 if (NULL != mPluginHandle) {
1151 wakeup_manager_set_background_volume func = mWakeupManagerInterface.set_background_volume;
1153 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_BACKGROUND_VOLUME);
1155 ret = func(appid, ratio);
1157 MAS_LOGE("[ERROR] Fail to set background volume, ret(%d)", ret);
1161 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1166 int CServicePlugin::update_recognition_result(const char* appid, int state)
1169 if (NULL != mPluginHandle) {
1170 wakeup_manager_update_recognition_result func = mWakeupManagerInterface.update_recognition_result;
1172 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
1174 ret = func(appid, state);
1176 MAS_LOGE("[ERROR] Fail to update result state, ret(%d)", ret);
1180 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1185 int CServicePlugin::process_event(int event, void *data, int len)
1188 if (NULL != mPluginHandle) {
1189 wakeup_manager_process_plugin_event func = mWakeupManagerInterface.process_plugin_event;
1191 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_PROCESS_PLUGIN_EVENT);
1193 ret = func((mas_plugin_event_e)event, data, len);
1195 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
1199 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1204 int CServicePlugin::start_streaming_utterance_data(void)
1208 if (NULL != mPluginHandle) {
1209 wakeup_manager_start_streaming_utterance_data func = mWakeupManagerInterface.start_streaming_utterance_data;
1211 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA);
1215 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1219 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1224 int CServicePlugin::stop_streaming_utterance_data(void)
1227 if (NULL != mPluginHandle) {
1228 wakeup_manager_stop_streaming_utterance_data func = mWakeupManagerInterface.stop_streaming_utterance_data;
1230 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_UTTERANCE_DATA);
1234 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1238 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1243 int CServicePlugin::start_streaming_previous_utterance_data(void)
1246 if (NULL != mPluginHandle) {
1247 wakeup_manager_start_streaming_previous_utterance_data func = mWakeupManagerInterface.start_streaming_previous_utterance_data;
1249 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_PREVIOUS_UTTERANCE_DATA);
1253 MAS_LOGE("[ERROR] Fail to request previous speech data, ret(%d)", ret);
1257 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1262 int CServicePlugin::stop_streaming_previous_utterance_data(void)
1265 if (NULL != mPluginHandle) {
1266 wakeup_manager_stop_streaming_previous_utterance_data func = mWakeupManagerInterface.stop_streaming_previous_utterance_data;
1268 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_PREVIOUS_UTTERANCE_DATA);
1272 MAS_LOGE("[ERROR] Fail to request previous speech data, ret(%d)", ret);
1276 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1281 int CServicePlugin::start_streaming_follow_up_data(void)
1284 if (NULL != mPluginHandle) {
1285 wakeup_manager_start_streaming_follow_up_data func = mWakeupManagerInterface.start_streaming_follow_up_data;
1287 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_FOLLOW_UP_DATA);
1291 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1295 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1300 int CServicePlugin::stop_streaming_follow_up_data(void)
1303 if (NULL != mPluginHandle) {
1304 wakeup_manager_stop_streaming_follow_up_data func = mWakeupManagerInterface.stop_streaming_follow_up_data;
1306 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_FOLLOW_UP_DATA);
1310 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1314 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1319 int CServicePlugin::get_recording_audio_format(int *rate, int *channel, int *audio_type)
1322 if (NULL != mPluginHandle) {
1323 wakeup_manager_get_audio_format func = mWakeupManagerInterface.get_audio_format;
1325 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT);
1327 ret = func(rate, channel, audio_type);
1329 MAS_LOGE("[ERROR] Fail to get recording audio format, ret(%d)", ret);
1333 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1338 int CServicePlugin::get_recording_audio_source_type(char** type)
1341 if (NULL != mPluginHandle) {
1342 wakeup_manager_get_audio_source_type func = mWakeupManagerInterface.get_audio_source_type;
1344 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
1348 MAS_LOGE("[ERROR] Fail to get recording audio source type, ret(%d)", ret);
1352 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1357 int CServicePlugin::set_voice_key_tap_duration(float duration)
1360 if (NULL != mPluginHandle) {
1361 wakeup_manager_set_voice_key_tap_duration func = mWakeupManagerInterface.set_voice_key_tap_duration;
1363 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_TAP_DURATION);
1365 ret = func(duration);
1367 MAS_LOGE("[ERROR] Fail to set voice key tap duration, ret(%d)", ret);
1371 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1376 int CServicePlugin::unset_voice_key_tap_duration()
1379 if (NULL != mPluginHandle) {
1380 wakeup_manager_unset_voice_key_tap_duration func = mWakeupManagerInterface.unset_voice_key_tap_duration;
1382 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UNSET_VOICE_KEY_TAP_DURATION);
1386 MAS_LOGE("[ERROR] Fail to unset voice key tap duration, ret(%d)", ret);
1390 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1395 int CServicePlugin::set_voice_key_support_mode(int mode)
1398 if (NULL != mPluginHandle) {
1399 wakeup_manager_set_voice_key_support_mode func = mWakeupManagerInterface.set_voice_key_support_mode;
1401 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_SUPPORT_MODE);
1405 MAS_LOGE("[ERROR] Fail to set voice key support mode, ret(%d)", ret);
1409 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1414 int CServicePlugin::set_wake_word_audio_require_flag(const char* appid, bool require)
1417 if (NULL != mPluginHandle) {
1418 wakeup_manager_set_wake_word_audio_require_flag func = mWakeupManagerInterface.set_wake_word_audio_require_flag;
1420 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG);
1422 ret = func(require);
1424 MAS_LOGE("[ERROR] Fail to set wake word audio require flag, ret(%d)", ret);
1428 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1433 int CServicePlugin::set_assistant_language(const char* appid, const char* language)
1436 if (NULL != mPluginHandle) {
1437 wakeup_manager_set_assistant_language func = mWakeupManagerInterface.set_assistant_language;
1439 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_LANGUAGE);
1441 ret = func(appid, language);
1443 MAS_LOGE("[ERROR] Fail to set assistant language, ret(%d)", ret);
1447 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1452 int CServicePlugin::set_callbacks(void)
1454 int ret = set_wakeup_event_callback(__wakeup_event_cb, this);
1456 MAS_LOGE("Fail to set wakeup event cb");
1460 ret = set_utterance_streaming_callback(__audio_streaming_cb, this);
1462 MAS_LOGE("Fail to set utterance streaming cb");
1466 ret = set_previous_utterance_streaming_callback(__audio_streaming_cb, this);
1468 MAS_LOGE("Fail to set previous utterance streaming cb");
1472 ret = set_follow_up_streaming_callback(__audio_streaming_cb, this);
1474 MAS_LOGE("Fail to set follow-up streaming cb");
1478 ret = set_speech_status_callback(__speech_status_cb, this);
1480 MAS_LOGE("Fail to set speech status changed cb");
1484 ret = set_setting_changed_callback(__setting_changed_cb, this);
1486 MAS_LOGE("Fail to set setting changed cb");
1490 ret = set_error_callback(__error_cb, this);
1492 MAS_LOGE("Fail to set error cb");
1496 ret = set_streaming_section_changed_callback(__streaming_section_changed_cb, this);
1498 MAS_LOGE("Fail to set streaming section changed cb");
1502 ret = set_wakeup_engine_command_callback(__wakeup_engine_command_cb, this);
1504 MAS_LOGE("Fail to set wakeup engine command cb");
1508 ret = set_wakeup_service_state_changed_callback(__wakeup_service_state_changed_cb, this);
1510 MAS_LOGE("Fail to set wakeup engine command cb");
1514 ret = set_voice_key_status_changed_callback(__wakeup_service_voice_key_status_changed_cb, this);
1516 MAS_LOGE("Fail to set wakeup engine command cb");
1520 ret = set_loaded_engine_changed_callback(__loaded_engine_changed_cb, this);
1522 MAS_LOGE("Fail to set loaded engine changed cb");
1529 int CServicePlugin::set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data)
1532 if (NULL != mPluginHandle) {
1533 wakeup_manager_set_wakeup_event_callback func = mWakeupManagerInterface.set_wakeup_event_callback;
1535 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
1537 ret = func(callback, user_data);
1539 MAS_LOGE("[ERROR] Fail to set wakeup event callback, ret(%d)", ret);
1543 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1548 int CServicePlugin::set_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1551 if (NULL != mPluginHandle) {
1552 wakeup_manager_set_utterance_streaming_callback func = mWakeupManagerInterface.set_utterance_streaming_callback;
1554 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_UTTERANCE_STREAMING_CALLBACK);
1556 ret = func(callback, user_data);
1558 MAS_LOGE("[ERROR] Fail to set utterance streaming callback, ret(%d)", ret);
1562 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1567 int CServicePlugin::set_previous_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1570 if (NULL != mPluginHandle) {
1571 wakeup_manager_set_previous_utterance_streaming_callback func = mWakeupManagerInterface.set_previous_utterance_streaming_callback;
1573 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_PREVIOUS_UTTERANCE_STREAMING_CALLBACK);
1575 ret = func(callback, user_data);
1577 MAS_LOGE("[ERROR] Fail to set utterance streaming callback, ret(%d)", ret);
1581 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1586 int CServicePlugin::set_follow_up_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1589 if (NULL != mPluginHandle) {
1590 wakeup_manager_set_follow_up_streaming_callback func = mWakeupManagerInterface.set_follow_up_streaming_callback;
1592 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_FOLLOW_UP_STREAMING_CALLBACK);
1594 ret = func(callback, user_data);
1596 MAS_LOGE("[ERROR] Fail to set follow-up streaming callback, ret(%d)", ret);
1600 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1605 int CServicePlugin::set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data)
1608 if (NULL != mPluginHandle) {
1609 wakeup_manager_set_speech_status_callback func = mWakeupManagerInterface.set_speech_status_callback;
1611 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK);
1613 ret = func(callback, user_data);
1615 MAS_LOGE("[ERROR] Fail to set speech status callback, ret(%d)", ret);
1622 int CServicePlugin::set_setting_changed_callback(wakeup_service_setting_changed_cb callback, void* user_data)
1625 if (NULL != mPluginHandle) {
1626 wakeup_manager_set_setting_changed_callback func = mWakeupManagerInterface.set_setting_changed_callback;
1628 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_SETTING_CHANGED_CALLBACK);
1630 ret = func(callback, user_data);
1632 MAS_LOGE("[ERROR] Fail to set setting_changed callback, ret(%d)", ret);
1639 int CServicePlugin::set_error_callback(wakeup_service_error_cb callback, void* user_data)
1642 if (NULL != mPluginHandle) {
1643 wakeup_manager_set_error_callback func = mWakeupManagerInterface.set_error_callback;
1645 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK);
1647 ret = func(callback, user_data);
1649 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1656 int CServicePlugin::set_streaming_section_changed_callback(wakeup_service_streaming_section_changed_cb callback, void* user_data)
1659 if (NULL != mPluginHandle) {
1660 wakeup_manager_set_streaming_section_changed_callback func = mWakeupManagerInterface.set_streaming_section_changed_callback;
1662 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_STREAMING_SECTION_CHANGED_CALLBACK);
1664 ret = func(callback, user_data);
1666 MAS_LOGE("[ERROR] Fail to set streaming section changed callback, ret(%d)", ret);
1673 int CServicePlugin::set_wakeup_engine_command_callback(wakeup_service_wakeup_engine_command_cb callback, void* user_data)
1676 if (NULL != mPluginHandle) {
1677 wakeup_manager_set_wakeup_engine_command_callback func = mWakeupManagerInterface.set_wakeup_engine_command_callback;
1679 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_ENGINE_COMMAND_CALLBACK);
1681 ret = func(callback, user_data);
1683 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1690 int CServicePlugin::set_wakeup_service_state_changed_callback(wakeup_service_wakeup_service_state_changed_cb callback, void* user_data)
1693 if (NULL != mPluginHandle) {
1694 wakeup_manager_set_wakeup_service_state_changed_callback func = mWakeupManagerInterface.set_wakeup_service_state_changed_callback;
1696 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_SERVICE_STATE_CHANGED_CALLBACK);
1698 ret = func(callback, user_data);
1700 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1707 int CServicePlugin::set_voice_key_status_changed_callback(wakeup_service_voice_key_status_changed_cb callback, void* user_data)
1710 if (NULL != mPluginHandle) {
1711 wakeup_manager_set_voice_key_status_changed_callback func = mWakeupManagerInterface.set_voice_key_status_changed_callback;
1713 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_STATUS_CHANGED_CALLBACK);
1715 ret = func(callback, user_data);
1717 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1724 int CServicePlugin::set_loaded_engine_changed_callback(wakeup_service_loaded_engine_changed_cb callback, void* user_data)
1727 if (NULL != mPluginHandle) {
1728 wakeup_manager_set_loaded_engine_changed_callback func = mWakeupManagerInterface.set_loaded_engine_changed_callback;
1730 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_LOADED_ENGINE_CHANGED_CALLBACK);
1732 ret = func(callback, user_data);
1734 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);