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>
29 #include "service_main.h"
30 #include "service_plugin.h"
31 #include "service_ipc_dbus.h"
33 /* Sound buf save for test */
38 static int g_last_wakeup_event_id = 0;
44 unsigned char* extra_data;
45 size_t extra_data_length;
46 char* extra_data_desc;
47 CServicePlugin* plugin;
50 bool CServicePlugin::is_ui_panel_enabled()
52 /* By default we assume the ui panel is always enabled unless explicitly turned off */
54 if (mPluginSettings) {
55 ret = mPluginSettings->ui_panel_enabled;
57 MAS_LOGD("UI Panel Enabled : %d", ret);
61 #if 0 /* + TEST_CODE */
62 Eina_Bool __send_asr_result(void *data)
66 if (!strcmp((char*)data, "Today's")) {
67 masc_ui_dbus_send_asr_result(-1, 1, "Today's");
69 if (!strcmp((char*)data, "weather.")) {
70 masc_ui_dbus_send_asr_result(-1, 0, "Today's weather.");
77 Eina_Bool __send_result(void *data)
81 int ret = masc_ui_dbus_send_result(-1, (const char*)data, (const char*)data, "test");
83 MAS_LOGE("[ERROR] Fail to stop recording(%d)", ret);
90 #endif /* -TEST_CODE */
92 static void process_wakeup_event_by_appid_timer(void* data)
94 if (nullptr == data) return;
96 AsyncParam* param = static_cast<AsyncParam*>(data);
98 char* wakeup_word = param->wakeup_word;
99 char* wakeup_appid = param->wakeup_appid;
100 unsigned char *extra_data = param->extra_data;
101 size_t extra_data_length = param->extra_data_length;
102 char* extra_data_desc = param->extra_data_desc;
103 MAS_LOGI("[ENTER] appid(%s), word(%s), id(%d), g_last_wakeup_event_id(%d)",
104 wakeup_appid, wakeup_word, param->id, g_last_wakeup_event_id);
107 if (param->wakeup_word) free(param->wakeup_word);
108 if (param->extra_data) free(param->extra_data);
109 if (param->extra_data_desc) free(param->extra_data_desc);
114 if (param->id < g_last_wakeup_event_id) {
115 if (param->wakeup_word) free(param->wakeup_word);
116 if (param->wakeup_appid) free(param->wakeup_appid);
117 if (param->extra_data) free(param->extra_data);
118 if (param->extra_data_desc) free(param->extra_data_desc);
125 CServicePlugin* plugin = param->plugin;
126 CServiceIpcDbus* service_ipc = nullptr;
127 CServiceMain* service_main = nullptr;
129 service_ipc = plugin->get_service_ipc();
130 service_main = plugin->get_service_main();
133 if (service_ipc && service_main) {
134 bool use_custom_ui = service_main->get_client_custom_ui_option_by_appid(wakeup_appid);
135 bool ui_panel_enabled = false;
136 if (param->plugin) ui_panel_enabled = param->plugin->is_ui_panel_enabled();
137 if (ui_panel_enabled) {
138 service_ipc->masc_ui_dbus_enable_common_ui(!use_custom_ui);
139 service_ipc->masc_ui_dbus_change_assistant(wakeup_appid);
142 service_main->set_current_client_by_appid(wakeup_appid);
143 if ((pid = service_main->get_client_pid_by_appid(wakeup_appid)) != -1) {
144 service_main->client_send_preprocessing_information(pid);
145 service_ipc->change_active_state(pid, MA_ACTIVE_STATE_ACTIVE, wakeup_word,
146 extra_data, extra_data_length, extra_data_desc);
147 service_main->process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
149 // Appropriate MA Client not available, trying to launch new one
150 MAS_LOGI("MA Client with appid %s does not exist, launching client", wakeup_appid);
151 service_main->launch_client_by_appid(wakeup_appid, wakeup_word,
152 extra_data, extra_data_length, extra_data_desc, CLIENT_LAUNCH_MODE_ACTIVATION);
156 if (param->wakeup_word) free(param->wakeup_word);
157 if (param->wakeup_appid) free(param->wakeup_appid);
158 if (param->extra_data) free(param->extra_data);
159 if (param->extra_data_desc) free(param->extra_data_desc);
163 static void process_wakeup_event_by_word_timer(void* data)
165 if (nullptr == data) return;
167 AsyncParam* param = static_cast<AsyncParam*>(data);
168 MAS_LOGI("[ENTER] wakeword(%s), id(%d)", (const char*)(param->wakeup_word), param->id);
170 if (!param->wakeup_word) {
171 if (param->wakeup_appid) free(param->wakeup_appid);
172 if (param->extra_data) free(param->extra_data);
173 if (param->extra_data_desc) free(param->extra_data_desc);
178 std::string wakeup_word{param->wakeup_word};
179 unsigned char *extra_data = nullptr;
180 size_t extra_data_length = param->extra_data_length;
181 if (param->extra_data && extra_data_length > 0) {
182 extra_data = (unsigned char*)malloc(extra_data_length);
184 memcpy(extra_data, param->extra_data, extra_data_length);
186 std::string extra_data_desc{param->extra_data_desc};
187 const char* appid = nullptr;
189 CServicePlugin* plugin = param->plugin;
190 CServiceMain* service_main = nullptr;
193 service_main = plugin->get_service_main();
195 appid = service_main->get_client_appid_by_wakeup_word(param->wakeup_word);
199 if (param->wakeup_word) free(param->wakeup_word);
200 if (param->wakeup_appid) free(param->wakeup_appid);
201 if (param->extra_data) free(param->extra_data);
202 if (param->extra_data_desc) free(param->extra_data_desc);
206 if (service_main && appid) {
207 param = new(std::nothrow) AsyncParam;
210 param->wakeup_word = strdup(wakeup_word.c_str());
211 param->wakeup_appid = strdup(appid);
212 param->extra_data = extra_data;
213 param->extra_data_length = extra_data_length;
214 param->extra_data_desc = strdup(extra_data_desc.c_str());
215 param->plugin = plugin;
216 process_wakeup_event_by_appid_timer(static_cast<void*>(param));
224 static void __wakeup_event_cb(mas_wakeup_event_info wakeup_info, void* user_data)
226 MAS_LOGI("[SUCCESS] __wakeup_event_cb is called, wakeup_word(%s)", wakeup_info.wakeup_word);
229 CServiceMain* service_main = nullptr;
230 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
232 service_main = plugin->get_service_main();
233 CServiceIpcDbus* service_ipc = plugin->get_service_ipc();
234 if (plugin->is_ui_panel_enabled() && service_ipc) {
237 ret = service_ipc->masc_ui_dbus_send_hello();
240 MAS_LOGE("[ERROR] Fail to receive reply for hello, ret(%d)", ret);
252 MAS_LOGD("[Recorder Info] File not found!");
256 snprintf(mDumpFilename, sizeof(mDumpFilename), "/tmp/ma_service_%d_%d", getpid(), mDumpCount);
257 int ret = access(mDumpFilename, 0);
260 MAS_LOGD("[Recorder ERROR] File is already exist");
261 if (0 == remove(mDumpFilename)) {
262 MAS_LOGD("[Recorder] Remove file");
272 MAS_LOGD("[Recorder] Temp file name=[%s]", mDumpFilename);
275 mDumpFile = fopen(mDumpFilename, "wb+x");
277 MAS_LOGD("[Recorder ERROR] File not found!");
283 #if 0 /* + TEST_CODE */
284 if (WAKEUP_EVENT_SUCCESS == event) {
285 ecore_thread_main_loop_begin();
286 ecore_timer_add(1.0, __send_asr_result, "Today's");
287 ecore_thread_main_loop_end();
289 ecore_thread_main_loop_begin();
290 ecore_timer_add(2.0, __send_asr_result, "weather.");
291 ecore_thread_main_loop_end();
293 ecore_thread_main_loop_begin();
294 ecore_timer_add(3.0, __send_result, "Partly cloudy with temperatures from 75 to 88");
295 ecore_thread_main_loop_end();
297 #endif /* - TEST_CODE */
299 if (wakeup_info.wakeup_appid) {
300 AsyncParam* param = new(std::nothrow) AsyncParam;
302 param->id = ++g_last_wakeup_event_id;
304 wakeup_info.wakeup_word ? strdup(wakeup_info.wakeup_word) : nullptr;
305 param->wakeup_appid = strdup(wakeup_info.wakeup_appid);
306 if (wakeup_info.extra_data && wakeup_info.extra_data_length > 0) {
307 param->extra_data = (unsigned char*)malloc(wakeup_info.extra_data_length);
308 if (param->extra_data)
309 memcpy(param->extra_data, wakeup_info.extra_data, wakeup_info.extra_data_length);
310 param->extra_data_length = wakeup_info.extra_data_length;
312 param->extra_data = nullptr;
313 param->extra_data_length = 0;
315 param->extra_data_desc =
316 wakeup_info.extra_data_description ? strdup(wakeup_info.extra_data_description) : nullptr;
317 param->plugin = static_cast<CServicePlugin*>(user_data);
318 ecore_main_loop_thread_safe_call_async(process_wakeup_event_by_appid_timer,
319 static_cast<void*>(param));
321 } else if (wakeup_info.wakeup_word) {
322 AsyncParam* param = new(std::nothrow) AsyncParam;
324 param->id = ++g_last_wakeup_event_id;
325 param->wakeup_word = strdup(wakeup_info.wakeup_word);
326 param->wakeup_appid = nullptr;
327 if (wakeup_info.extra_data && wakeup_info.extra_data_length) {
328 param->extra_data = (unsigned char*)malloc(wakeup_info.extra_data_length);
329 if (param->extra_data)
330 memcpy(param->extra_data, wakeup_info.extra_data, wakeup_info.extra_data_length);
331 param->extra_data_length = wakeup_info.extra_data_length;
333 param->extra_data = nullptr;
334 param->extra_data_length = 0;
336 param->extra_data_desc =
337 wakeup_info.extra_data_description ? strdup(wakeup_info.extra_data_description) : nullptr;
338 param->plugin = static_cast<CServicePlugin*>(user_data);
339 ecore_main_loop_thread_safe_call_async(process_wakeup_event_by_word_timer,
340 static_cast<void*>(param));
345 static bool __validate_streaming_event_order(pid_t pid, mas_speech_streaming_event_e *event)
349 static int previous_pid = -1;
350 static mas_speech_streaming_event_e previous_event = MAS_SPEECH_STREAMING_EVENT_FINISH;
352 if (NULL == event) return false;
354 mas_speech_streaming_event_e expected_sequence[][2] = {
355 {MAS_SPEECH_STREAMING_EVENT_START, MAS_SPEECH_STREAMING_EVENT_CONTINUE},
356 {MAS_SPEECH_STREAMING_EVENT_START, MAS_SPEECH_STREAMING_EVENT_FINISH},
357 {MAS_SPEECH_STREAMING_EVENT_CONTINUE, MAS_SPEECH_STREAMING_EVENT_CONTINUE},
358 {MAS_SPEECH_STREAMING_EVENT_CONTINUE, MAS_SPEECH_STREAMING_EVENT_FINISH},
359 {MAS_SPEECH_STREAMING_EVENT_FINISH, MAS_SPEECH_STREAMING_EVENT_START},
360 /* If there is no audio data even after the start streaming request */
361 {MAS_SPEECH_STREAMING_EVENT_FINISH, MAS_SPEECH_STREAMING_EVENT_FINISH},
364 if (pid != previous_pid) {
365 /* When sending streaming event to a new client, it always sends START message first */
366 previous_event = MAS_SPEECH_STREAMING_EVENT_FINISH;
369 for (int loop = 0;loop < sizeof(expected_sequence) / sizeof(expected_sequence[0]);loop++) {
370 if (previous_event == expected_sequence[loop][0] &&
371 *event == expected_sequence[loop][1]) {
376 /* In case of FINISH -> CONTINUE without START, simply modify current event value */
377 if (MAS_SPEECH_STREAMING_EVENT_FINISH == previous_event &&
378 MAS_SPEECH_STREAMING_EVENT_CONTINUE == *event) {
379 *event = MAS_SPEECH_STREAMING_EVENT_START;
382 MAS_LOGD("[WARNING] forcibly changed CONTINUE to START : %d -> %d (PID %d -> %d)",
383 previous_event, *event, previous_pid, pid);
389 previous_event = *event;
391 MAS_LOGE("[ERROR] State sequence validation failed : %d -> %d (PID %d -> %d)",
392 previous_event, *event, previous_pid, pid);
397 void handle_speech_streaming_event_failure(void* data)
399 AsyncParam* param = static_cast<AsyncParam*>(data);
400 if (NULL == param) return;
402 CServicePlugin* plugin = param->plugin;
403 CServiceMain* service_main = nullptr;
404 if (plugin) service_main = plugin->get_service_main();
407 pid_t pid = service_main->get_current_client_pid();
408 service_main->client_send_recognition_result(pid, MA_RECOGNITION_RESULT_EVENT_ERROR);
414 static void __audio_streaming_cb(mas_speech_streaming_event_e event, void* buffer, int len, void *user_data)
416 CServicePlugin* plugin = static_cast<CServicePlugin*>(user_data);
418 if (event == MAS_SPEECH_STREAMING_EVENT_FAIL) {
419 AsyncParam* param = new(std::nothrow) AsyncParam;
421 param->plugin = plugin;
422 param->wakeup_word = nullptr;
423 param->wakeup_appid = nullptr;
424 param->extra_data = nullptr;
425 param->extra_data_length = 0;
426 param->extra_data_desc = nullptr;
427 ecore_main_loop_thread_safe_call_async(
428 handle_speech_streaming_event_failure, static_cast<void*>(param));
432 static int count = 0;
433 if (event != MAS_SPEECH_STREAMING_EVENT_CONTINUE || count % 100 == 0) {
434 MAS_LOGI("[SUCCESS] __audio_streaming_cb is called, event(%d), buffer(%p), len(%d)",
439 CServiceIpcDbus* service_ipc = nullptr;
440 CServiceMain* service_main = nullptr;
442 service_ipc = plugin->get_service_ipc();
443 service_main = plugin->get_service_main();
446 if (service_ipc && service_main) {
447 /* First check if we have dedicated audio processing app for current client */
448 pid_t pid = service_main->get_current_audio_processing_pid();
449 /* If not, send audio data to the main client */
450 if (-1 == pid) pid = service_main->get_current_client_pid();
452 int preprocessing_pid = service_main->get_current_preprocessing_client_pid();
454 MAS_LOGE("[ERROR] Fail to retrieve pid of current MA client");
456 if (__validate_streaming_event_order(pid, &event)) {
457 int ret = service_ipc->send_streaming_audio_data(pid,
460 MAS_LOGE("[ERROR] Fail to send speech data, ret(%d)", ret);
462 if (pid != preprocessing_pid && -1 != preprocessing_pid) {
463 int ret = service_ipc->send_streaming_audio_data(preprocessing_pid,
466 MAS_LOGE("[ERROR] Fail to send speech data to preprocessing client, ret(%d)", ret);
474 fwrite(speech_data->buffer, 1, speech_data->len, mDumpFile);
476 if (MAS_SPEECH_STREAMING_EVENT_FINISH == event) {
478 MAS_LOGE("[Recorder SUCCESS] File Close");
482 MAS_LOGE("[Recorder ERROR] File not found!");
488 static void __speech_status_cb(mas_speech_status_e status, void *user_data)
490 MAS_LOGD("[SUCCESS] __speech_status_cb is called, status(%d)", status);
493 static void __error_cb(int error, const char* err_msg, void* user_data)
495 MAS_LOGE("[SUCCESS] __error_cb is called, error(%d), err_msg(%s)", error, err_msg);
497 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
498 if (nullptr == plugin) return;
500 CServiceIpcDbus* service_ipc = plugin->get_service_ipc();
501 if (plugin->is_ui_panel_enabled() && service_ipc) {
502 int ret = service_ipc->masc_ui_dbus_send_error_message(error, err_msg);
504 MAS_LOGE("[ERROR] Fail to send error message, ret(%d)", ret);
509 static void __setting_changed_cb(void *user_data)
511 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
512 if (nullptr == plugin) return;
514 CServiceMain* service_main = plugin->get_service_main();
516 service_main->prelaunch_default_assistant();
517 service_main->update_voice_key_support_mode();
519 MAS_LOGD("[SUCCESS] __setting_changed_cb is called");
522 static void __streaming_section_changed_cb(ma_audio_streaming_data_section_e section, void* user_data)
524 MAS_LOGI("[SUCCESS] __streaming_section_changed_cb is called, section(%d)", section);
526 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
527 if (nullptr == plugin) return;
529 CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
530 CServiceMain* service_main = plugin->get_service_main();
531 if (service_ipc && service_main) {
532 pid_t pid = service_main->get_current_client_pid();
533 int ret = service_ipc->send_streaming_section_changed(pid, (int)section);
535 MAS_LOGE("[ERROR] Fail to send streaming section changed information, ret(%d)", ret);
540 static void __wakeup_engine_command_cb(mas_wakeup_engine_command_target_e target, const char* assistant_name, const char* command, void* user_data)
542 MAS_LOGD("[SUCCESS] __wakeup_engine_command_cb is called, command(%s)", command);
544 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
545 if (nullptr == plugin) return;
547 CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
548 CServiceMain* service_main = plugin->get_service_main();
549 if (service_ipc && service_main) {
550 pid_t pid = service_main->get_client_pid_by_appid(assistant_name);
552 int ret = service_ipc->send_wakeup_engine_command(pid, command);
554 MAS_LOGE("[ERROR] Fail to send wakeup engine command, ret(%d)", ret);
560 static void __wakeup_service_state_changed_cb(ma_service_state_e state, void* user_data)
562 MAS_LOGD("[SUCCESS] __wakeup_service_state_changed_cb is called, state(%d)", state);
564 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
565 if (nullptr == plugin) return;
567 CServiceMain* service_main = plugin->get_service_main();
569 service_main->set_current_service_state(state);
573 static void __wakeup_service_voice_key_status_changed_cb(ma_voice_key_status_e status, void* user_data)
575 MAS_LOGD("[SUCCESS] __wakeup_service_voice_key_status_changed_cb is called, state(%d)", status);
577 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
578 if (nullptr == plugin) return;
580 CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
581 CServiceMain* service_main = plugin->get_service_main();
582 if (service_ipc && service_main) {
583 pid_t pid = service_main->get_current_client_pid();
584 int ret = service_ipc->change_voice_key_status(pid, status);
586 MAS_LOGE("[ERROR] Fail to send voice key status changed information, ret(%d)", ret);
591 static void __loaded_engine_changed_cb(void* user_data)
593 MAS_LOGD("[SUCCESS] __loaded_engine_changed_cb is called");
595 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
596 if (nullptr == plugin) return;
598 CServiceMain* service_main = plugin->get_service_main();
600 service_main->app_restart();
604 int CServicePlugin::initialize(void)
608 char filepath[512] = {'\0', };
609 const char *default_engine_path = MA_WAKEUP_MANAGER_PATH;
610 snprintf(filepath, 512, "%s/%s", default_engine_path, MA_DEFAULT_WAKEUP_MANAGER_FILENAME);
613 mPluginHandle = nullptr;
614 mPluginHandle = dlopen(filepath, RTLD_LAZY);
615 if (nullptr != (error = dlerror())) {
616 MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error);
617 if (mPluginHandle) dlclose(mPluginHandle);
618 mPluginHandle = nullptr;
619 return -1; //MAS_ERROR_OPERATION_FAILED;
621 if (nullptr == mPluginHandle) {
622 MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error);
623 return -1; //MAS_ERROR_OPERATION_FAILED;
626 mWakeupManagerInterface.initialize =
627 (wakeup_manager_initialize)dlsym(mPluginHandle,
628 MA_WAKEUP_MANAGER_FUNC_INITIALIZE);
629 mWakeupManagerInterface.deinitialize =
630 (wakeup_manager_deinitialize)dlsym(mPluginHandle,
631 MA_WAKEUP_MANAGER_FUNC_DEINITIALIZE);
632 mWakeupManagerInterface.get_settings =
633 (wakeup_manager_get_settings)dlsym(mPluginHandle,
634 MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
635 mWakeupManagerInterface.add_assistant_wakeup_word =
636 (wakeup_manager_add_assistant_wakeup_word)dlsym(mPluginHandle,
637 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_WORD);
638 mWakeupManagerInterface.remove_assistant_wakeup_word =
639 (wakeup_manager_remove_assistant_wakeup_word)dlsym(mPluginHandle,
640 MA_WAKEUP_MANAGER_FUNC_REMOVE_ASSISTANT_WAKEUP_WORD);
641 mWakeupManagerInterface.add_assistant_language =
642 (wakeup_manager_add_assistant_language)dlsym(mPluginHandle,
643 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE);
644 mWakeupManagerInterface.add_assistant_wakeup_engine =
645 (wakeup_manager_add_assistant_wakeup_engine)dlsym(mPluginHandle,
646 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_ENGINE);
647 mWakeupManagerInterface.set_default_assistant =
648 (wakeup_manager_set_default_assistant)dlsym(mPluginHandle,
649 MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT);
650 mWakeupManagerInterface.get_default_assistant =
651 (wakeup_manager_get_default_assistant)dlsym(mPluginHandle,
652 MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT);
653 mWakeupManagerInterface.set_language =
654 (wakeup_manager_set_language)dlsym(mPluginHandle,
655 MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE);
656 mWakeupManagerInterface.activate =
657 (wakeup_manager_activate)dlsym(mPluginHandle,
658 MA_WAKEUP_MANAGER_FUNC_ACTIVATE);
659 mWakeupManagerInterface.deactivate =
660 (wakeup_manager_deactivate)dlsym(mPluginHandle,
661 MA_WAKEUP_MANAGER_FUNC_DEACTIVATE);
662 mWakeupManagerInterface.update_voice_feedback_state =
663 (wakeup_manager_update_voice_feedback_state)dlsym(mPluginHandle,
664 MA_WAKEUP_MANAGER_FUNC_UPDATE_VOICE_FEEDBACK_STATE);
665 mWakeupManagerInterface.set_assistant_specific_command =
666 (wakeup_manager_set_assistant_specific_command)dlsym(mPluginHandle,
667 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_SPECIFIC_COMMAND);
668 mWakeupManagerInterface.set_background_volume =
669 (wakeup_manager_set_background_volume)dlsym(mPluginHandle,
670 MA_WAKEUP_MANAGER_FUNC_SET_BACKGROUND_VOLUME);
671 mWakeupManagerInterface.update_recognition_result =
672 (wakeup_manager_update_recognition_result)dlsym(mPluginHandle,
673 MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
674 mWakeupManagerInterface.process_plugin_event =
675 (wakeup_manager_process_plugin_event)dlsym(mPluginHandle,
676 MA_WAKEUP_MANAGER_FUNC_PROCESS_PLUGIN_EVENT);
677 mWakeupManagerInterface.start_streaming_utterance_data =
678 (wakeup_manager_start_streaming_utterance_data)dlsym(mPluginHandle,
679 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA);
680 mWakeupManagerInterface.stop_streaming_utterance_data =
681 (wakeup_manager_stop_streaming_utterance_data)dlsym(mPluginHandle,
682 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_UTTERANCE_DATA);
683 mWakeupManagerInterface.start_streaming_previous_utterance_data =
684 (wakeup_manager_start_streaming_previous_utterance_data)dlsym(mPluginHandle,
685 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_PREVIOUS_UTTERANCE_DATA);
686 mWakeupManagerInterface.stop_streaming_previous_utterance_data =
687 (wakeup_manager_stop_streaming_previous_utterance_data)dlsym(mPluginHandle,
688 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_PREVIOUS_UTTERANCE_DATA);
689 mWakeupManagerInterface.start_streaming_follow_up_data =
690 (wakeup_manager_start_streaming_follow_up_data)dlsym(mPluginHandle,
691 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_FOLLOW_UP_DATA);
692 mWakeupManagerInterface.stop_streaming_follow_up_data =
693 (wakeup_manager_stop_streaming_follow_up_data)dlsym(mPluginHandle,
694 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_FOLLOW_UP_DATA);
695 mWakeupManagerInterface.get_audio_format =
696 (wakeup_manager_get_audio_format)dlsym(mPluginHandle,
697 MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT);
698 mWakeupManagerInterface.get_audio_source_type =
699 (wakeup_manager_get_audio_source_type)dlsym(mPluginHandle,
700 MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
701 mWakeupManagerInterface.set_wake_word_audio_require_flag =
702 (wakeup_manager_set_wake_word_audio_require_flag)dlsym(mPluginHandle,
703 MA_WAKEUP_MANAGER_FUNC_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG);
704 mWakeupManagerInterface.set_assistant_language =
705 (wakeup_manager_set_assistant_language)dlsym(mPluginHandle,
706 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_LANGUAGE);
707 mWakeupManagerInterface.set_voice_key_tap_duration =
708 (wakeup_manager_set_voice_key_tap_duration)dlsym(mPluginHandle,
709 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_TAP_DURATION);
710 mWakeupManagerInterface.unset_voice_key_tap_duration =
711 (wakeup_manager_unset_voice_key_tap_duration)dlsym(mPluginHandle,
712 MA_WAKEUP_MANAGER_FUNC_UNSET_VOICE_KEY_TAP_DURATION);
713 mWakeupManagerInterface.set_voice_key_support_mode =
714 (wakeup_manager_set_voice_key_support_mode)dlsym(mPluginHandle,
715 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_SUPPORT_MODE);
716 mWakeupManagerInterface.set_wakeup_event_callback =
717 (wakeup_manager_set_wakeup_event_callback)dlsym(mPluginHandle,
718 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
719 mWakeupManagerInterface.set_utterance_streaming_callback =
720 (wakeup_manager_set_utterance_streaming_callback)dlsym(mPluginHandle,
721 MA_WAKEUP_MANAGER_FUNC_SET_UTTERANCE_STREAMING_CALLBACK);
722 mWakeupManagerInterface.set_previous_utterance_streaming_callback =
723 (wakeup_manager_set_previous_utterance_streaming_callback)dlsym(mPluginHandle,
724 MA_WAKEUP_MANAGER_FUNC_SET_PREVIOUS_UTTERANCE_STREAMING_CALLBACK);
725 mWakeupManagerInterface.set_follow_up_streaming_callback =
726 (wakeup_manager_set_follow_up_streaming_callback)dlsym(mPluginHandle,
727 MA_WAKEUP_MANAGER_FUNC_SET_FOLLOW_UP_STREAMING_CALLBACK);
728 mWakeupManagerInterface.set_speech_status_callback =
729 (wakeup_manager_set_speech_status_callback)dlsym(mPluginHandle,
730 MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK);
731 mWakeupManagerInterface.set_setting_changed_callback =
732 (wakeup_manager_set_setting_changed_callback)dlsym(mPluginHandle,
733 MA_WAKEUP_MANAGER_FUNC_SET_SETTING_CHANGED_CALLBACK);
734 mWakeupManagerInterface.set_error_callback =
735 (wakeup_manager_set_error_callback)dlsym(mPluginHandle,
736 MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK);
737 mWakeupManagerInterface.set_streaming_section_changed_callback =
738 (wakeup_manager_set_streaming_section_changed_callback)dlsym(mPluginHandle,
739 MA_WAKEUP_MANAGER_FUNC_SET_STREAMING_SECTION_CHANGED_CALLBACK);
740 mWakeupManagerInterface.set_wakeup_engine_command_callback =
741 (wakeup_manager_set_wakeup_engine_command_callback)dlsym(mPluginHandle,
742 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_ENGINE_COMMAND_CALLBACK);
743 mWakeupManagerInterface.set_wakeup_service_state_changed_callback =
744 (wakeup_manager_set_wakeup_service_state_changed_callback)dlsym(mPluginHandle,
745 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_SERVICE_STATE_CHANGED_CALLBACK);
746 mWakeupManagerInterface.set_voice_key_status_changed_callback =
747 (wakeup_manager_set_voice_key_status_changed_callback)dlsym(mPluginHandle,
748 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_STATUS_CHANGED_CALLBACK);
749 mWakeupManagerInterface.set_loaded_engine_changed_callback =
750 (wakeup_manager_set_loaded_engine_changed_callback)dlsym(mPluginHandle,
751 MA_WAKEUP_MANAGER_FUNC_SET_LOADED_ENGINE_CHANGED_CALLBACK);
754 if (NULL != mPluginHandle) {
755 wakeup_manager_initialize func = mWakeupManagerInterface.initialize;
758 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_INITIALIZE);
762 MAS_LOGE("[ERROR] Fail to initialize, ret(%d)", ret);
766 wakeup_manager_get_settings get_settings_func = mWakeupManagerInterface.get_settings;
768 if (NULL == get_settings_func) {
769 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
772 ret = get_settings_func(&mPluginSettings, &struct_size);
773 if (0 != ret || struct_size != sizeof(ma_plugin_settings)) {
774 MAS_LOGE("[ERROR] Fail to get settings, ret(%d), size %zu", ret, struct_size);
775 mPluginSettings = NULL;
779 MAS_LOGE("[ERROR] mPluginHandle is not valid");
784 int CServicePlugin::deinitialize(void)
791 MAS_LOGD("[Recorder ERROR] File not found!");
796 if (NULL != mPluginHandle) {
797 wakeup_manager_deinitialize func = mWakeupManagerInterface.deinitialize;
799 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_DEINITIALIZE);
803 MAS_LOGE("[ERROR] Fail to deinitialize, ret(%d)", ret);
807 dlclose(mPluginHandle);
808 mPluginHandle = NULL;
810 MAS_LOGE("[ERROR] mPluginHandle is not valid");
816 int CServicePlugin::get_settings(ma_plugin_settings **settings, size_t *struct_size)
819 if (NULL != mPluginHandle) {
820 wakeup_manager_get_settings func = mWakeupManagerInterface.get_settings;
822 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
824 ret = func(settings, struct_size);
826 MAS_LOGE("[ERROR] Fail to get settings, ret(%d)", ret);
830 MAS_LOGE("[ERROR] mPluginHandle is not valid");
835 int CServicePlugin::set_language(const char* language)
838 if (NULL != mPluginHandle) {
839 wakeup_manager_set_language func = mWakeupManagerInterface.set_language;
841 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE);
843 ret = func(language);
845 MAS_LOGE("[ERROR] Fail to set langauge(%s), ret(%d)", language, ret);
849 MAS_LOGE("[ERROR] mPluginHandle is not valid");
854 int CServicePlugin::add_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
857 if (NULL != mPluginHandle) {
858 wakeup_manager_add_assistant_wakeup_word func = mWakeupManagerInterface.add_assistant_wakeup_word;
860 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_WORD);
862 ret = func(appid, wakeup_word, language);
864 MAS_LOGE("[ERROR] Fail to add wakeup word(%s)(%s)(%s), ret(%d)", appid, wakeup_word, language, ret);
868 MAS_LOGE("[ERROR] mPluginHandle is not valid");
873 int CServicePlugin::remove_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
876 if (NULL != mPluginHandle) {
877 wakeup_manager_remove_assistant_wakeup_word func = mWakeupManagerInterface.remove_assistant_wakeup_word;
879 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_REMOVE_ASSISTANT_WAKEUP_WORD);
881 ret = func(appid, wakeup_word, language);
883 MAS_LOGE("[ERROR] Fail to remove wakeup word(%s)(%s)(%s), ret(%d)", appid, wakeup_word, language, ret);
887 MAS_LOGE("[ERROR] mPluginHandle is not valid");
892 int CServicePlugin::add_assistant_language(const char* appid, const char* language)
895 if (NULL != mPluginHandle) {
896 wakeup_manager_add_assistant_language func = mWakeupManagerInterface.add_assistant_language;
898 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE);
900 ret = func(appid, language);
902 MAS_LOGE("[ERROR] Fail to set wakeup word(%s)(%s), ret(%d)", appid, language, ret);
906 MAS_LOGE("[ERROR] mPluginHandle is not valid");
911 int CServicePlugin::add_assistant_wakeup_engine(const char* appid, const char* engine)
914 if (NULL != mPluginHandle) {
915 wakeup_manager_add_assistant_wakeup_engine func = mWakeupManagerInterface.add_assistant_wakeup_engine;
917 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_ENGINE);
919 ret = func(appid, engine);
921 MAS_LOGE("[ERROR] Fail to set wakeup engine(%s)(%s), ret(%d)", appid, engine, ret);
925 MAS_LOGE("[ERROR] mPluginHandle is not valid");
930 int CServicePlugin::set_default_assistant(const char* appid)
933 if (NULL != mPluginHandle) {
934 wakeup_manager_set_default_assistant func = mWakeupManagerInterface.set_default_assistant;
936 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT);
940 MAS_LOGE("[ERROR] Fail to set default assistant(%s), ret(%d)", appid, ret);
944 MAS_LOGE("[ERROR] mPluginHandle is not valid");
949 int CServicePlugin::get_default_assistant(const char** appid)
953 MAS_LOGE("[ERROR] appid is not valid");
956 if (NULL != mPluginHandle) {
957 wakeup_manager_get_default_assistant func = mWakeupManagerInterface.get_default_assistant;
959 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT);
963 MAS_LOGE("[ERROR] Fail to get default assistant, ret(%d)", ret);
967 MAS_LOGE("[ERROR] mPluginHandle is not valid");
972 int CServicePlugin::activate(void)
975 if (NULL != mPluginHandle) {
976 wakeup_manager_activate func = mWakeupManagerInterface.activate;
978 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ACTIVATE);
982 MAS_LOGE("[ERROR] Fail to start recording, ret(%d)", ret);
986 MAS_LOGE("[ERROR] mPluginHandle is not valid");
991 int CServicePlugin::deactivate(void)
994 if (NULL != mPluginHandle) {
995 wakeup_manager_deactivate func = mWakeupManagerInterface.deactivate;
997 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_DEACTIVATE);
1001 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
1005 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1010 int CServicePlugin::update_voice_feedback_state(const char* appid, int state)
1013 if (NULL != mPluginHandle) {
1014 wakeup_manager_update_voice_feedback_state func = mWakeupManagerInterface.update_voice_feedback_state;
1016 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_VOICE_FEEDBACK_STATE);
1018 ret = func(appid, state);
1020 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
1024 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1029 int CServicePlugin::set_assistant_specific_command(const char* appid, const char* command)
1032 if (NULL != mPluginHandle) {
1033 wakeup_manager_set_assistant_specific_command func = mWakeupManagerInterface.set_assistant_specific_command;
1035 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_SPECIFIC_COMMAND);
1037 ret = func(appid, command);
1039 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
1043 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1048 int CServicePlugin::set_background_volume(const char* appid, double ratio)
1051 if (NULL != mPluginHandle) {
1052 wakeup_manager_set_background_volume func = mWakeupManagerInterface.set_background_volume;
1054 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_BACKGROUND_VOLUME);
1056 ret = func(appid, ratio);
1058 MAS_LOGE("[ERROR] Fail to set background volume, ret(%d)", ret);
1062 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1067 int CServicePlugin::update_recognition_result(const char* appid, int state)
1070 if (NULL != mPluginHandle) {
1071 wakeup_manager_update_recognition_result func = mWakeupManagerInterface.update_recognition_result;
1073 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
1075 ret = func(appid, state);
1077 MAS_LOGE("[ERROR] Fail to update result state, ret(%d)", ret);
1081 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1086 int CServicePlugin::process_event(int event, void *data, int len)
1089 if (NULL != mPluginHandle) {
1090 wakeup_manager_process_plugin_event func = mWakeupManagerInterface.process_plugin_event;
1092 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_PROCESS_PLUGIN_EVENT);
1094 ret = func((mas_plugin_event_e)event, data, len);
1096 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
1100 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1105 int CServicePlugin::start_streaming_utterance_data(void)
1109 if (NULL != mPluginHandle) {
1110 wakeup_manager_start_streaming_utterance_data func = mWakeupManagerInterface.start_streaming_utterance_data;
1112 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA);
1116 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1120 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1125 int CServicePlugin::stop_streaming_utterance_data(void)
1128 if (NULL != mPluginHandle) {
1129 wakeup_manager_stop_streaming_utterance_data func = mWakeupManagerInterface.stop_streaming_utterance_data;
1131 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_UTTERANCE_DATA);
1135 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1139 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1144 int CServicePlugin::start_streaming_previous_utterance_data(void)
1147 if (NULL != mPluginHandle) {
1148 wakeup_manager_start_streaming_previous_utterance_data func = mWakeupManagerInterface.start_streaming_previous_utterance_data;
1150 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_PREVIOUS_UTTERANCE_DATA);
1154 MAS_LOGE("[ERROR] Fail to request previous speech data, ret(%d)", ret);
1158 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1163 int CServicePlugin::stop_streaming_previous_utterance_data(void)
1166 if (NULL != mPluginHandle) {
1167 wakeup_manager_stop_streaming_previous_utterance_data func = mWakeupManagerInterface.stop_streaming_previous_utterance_data;
1169 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_PREVIOUS_UTTERANCE_DATA);
1173 MAS_LOGE("[ERROR] Fail to request previous speech data, ret(%d)", ret);
1177 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1182 int CServicePlugin::start_streaming_follow_up_data(void)
1185 if (NULL != mPluginHandle) {
1186 wakeup_manager_start_streaming_follow_up_data func = mWakeupManagerInterface.start_streaming_follow_up_data;
1188 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_FOLLOW_UP_DATA);
1192 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1196 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1201 int CServicePlugin::stop_streaming_follow_up_data(void)
1204 if (NULL != mPluginHandle) {
1205 wakeup_manager_stop_streaming_follow_up_data func = mWakeupManagerInterface.stop_streaming_follow_up_data;
1207 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_FOLLOW_UP_DATA);
1211 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1215 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1220 int CServicePlugin::get_recording_audio_format(int *rate, int *channel, int *audio_type)
1223 if (NULL != mPluginHandle) {
1224 wakeup_manager_get_audio_format func = mWakeupManagerInterface.get_audio_format;
1226 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT);
1228 ret = func(rate, channel, audio_type);
1230 MAS_LOGE("[ERROR] Fail to get recording audio format, ret(%d)", ret);
1234 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1239 int CServicePlugin::get_recording_audio_source_type(char** type)
1242 if (NULL != mPluginHandle) {
1243 wakeup_manager_get_audio_source_type func = mWakeupManagerInterface.get_audio_source_type;
1245 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
1249 MAS_LOGE("[ERROR] Fail to get recording audio source type, ret(%d)", ret);
1253 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1258 int CServicePlugin::set_voice_key_tap_duration(float duration)
1261 if (NULL != mPluginHandle) {
1262 wakeup_manager_set_voice_key_tap_duration func = mWakeupManagerInterface.set_voice_key_tap_duration;
1264 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_TAP_DURATION);
1266 ret = func(duration);
1268 MAS_LOGE("[ERROR] Fail to set voice key tap duration, ret(%d)", ret);
1272 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1277 int CServicePlugin::unset_voice_key_tap_duration()
1280 if (NULL != mPluginHandle) {
1281 wakeup_manager_unset_voice_key_tap_duration func = mWakeupManagerInterface.unset_voice_key_tap_duration;
1283 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UNSET_VOICE_KEY_TAP_DURATION);
1287 MAS_LOGE("[ERROR] Fail to unset voice key tap duration, ret(%d)", ret);
1291 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1296 int CServicePlugin::set_voice_key_support_mode(int mode)
1299 if (NULL != mPluginHandle) {
1300 wakeup_manager_set_voice_key_support_mode func = mWakeupManagerInterface.set_voice_key_support_mode;
1302 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_SUPPORT_MODE);
1306 MAS_LOGE("[ERROR] Fail to set voice key support mode, ret(%d)", ret);
1310 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1315 int CServicePlugin::set_wake_word_audio_require_flag(const char* appid, bool require)
1318 if (NULL != mPluginHandle) {
1319 wakeup_manager_set_wake_word_audio_require_flag func = mWakeupManagerInterface.set_wake_word_audio_require_flag;
1321 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG);
1323 ret = func(require);
1325 MAS_LOGE("[ERROR] Fail to set wake word audio require flag, ret(%d)", ret);
1329 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1334 int CServicePlugin::set_assistant_language(const char* appid, const char* language)
1337 if (NULL != mPluginHandle) {
1338 wakeup_manager_set_assistant_language func = mWakeupManagerInterface.set_assistant_language;
1340 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_LANGUAGE);
1342 ret = func(appid, language);
1344 MAS_LOGE("[ERROR] Fail to set assistant language, ret(%d)", ret);
1348 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1353 int CServicePlugin::set_callbacks(void)
1355 int ret = set_wakeup_event_callback(__wakeup_event_cb, this);
1357 MAS_LOGE("Fail to set wakeup event cb");
1361 ret = set_utterance_streaming_callback(__audio_streaming_cb, this);
1363 MAS_LOGE("Fail to set utterance streaming cb");
1367 ret = set_previous_utterance_streaming_callback(__audio_streaming_cb, this);
1369 MAS_LOGE("Fail to set previous utterance streaming cb");
1373 ret = set_follow_up_streaming_callback(__audio_streaming_cb, this);
1375 MAS_LOGE("Fail to set follow-up streaming cb");
1379 ret = set_speech_status_callback(__speech_status_cb, this);
1381 MAS_LOGE("Fail to set speech status changed cb");
1385 ret = set_setting_changed_callback(__setting_changed_cb, this);
1387 MAS_LOGE("Fail to set setting changed cb");
1391 ret = set_error_callback(__error_cb, this);
1393 MAS_LOGE("Fail to set error cb");
1397 ret = set_streaming_section_changed_callback(__streaming_section_changed_cb, this);
1399 MAS_LOGE("Fail to set streaming section changed cb");
1403 ret = set_wakeup_engine_command_callback(__wakeup_engine_command_cb, this);
1405 MAS_LOGE("Fail to set wakeup engine command cb");
1409 ret = set_wakeup_service_state_changed_callback(__wakeup_service_state_changed_cb, this);
1411 MAS_LOGE("Fail to set wakeup engine command cb");
1415 ret = set_voice_key_status_changed_callback(__wakeup_service_voice_key_status_changed_cb, this);
1417 MAS_LOGE("Fail to set wakeup engine command cb");
1421 ret = set_loaded_engine_changed_callback(__loaded_engine_changed_cb, this);
1423 MAS_LOGE("Fail to set loaded engine changed cb");
1430 int CServicePlugin::set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data)
1433 if (NULL != mPluginHandle) {
1434 wakeup_manager_set_wakeup_event_callback func = mWakeupManagerInterface.set_wakeup_event_callback;
1436 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
1438 ret = func(callback, user_data);
1440 MAS_LOGE("[ERROR] Fail to set wakeup event callback, ret(%d)", ret);
1444 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1449 int CServicePlugin::set_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1452 if (NULL != mPluginHandle) {
1453 wakeup_manager_set_utterance_streaming_callback func = mWakeupManagerInterface.set_utterance_streaming_callback;
1455 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_UTTERANCE_STREAMING_CALLBACK);
1457 ret = func(callback, user_data);
1459 MAS_LOGE("[ERROR] Fail to set utterance streaming callback, ret(%d)", ret);
1463 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1468 int CServicePlugin::set_previous_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1471 if (NULL != mPluginHandle) {
1472 wakeup_manager_set_previous_utterance_streaming_callback func = mWakeupManagerInterface.set_previous_utterance_streaming_callback;
1474 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_PREVIOUS_UTTERANCE_STREAMING_CALLBACK);
1476 ret = func(callback, user_data);
1478 MAS_LOGE("[ERROR] Fail to set utterance streaming callback, ret(%d)", ret);
1482 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1487 int CServicePlugin::set_follow_up_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1490 if (NULL != mPluginHandle) {
1491 wakeup_manager_set_follow_up_streaming_callback func = mWakeupManagerInterface.set_follow_up_streaming_callback;
1493 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_FOLLOW_UP_STREAMING_CALLBACK);
1495 ret = func(callback, user_data);
1497 MAS_LOGE("[ERROR] Fail to set follow-up streaming callback, ret(%d)", ret);
1501 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1506 int CServicePlugin::set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data)
1509 if (NULL != mPluginHandle) {
1510 wakeup_manager_set_speech_status_callback func = mWakeupManagerInterface.set_speech_status_callback;
1512 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK);
1514 ret = func(callback, user_data);
1516 MAS_LOGE("[ERROR] Fail to set speech status callback, ret(%d)", ret);
1523 int CServicePlugin::set_setting_changed_callback(wakeup_service_setting_changed_cb callback, void* user_data)
1526 if (NULL != mPluginHandle) {
1527 wakeup_manager_set_setting_changed_callback func = mWakeupManagerInterface.set_setting_changed_callback;
1529 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_SETTING_CHANGED_CALLBACK);
1531 ret = func(callback, user_data);
1533 MAS_LOGE("[ERROR] Fail to set setting_changed callback, ret(%d)", ret);
1540 int CServicePlugin::set_error_callback(wakeup_service_error_cb callback, void* user_data)
1543 if (NULL != mPluginHandle) {
1544 wakeup_manager_set_error_callback func = mWakeupManagerInterface.set_error_callback;
1546 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK);
1548 ret = func(callback, user_data);
1550 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1557 int CServicePlugin::set_streaming_section_changed_callback(wakeup_service_streaming_section_changed_cb callback, void* user_data)
1560 if (NULL != mPluginHandle) {
1561 wakeup_manager_set_streaming_section_changed_callback func = mWakeupManagerInterface.set_streaming_section_changed_callback;
1563 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_STREAMING_SECTION_CHANGED_CALLBACK);
1565 ret = func(callback, user_data);
1567 MAS_LOGE("[ERROR] Fail to set streaming section changed callback, ret(%d)", ret);
1574 int CServicePlugin::set_wakeup_engine_command_callback(wakeup_service_wakeup_engine_command_cb callback, void* user_data)
1577 if (NULL != mPluginHandle) {
1578 wakeup_manager_set_wakeup_engine_command_callback func = mWakeupManagerInterface.set_wakeup_engine_command_callback;
1580 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_ENGINE_COMMAND_CALLBACK);
1582 ret = func(callback, user_data);
1584 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1591 int CServicePlugin::set_wakeup_service_state_changed_callback(wakeup_service_wakeup_service_state_changed_cb callback, void* user_data)
1594 if (NULL != mPluginHandle) {
1595 wakeup_manager_set_wakeup_service_state_changed_callback func = mWakeupManagerInterface.set_wakeup_service_state_changed_callback;
1597 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_SERVICE_STATE_CHANGED_CALLBACK);
1599 ret = func(callback, user_data);
1601 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1608 int CServicePlugin::set_voice_key_status_changed_callback(wakeup_service_voice_key_status_changed_cb callback, void* user_data)
1611 if (NULL != mPluginHandle) {
1612 wakeup_manager_set_voice_key_status_changed_callback func = mWakeupManagerInterface.set_voice_key_status_changed_callback;
1614 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_STATUS_CHANGED_CALLBACK);
1616 ret = func(callback, user_data);
1618 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1625 int CServicePlugin::set_loaded_engine_changed_callback(wakeup_service_loaded_engine_changed_cb callback, void* user_data)
1628 if (NULL != mPluginHandle) {
1629 wakeup_manager_set_loaded_engine_changed_callback func = mWakeupManagerInterface.set_loaded_engine_changed_callback;
1631 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_LOADED_ENGINE_CHANGED_CALLBACK);
1633 ret = func(callback, user_data);
1635 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);