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>
19 #include <app_manager.h>
31 #include "service_main.h"
32 #include "service_plugin.h"
33 #include "service_ipc_dbus.h"
35 /* Sound buf save for test */
42 CServicePlugin* plugin;
45 bool CServicePlugin::is_ui_panel_enabled()
47 /* By default we assume the ui panel is always enabled unless explicitly turned off */
49 if (mPluginSettings) {
50 ret = mPluginSettings->ui_panel_enabled;
52 MAS_LOGD("UI Panel Enabled : %d", ret);
56 #if 0 /* + TEST_CODE */
57 Eina_Bool __send_asr_result(void *data)
61 if (!strcmp((char*)data, "Today's")) {
62 masc_ui_dbus_send_asr_result(-1, 1, "Today's");
64 if (!strcmp((char*)data, "weather.")) {
65 masc_ui_dbus_send_asr_result(-1, 0, "Today's weather.");
72 Eina_Bool __send_result(void *data)
76 int ret = masc_ui_dbus_send_result(-1, (const char*)data, (const char*)data, "test");
78 MAS_LOGE("[ERROR] Fail to stop recording(%d)", ret);
85 #endif /* -TEST_CODE */
87 static Eina_Bool process_wakeup_event_by_appid_timer(void* data)
89 if (NULL == data) return ECORE_CALLBACK_CANCEL;
90 AsyncParam* param = static_cast<AsyncParam*>(data);
92 char* appid = static_cast<char*>(param->data);
93 MAS_LOGD("[ENTER] appid(%s)", appid);
96 if (!appid) return ECORE_CALLBACK_CANCEL;
98 CServicePlugin* plugin = param->plugin;
99 CServiceIpcDbus* service_ipc = nullptr;
100 CServiceMain* service_main = nullptr;
102 service_ipc = plugin->get_service_ipc();
103 service_main = plugin->get_service_main();
105 if (service_ipc && service_main) {
106 bool use_custom_ui = service_main->mas_get_client_custom_ui_option_by_appid(appid);
107 bool ui_panel_enabled = false;
108 if (param->plugin) ui_panel_enabled = param->plugin->is_ui_panel_enabled();
109 if (ui_panel_enabled) {
110 service_ipc->masc_ui_dbus_enable_common_ui(!use_custom_ui);
111 service_ipc->masc_ui_dbus_change_assistant(appid);
114 service_main->mas_set_current_client_by_appid(appid);
115 if ((pid = service_main->mas_get_client_pid_by_appid(appid)) != -1) {
116 service_main->mas_client_send_preprocessing_information(pid);
117 service_ipc->change_active_state(pid, MA_ACTIVE_STATE_ACTIVE);
118 service_main->mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
120 // Appropriate MA Client not available, trying to launch new one
121 MAS_LOGD("MA Client with appid %s does not exist, launching client", appid);
122 service_main->mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);
126 if (appid) free(appid);
130 return ECORE_CALLBACK_CANCEL;
133 static Eina_Bool process_wakeup_event_by_word_timer(void* data)
137 if (NULL == data) return ECORE_CALLBACK_CANCEL;
138 AsyncParam* param = static_cast<AsyncParam*>(data);
140 char* wakeup_word = static_cast<char*>(param->data);
141 CServicePlugin* plugin = param->plugin;
142 CServiceMain* service_main = nullptr;
145 service_main = plugin->get_service_main();
152 const char* appid = service_main->mas_get_client_appid_by_wakeup_word(wakeup_word);
154 param = new(std::nothrow) AsyncParam;
156 param->data = static_cast<void*>(strdup(appid));
157 param->plugin = plugin;
158 process_wakeup_event_by_appid_timer(static_cast<void*>(param));
163 if (wakeup_word) free(wakeup_word);
166 return ECORE_CALLBACK_CANCEL;
169 static void __wakeup_event_cb(mas_wakeup_event_info wakeup_info, void* user_data)
171 MAS_LOGD("dalton debug : %p", user_data);
172 MAS_LOGD("[SUCCESS] __wakeup_event_cb is called, wakeup_word(%s)", wakeup_info.wakeup_word);
175 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
177 CServiceIpcDbus* service_ipc = plugin->get_service_ipc();
178 if (plugin->is_ui_panel_enabled() && service_ipc) {
181 ret = service_ipc->masc_ui_dbus_send_hello();
184 MAS_LOGE("[ERROR] Fail to receive reply for hello, ret(%d)", ret);
196 MAS_LOGD("[Recorder Info] File not found!");
200 snprintf(mDumpFilename, sizeof(mDumpFilename), "/tmp/ma_service_%d_%d", getpid(), mDumpCount);
201 int ret = access(mDumpFilename, 0);
204 MAS_LOGD("[Recorder ERROR] File is already exist");
205 if (0 == remove(mDumpFilename)) {
206 MAS_LOGD("[Recorder] Remove file");
216 MAS_LOGD("[Recorder] Temp file name=[%s]", mDumpFilename);
219 mDumpFile = fopen(mDumpFilename, "wb+x");
221 MAS_LOGD("[Recorder ERROR] File not found!");
227 #if 0 /* + TEST_CODE */
228 if (WAKEUP_EVENT_SUCCESS == event) {
229 ecore_thread_main_loop_begin();
230 ecore_timer_add(1.0, __send_asr_result, "Today's");
231 ecore_thread_main_loop_end();
233 ecore_thread_main_loop_begin();
234 ecore_timer_add(2.0, __send_asr_result, "weather.");
235 ecore_thread_main_loop_end();
237 ecore_thread_main_loop_begin();
238 ecore_timer_add(3.0, __send_result, "Partly cloudy with temperatures from 75 to 88");
239 ecore_thread_main_loop_end();
241 #endif /* - TEST_CODE */
242 if (wakeup_info.wakeup_appid) {
243 AsyncParam* param = new(std::nothrow) AsyncParam;
245 param->data = static_cast<void*>(strdup(wakeup_info.wakeup_appid));
246 param->plugin = static_cast<CServicePlugin*>(user_data);
247 ecore_thread_main_loop_begin();
248 ecore_timer_add(0.0f, process_wakeup_event_by_appid_timer,
249 static_cast<void*>(param));
250 ecore_thread_main_loop_end();
252 } else if (wakeup_info.wakeup_word) {
253 AsyncParam* param = new(std::nothrow) AsyncParam;
255 param->data = static_cast<void*>(strdup(wakeup_info.wakeup_word));
256 param->plugin = static_cast<CServicePlugin*>(user_data);
257 ecore_thread_main_loop_begin();
258 ecore_timer_add(0.0f, process_wakeup_event_by_word_timer,
259 static_cast<void*>(param));
260 ecore_thread_main_loop_end();
265 static bool __validate_streaming_event_order(int pid, mas_speech_streaming_event_e *event)
269 static int previous_pid = -1;
270 static mas_speech_streaming_event_e previous_event = MAS_SPEECH_STREAMING_EVENT_FINISH;
272 if (NULL == event) return false;
274 mas_speech_streaming_event_e expected_sequence[][2] = {
275 {MAS_SPEECH_STREAMING_EVENT_START, MAS_SPEECH_STREAMING_EVENT_CONTINUE},
276 {MAS_SPEECH_STREAMING_EVENT_START, MAS_SPEECH_STREAMING_EVENT_FINISH},
277 {MAS_SPEECH_STREAMING_EVENT_CONTINUE, MAS_SPEECH_STREAMING_EVENT_CONTINUE},
278 {MAS_SPEECH_STREAMING_EVENT_CONTINUE, MAS_SPEECH_STREAMING_EVENT_FINISH},
279 {MAS_SPEECH_STREAMING_EVENT_FINISH, MAS_SPEECH_STREAMING_EVENT_START},
280 /* If there is no audio data even after the start streaming request */
281 {MAS_SPEECH_STREAMING_EVENT_FINISH, MAS_SPEECH_STREAMING_EVENT_FINISH},
284 if (pid != previous_pid) {
285 /* When sending streaming event to a new client, it always sends START message first */
286 previous_event = MAS_SPEECH_STREAMING_EVENT_FINISH;
289 for (int loop = 0;loop < sizeof(expected_sequence) / sizeof(expected_sequence[0]);loop++) {
290 if (previous_event == expected_sequence[loop][0] &&
291 *event == expected_sequence[loop][1]) {
296 /* In case of FINISH -> CONTINUE without START, simply modify current event value */
297 if (MAS_SPEECH_STREAMING_EVENT_FINISH == previous_event &&
298 MAS_SPEECH_STREAMING_EVENT_CONTINUE == *event) {
299 *event = MAS_SPEECH_STREAMING_EVENT_START;
302 MAS_LOGD("[WARNING] forcibly changed CONTINUE to START : %d -> %d (PID %d -> %d)",
303 previous_event, *event, previous_pid, pid);
309 previous_event = *event;
311 MAS_LOGE("[ERROR] State sequence validation failed : %d -> %d (PID %d -> %d)",
312 previous_event, *event, previous_pid, pid);
317 void handle_speech_streaming_event_failure(void* data)
319 AsyncParam* param = static_cast<AsyncParam*>(data);
320 if (NULL == param) return;
322 CServicePlugin* plugin = param->plugin;
323 CServiceMain* service_main = nullptr;
324 if (plugin) service_main = plugin->get_service_main();
327 service_main->mas_client_send_recognition_result(0, MA_RECOGNITION_RESULT_EVENT_ERROR);
333 static void __audio_streaming_cb(mas_speech_streaming_event_e event, void* buffer, int len, void *user_data)
335 if (event == MAS_SPEECH_STREAMING_EVENT_FAIL) {
336 ecore_main_loop_thread_safe_call_async(handle_speech_streaming_event_failure, NULL);
339 static int count = 0;
340 if (event != MAS_SPEECH_STREAMING_EVENT_CONTINUE || count % 100 == 0) {
341 MAS_LOGD("[SUCCESS] __audio_streaming_cb is called, event(%d), buffer(%p), len(%d)",
346 CServicePlugin* plugin = static_cast<CServicePlugin*>(user_data);
347 CServiceIpcDbus* service_ipc = nullptr;
348 CServiceMain* service_main = nullptr;
350 service_ipc = plugin->get_service_ipc();
351 service_main = plugin->get_service_main();
354 if (service_ipc && service_main) {
355 int pid = service_main->mas_get_current_client_pid();
356 int preprocessing_pid = service_main->mas_get_current_preprocessing_client_pid();
358 MAS_LOGE("[ERROR] Fail to retrieve pid of current MA client");
360 if (__validate_streaming_event_order(pid, &event)) {
361 int ret = service_ipc->send_streaming_audio_data(pid,
364 MAS_LOGE("[ERROR] Fail to send speech data, ret(%d)", ret);
366 if (pid != preprocessing_pid && -1 != preprocessing_pid) {
367 int ret = service_ipc->send_streaming_audio_data(preprocessing_pid,
370 MAS_LOGE("[ERROR] Fail to send speech data to preprocessing client, ret(%d)", ret);
378 fwrite(speech_data->buffer, 1, speech_data->len, mDumpFile);
380 if (MAS_SPEECH_STREAMING_EVENT_FINISH == event) {
382 MAS_LOGE("[Recorder SUCCESS] File Close");
386 MAS_LOGE("[Recorder ERROR] File not found!");
392 static void __speech_status_cb(mas_speech_status_e status, void *user_data)
394 MAS_LOGD("[SUCCESS] __speech_status_cb is called, status(%d)", status);
397 static void __error_cb(int error, const char* err_msg, void* user_data)
399 MAS_LOGD("[SUCCESS] __error_cb is called, error(%d), err_msg(%s)", error, err_msg);
401 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
402 if (nullptr == plugin) return;
404 CServiceIpcDbus* service_ipc = plugin->get_service_ipc();
405 if (plugin->is_ui_panel_enabled() && service_ipc) {
406 int ret = service_ipc->masc_ui_dbus_send_error_message(error, err_msg);
408 MAS_LOGE("[ERROR] Fail to send error message, ret(%d)", ret);
413 static void __setting_changed_cb(void *user_data)
415 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
416 if (nullptr == plugin) return;
418 CServiceMain* service_main = plugin->get_service_main();
420 service_main->mas_prelaunch_default_assistant();
421 service_main->mas_update_voice_key_support_mode();
423 MAS_LOGD("[SUCCESS] __setting_changed_cb is called");
426 static void __streaming_section_changed_cb(ma_audio_streaming_data_section_e section, void* user_data)
428 MAS_LOGD("[SUCCESS] __streaming_section_changed_cb is called, section(%d)", section);
430 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
431 if (nullptr == plugin) return;
433 CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
434 CServiceMain* service_main = plugin->get_service_main();
435 if (service_ipc && service_main) {
436 int pid = service_main->mas_get_current_client_pid();
437 int ret = service_ipc->send_streaming_section_changed(pid, (int)section);
439 MAS_LOGE("[ERROR] Fail to send streaming section changed information, ret(%d)", ret);
444 static void __wakeup_engine_command_cb(mas_wakeup_engine_command_target_e target, const char* assistant_name, const char* command, void* user_data)
446 MAS_LOGD("[SUCCESS] __wakeup_engine_command_cb is called, command(%s)", command);
448 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
449 if (nullptr == plugin) return;
451 CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
452 CServiceMain* service_main = plugin->get_service_main();
453 if (service_ipc && service_main) {
454 int pid = service_main->mas_get_client_pid_by_appid(assistant_name);
456 int ret = service_ipc->send_wakeup_engine_command(pid, command);
458 MAS_LOGE("[ERROR] Fail to send wakeup engine command, ret(%d)", ret);
464 static void __wakeup_service_state_changed_cb(ma_service_state_e state, void* user_data)
466 MAS_LOGD("[SUCCESS] __wakeup_service_state_changed_cb is called, state(%d)", state);
468 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
469 if (nullptr == plugin) return;
471 CServiceMain* service_main = plugin->get_service_main();
473 service_main->mas_set_current_service_state(state);
477 static void __wakeup_service_voice_key_status_changed_cb(ma_voice_key_status_e status, void* user_data)
479 MAS_LOGD("[SUCCESS] __wakeup_service_voice_key_status_changed_cb is called, state(%d)", status);
481 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
482 if (nullptr == plugin) return;
484 CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
485 CServiceMain* service_main = plugin->get_service_main();
486 if (service_ipc && service_main) {
487 int pid = service_main->mas_get_current_client_pid();
488 int ret = service_ipc->change_voice_key_status(pid, status);
490 MAS_LOGE("[ERROR] Fail to send voice key status changed information, ret(%d)", ret);
495 int CServicePlugin::initialize(void)
499 char filepath[512] = {'\0', };
500 const char *default_engine_path = MA_WAKEUP_MANAGER_PATH;
501 snprintf(filepath, 512, "%s/%s", default_engine_path, MA_DEFAULT_WAKEUP_MANAGER_FILENAME);
504 mPluginHandle = NULL;
505 mPluginHandle = dlopen(filepath, RTLD_LAZY);
506 if (NULL != (error = dlerror())) {
507 MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error);
508 return -1; //MAS_ERROR_OPERATION_FAILED;
511 mWakeupManagerInterface.initialize =
512 (wakeup_manager_initialize)dlsym(mPluginHandle,
513 MA_WAKEUP_MANAGER_FUNC_INITIALIZE);
514 mWakeupManagerInterface.deinitialize =
515 (wakeup_manager_deinitialize)dlsym(mPluginHandle,
516 MA_WAKEUP_MANAGER_FUNC_DEINITIALIZE);
517 mWakeupManagerInterface.get_settings =
518 (wakeup_manager_get_settings)dlsym(mPluginHandle,
519 MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
520 mWakeupManagerInterface.add_assistant_wakeup_word =
521 (wakeup_manager_add_assistant_wakeup_word)dlsym(mPluginHandle,
522 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_WORD);
523 mWakeupManagerInterface.remove_assistant_wakeup_word =
524 (wakeup_manager_remove_assistant_wakeup_word)dlsym(mPluginHandle,
525 MA_WAKEUP_MANAGER_FUNC_REMOVE_ASSISTANT_WAKEUP_WORD);
526 mWakeupManagerInterface.add_assistant_language =
527 (wakeup_manager_add_assistant_language)dlsym(mPluginHandle,
528 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE);
529 mWakeupManagerInterface.set_assistant_wakeup_engine =
530 (wakeup_manager_set_assistant_wakeup_engine)dlsym(mPluginHandle,
531 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_WAKEUP_ENGINE);
532 mWakeupManagerInterface.set_default_assistant =
533 (wakeup_manager_set_default_assistant)dlsym(mPluginHandle,
534 MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT);
535 mWakeupManagerInterface.get_default_assistant =
536 (wakeup_manager_get_default_assistant)dlsym(mPluginHandle,
537 MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT);
538 mWakeupManagerInterface.set_language =
539 (wakeup_manager_set_language)dlsym(mPluginHandle,
540 MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE);
541 mWakeupManagerInterface.activate =
542 (wakeup_manager_activate)dlsym(mPluginHandle,
543 MA_WAKEUP_MANAGER_FUNC_ACTIVATE);
544 mWakeupManagerInterface.deactivate =
545 (wakeup_manager_deactivate)dlsym(mPluginHandle,
546 MA_WAKEUP_MANAGER_FUNC_DEACTIVATE);
547 mWakeupManagerInterface.update_voice_feedback_state =
548 (wakeup_manager_update_voice_feedback_state)dlsym(mPluginHandle,
549 MA_WAKEUP_MANAGER_FUNC_UPDATE_VOICE_FEEDBACK_STATE);
550 mWakeupManagerInterface.set_assistant_specific_command =
551 (wakeup_manager_set_assistant_specific_command)dlsym(mPluginHandle,
552 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_SPECIFIC_COMMAND);
553 mWakeupManagerInterface.set_background_volume =
554 (wakeup_manager_set_background_volume)dlsym(mPluginHandle,
555 MA_WAKEUP_MANAGER_FUNC_SET_BACKGROUND_VOLUME);
556 mWakeupManagerInterface.update_recognition_result =
557 (wakeup_manager_update_recognition_result)dlsym(mPluginHandle,
558 MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
559 mWakeupManagerInterface.process_plugin_event =
560 (wakeup_manager_process_plugin_event)dlsym(mPluginHandle,
561 MA_WAKEUP_MANAGER_FUNC_PROCESS_PLUGIN_EVENT);
562 mWakeupManagerInterface.start_streaming_utterance_data =
563 (wakeup_manager_start_streaming_utterance_data)dlsym(mPluginHandle,
564 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA);
565 mWakeupManagerInterface.stop_streaming_utterance_data =
566 (wakeup_manager_stop_streaming_utterance_data)dlsym(mPluginHandle,
567 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_UTTERANCE_DATA);
568 mWakeupManagerInterface.start_streaming_previous_utterance_data =
569 (wakeup_manager_start_streaming_previous_utterance_data)dlsym(mPluginHandle,
570 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_PREVIOUS_UTTERANCE_DATA);
571 mWakeupManagerInterface.stop_streaming_previous_utterance_data =
572 (wakeup_manager_stop_streaming_previous_utterance_data)dlsym(mPluginHandle,
573 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_PREVIOUS_UTTERANCE_DATA);
574 mWakeupManagerInterface.start_streaming_follow_up_data =
575 (wakeup_manager_start_streaming_follow_up_data)dlsym(mPluginHandle,
576 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_FOLLOW_UP_DATA);
577 mWakeupManagerInterface.stop_streaming_follow_up_data =
578 (wakeup_manager_stop_streaming_follow_up_data)dlsym(mPluginHandle,
579 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_FOLLOW_UP_DATA);
580 mWakeupManagerInterface.get_audio_format =
581 (wakeup_manager_get_audio_format)dlsym(mPluginHandle,
582 MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT);
583 mWakeupManagerInterface.get_audio_source_type =
584 (wakeup_manager_get_audio_source_type)dlsym(mPluginHandle,
585 MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
586 mWakeupManagerInterface.set_wake_word_audio_require_flag =
587 (wakeup_manager_set_wake_word_audio_require_flag)dlsym(mPluginHandle,
588 MA_WAKEUP_MANAGER_FUNC_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG);
589 mWakeupManagerInterface.set_assistant_language =
590 (wakeup_manager_set_assistant_language)dlsym(mPluginHandle,
591 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_LANGUAGE);
592 mWakeupManagerInterface.set_voice_key_tap_duration =
593 (wakeup_manager_set_voice_key_tap_duration)dlsym(mPluginHandle,
594 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_TAP_DURATION);
595 mWakeupManagerInterface.unset_voice_key_tap_duration =
596 (wakeup_manager_unset_voice_key_tap_duration)dlsym(mPluginHandle,
597 MA_WAKEUP_MANAGER_FUNC_UNSET_VOICE_KEY_TAP_DURATION);
598 mWakeupManagerInterface.set_voice_key_support_mode =
599 (wakeup_manager_set_voice_key_support_mode)dlsym(mPluginHandle,
600 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_SUPPORT_MODE);
601 mWakeupManagerInterface.set_wakeup_event_callback =
602 (wakeup_manager_set_wakeup_event_callback)dlsym(mPluginHandle,
603 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
604 mWakeupManagerInterface.set_utterance_streaming_callback =
605 (wakeup_manager_set_utterance_streaming_callback)dlsym(mPluginHandle,
606 MA_WAKEUP_MANAGER_FUNC_SET_UTTERANCE_STREAMING_CALLBACK);
607 mWakeupManagerInterface.set_previous_utterance_streaming_callback =
608 (wakeup_manager_set_previous_utterance_streaming_callback)dlsym(mPluginHandle,
609 MA_WAKEUP_MANAGER_FUNC_SET_PREVIOUS_UTTERANCE_STREAMING_CALLBACK);
610 mWakeupManagerInterface.set_follow_up_streaming_callback =
611 (wakeup_manager_set_follow_up_streaming_callback)dlsym(mPluginHandle,
612 MA_WAKEUP_MANAGER_FUNC_SET_FOLLOW_UP_STREAMING_CALLBACK);
613 mWakeupManagerInterface.set_speech_status_callback =
614 (wakeup_manager_set_speech_status_callback)dlsym(mPluginHandle,
615 MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK);
616 mWakeupManagerInterface.set_setting_changed_callback =
617 (wakeup_manager_set_setting_changed_callback)dlsym(mPluginHandle,
618 MA_WAKEUP_MANAGER_FUNC_SET_SETTING_CHANGED_CALLBACK);
619 mWakeupManagerInterface.set_error_callback =
620 (wakeup_manager_set_error_callback)dlsym(mPluginHandle,
621 MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK);
622 mWakeupManagerInterface.set_streaming_section_changed_callback =
623 (wakeup_manager_set_streaming_section_changed_callback)dlsym(mPluginHandle,
624 MA_WAKEUP_MANAGER_FUNC_SET_STREAMING_SECTION_CHANGED_CALLBACK);
625 mWakeupManagerInterface.set_wakeup_engine_command_callback =
626 (wakeup_manager_set_wakeup_engine_command_callback)dlsym(mPluginHandle,
627 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_ENGINE_COMMAND_CALLBACK);
628 mWakeupManagerInterface.set_wakeup_service_state_changed_callback =
629 (wakeup_manager_set_wakeup_service_state_changed_callback)dlsym(mPluginHandle,
630 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_SERVICE_STATE_CHANGED_CALLBACK);
631 mWakeupManagerInterface.set_voice_key_status_changed_callback =
632 (wakeup_manager_set_voice_key_status_changed_callback)dlsym(mPluginHandle,
633 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_STATUS_CHANGED_CALLBACK);
636 if (NULL != mPluginHandle) {
637 wakeup_manager_initialize func = mWakeupManagerInterface.initialize;
640 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_INITIALIZE);
644 MAS_LOGE("[ERROR] Fail to initialize, ret(%d)", ret);
648 wakeup_manager_get_settings get_settings_func = mWakeupManagerInterface.get_settings;
650 if (NULL == get_settings_func) {
651 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
654 ret = get_settings_func(&mPluginSettings, &struct_size);
655 if (0 != ret || struct_size != sizeof(ma_plugin_settings)) {
656 MAS_LOGE("[ERROR] Fail to get settings, ret(%d), size %zu", ret, struct_size);
657 mPluginSettings = NULL;
661 MAS_LOGE("[ERROR] mPluginHandle is not valid");
666 int CServicePlugin::deinitialize(void)
673 MAS_LOGD("[Recorder ERROR] File not found!");
678 if (NULL != mPluginHandle) {
679 wakeup_manager_deinitialize func = mWakeupManagerInterface.deinitialize;
681 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_DEINITIALIZE);
685 MAS_LOGE("[ERROR] Fail to deinitialize, ret(%d)", ret);
689 dlclose(mPluginHandle);
690 mPluginHandle = NULL;
692 MAS_LOGE("[ERROR] mPluginHandle is not valid");
698 int CServicePlugin::get_settings(ma_plugin_settings **settings, size_t *struct_size)
701 if (NULL != mPluginHandle) {
702 wakeup_manager_get_settings func = mWakeupManagerInterface.get_settings;
704 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
706 ret = func(settings, struct_size);
708 MAS_LOGE("[ERROR] Fail to get settings, ret(%d)", ret);
712 MAS_LOGE("[ERROR] mPluginHandle is not valid");
717 int CServicePlugin::set_language(const char* language)
720 if (NULL != mPluginHandle) {
721 wakeup_manager_set_language func = mWakeupManagerInterface.set_language;
723 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE);
725 ret = func(language);
727 MAS_LOGE("[ERROR] Fail to set langauge(%s), ret(%d)", language, ret);
731 MAS_LOGE("[ERROR] mPluginHandle is not valid");
736 int CServicePlugin::add_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
739 if (NULL != mPluginHandle) {
740 wakeup_manager_add_assistant_wakeup_word func = mWakeupManagerInterface.add_assistant_wakeup_word;
742 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_WORD);
744 ret = func(appid, wakeup_word, language);
746 MAS_LOGE("[ERROR] Fail to add wakeup word(%s)(%s)(%s), ret(%d)", appid, wakeup_word, language, ret);
750 MAS_LOGE("[ERROR] mPluginHandle is not valid");
755 int CServicePlugin::remove_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
758 if (NULL != mPluginHandle) {
759 wakeup_manager_remove_assistant_wakeup_word func = mWakeupManagerInterface.remove_assistant_wakeup_word;
761 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_REMOVE_ASSISTANT_WAKEUP_WORD);
763 ret = func(appid, wakeup_word, language);
765 MAS_LOGE("[ERROR] Fail to remove wakeup word(%s)(%s)(%s), ret(%d)", appid, wakeup_word, language, ret);
769 MAS_LOGE("[ERROR] mPluginHandle is not valid");
774 int CServicePlugin::add_assistant_language(const char* appid, const char* language)
777 if (NULL != mPluginHandle) {
778 wakeup_manager_add_assistant_language func = mWakeupManagerInterface.add_assistant_language;
780 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE);
782 ret = func(appid, language);
784 MAS_LOGE("[ERROR] Fail to set wakeup word(%s)(%s), ret(%d)", appid, language, ret);
788 MAS_LOGE("[ERROR] mPluginHandle is not valid");
793 int CServicePlugin::set_assistant_wakeup_engine(const char* appid, const char* engine)
796 if (NULL != mPluginHandle) {
797 wakeup_manager_set_assistant_wakeup_engine func = mWakeupManagerInterface.set_assistant_wakeup_engine;
799 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_WAKEUP_ENGINE);
801 ret = func(appid, engine);
803 MAS_LOGE("[ERROR] Fail to set wakeup engine(%s)(%s), ret(%d)", appid, engine, ret);
807 MAS_LOGE("[ERROR] mPluginHandle is not valid");
812 int CServicePlugin::set_default_assistant(const char* appid)
815 if (NULL != mPluginHandle) {
816 wakeup_manager_set_default_assistant func = mWakeupManagerInterface.set_default_assistant;
818 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT);
822 MAS_LOGE("[ERROR] Fail to set default assistant(%s), ret(%d)", appid, ret);
826 MAS_LOGE("[ERROR] mPluginHandle is not valid");
831 int CServicePlugin::get_default_assistant(const char** appid)
835 MAS_LOGE("[ERROR] appid is not valid");
838 if (NULL != mPluginHandle) {
839 wakeup_manager_get_default_assistant func = mWakeupManagerInterface.get_default_assistant;
841 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT);
845 MAS_LOGE("[ERROR] Fail to get default assistant, ret(%d)", ret);
849 MAS_LOGE("[ERROR] mPluginHandle is not valid");
854 int CServicePlugin::activate(void)
857 if (NULL != mPluginHandle) {
858 wakeup_manager_activate func = mWakeupManagerInterface.activate;
860 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ACTIVATE);
864 MAS_LOGE("[ERROR] Fail to start recording, ret(%d)", ret);
868 MAS_LOGE("[ERROR] mPluginHandle is not valid");
873 int CServicePlugin::deactivate(void)
876 if (NULL != mPluginHandle) {
877 wakeup_manager_deactivate func = mWakeupManagerInterface.deactivate;
879 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_DEACTIVATE);
883 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
887 MAS_LOGE("[ERROR] mPluginHandle is not valid");
892 int CServicePlugin::update_voice_feedback_state(const char* appid, int state)
895 if (NULL != mPluginHandle) {
896 wakeup_manager_update_voice_feedback_state func = mWakeupManagerInterface.update_voice_feedback_state;
898 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_VOICE_FEEDBACK_STATE);
900 ret = func(appid, state);
902 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
906 MAS_LOGE("[ERROR] mPluginHandle is not valid");
911 int CServicePlugin::set_assistant_specific_command(const char* appid, const char* command)
914 if (NULL != mPluginHandle) {
915 wakeup_manager_set_assistant_specific_command func = mWakeupManagerInterface.set_assistant_specific_command;
917 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_SPECIFIC_COMMAND);
919 ret = func(appid, command);
921 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
925 MAS_LOGE("[ERROR] mPluginHandle is not valid");
930 int CServicePlugin::set_background_volume(const char* appid, double ratio)
933 if (NULL != mPluginHandle) {
934 wakeup_manager_set_background_volume func = mWakeupManagerInterface.set_background_volume;
936 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_BACKGROUND_VOLUME);
938 ret = func(appid, ratio);
940 MAS_LOGE("[ERROR] Fail to set background volume, ret(%d)", ret);
944 MAS_LOGE("[ERROR] mPluginHandle is not valid");
949 int CServicePlugin::update_recognition_result(const char* appid, int state)
952 if (NULL != mPluginHandle) {
953 wakeup_manager_update_recognition_result func = mWakeupManagerInterface.update_recognition_result;
955 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
957 ret = func(appid, state);
959 MAS_LOGE("[ERROR] Fail to update result state, ret(%d)", ret);
963 MAS_LOGE("[ERROR] mPluginHandle is not valid");
968 int CServicePlugin::process_event(int event, void *data, int len)
971 if (NULL != mPluginHandle) {
972 wakeup_manager_process_plugin_event func = mWakeupManagerInterface.process_plugin_event;
974 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_PROCESS_PLUGIN_EVENT);
976 ret = func((mas_plugin_event_e)event, data, len);
978 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
982 MAS_LOGE("[ERROR] mPluginHandle is not valid");
987 int CServicePlugin::start_streaming_utterance_data(void)
990 if (NULL != mPluginHandle) {
991 wakeup_manager_start_streaming_utterance_data func = mWakeupManagerInterface.start_streaming_utterance_data;
993 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA);
997 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1001 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1006 int CServicePlugin::stop_streaming_utterance_data(void)
1009 if (NULL != mPluginHandle) {
1010 wakeup_manager_stop_streaming_utterance_data func = mWakeupManagerInterface.stop_streaming_utterance_data;
1012 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_UTTERANCE_DATA);
1016 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1020 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1025 int CServicePlugin::start_streaming_previous_utterance_data(void)
1028 if (NULL != mPluginHandle) {
1029 wakeup_manager_start_streaming_previous_utterance_data func = mWakeupManagerInterface.start_streaming_previous_utterance_data;
1031 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_PREVIOUS_UTTERANCE_DATA);
1035 MAS_LOGE("[ERROR] Fail to request previous speech data, ret(%d)", ret);
1039 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1044 int CServicePlugin::stop_streaming_previous_utterance_data(void)
1047 if (NULL != mPluginHandle) {
1048 wakeup_manager_stop_streaming_previous_utterance_data func = mWakeupManagerInterface.stop_streaming_previous_utterance_data;
1050 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_PREVIOUS_UTTERANCE_DATA);
1054 MAS_LOGE("[ERROR] Fail to request previous speech data, ret(%d)", ret);
1058 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1063 int CServicePlugin::start_streaming_follow_up_data(void)
1066 if (NULL != mPluginHandle) {
1067 wakeup_manager_start_streaming_follow_up_data func = mWakeupManagerInterface.start_streaming_follow_up_data;
1069 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_FOLLOW_UP_DATA);
1073 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1077 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1082 int CServicePlugin::stop_streaming_follow_up_data(void)
1085 if (NULL != mPluginHandle) {
1086 wakeup_manager_stop_streaming_follow_up_data func = mWakeupManagerInterface.stop_streaming_follow_up_data;
1088 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_FOLLOW_UP_DATA);
1092 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1096 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1101 int CServicePlugin::get_recording_audio_format(int *rate, int *channel, int *audio_type)
1104 if (NULL != mPluginHandle) {
1105 wakeup_manager_get_audio_format func = mWakeupManagerInterface.get_audio_format;
1107 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT);
1109 ret = func(rate, channel, audio_type);
1111 MAS_LOGE("[ERROR] Fail to get recording audio format, ret(%d)", ret);
1115 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1120 int CServicePlugin::get_recording_audio_source_type(char** type)
1123 if (NULL != mPluginHandle) {
1124 wakeup_manager_get_audio_source_type func = mWakeupManagerInterface.get_audio_source_type;
1126 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
1130 MAS_LOGE("[ERROR] Fail to get recording audio source type, ret(%d)", ret);
1134 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1139 int CServicePlugin::set_voice_key_tap_duration(float duration)
1142 if (NULL != mPluginHandle) {
1143 wakeup_manager_set_voice_key_tap_duration func = mWakeupManagerInterface.set_voice_key_tap_duration;
1145 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_TAP_DURATION);
1147 ret = func(duration);
1149 MAS_LOGE("[ERROR] Fail to set voice key tap duration, ret(%d)", ret);
1153 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1158 int CServicePlugin::unset_voice_key_tap_duration()
1161 if (NULL != mPluginHandle) {
1162 wakeup_manager_unset_voice_key_tap_duration func = mWakeupManagerInterface.unset_voice_key_tap_duration;
1164 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UNSET_VOICE_KEY_TAP_DURATION);
1168 MAS_LOGE("[ERROR] Fail to unset voice key tap duration, ret(%d)", ret);
1172 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1177 int CServicePlugin::set_voice_key_support_mode(int mode)
1180 if (NULL != mPluginHandle) {
1181 wakeup_manager_set_voice_key_support_mode func = mWakeupManagerInterface.set_voice_key_support_mode;
1183 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_SUPPORT_MODE);
1187 MAS_LOGE("[ERROR] Fail to set voice key support mode, ret(%d)", ret);
1191 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1196 int CServicePlugin::set_wake_word_audio_require_flag(const char* appid, bool require)
1199 if (NULL != mPluginHandle) {
1200 wakeup_manager_set_wake_word_audio_require_flag func = mWakeupManagerInterface.set_wake_word_audio_require_flag;
1202 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG);
1204 ret = func(require);
1206 MAS_LOGE("[ERROR] Fail to set wake word audio require flag, ret(%d)", ret);
1210 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1215 int CServicePlugin::set_assistant_language(const char* appid, const char* language)
1218 if (NULL != mPluginHandle) {
1219 wakeup_manager_set_assistant_language func = mWakeupManagerInterface.set_assistant_language;
1221 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_LANGUAGE);
1223 ret = func(appid, language);
1225 MAS_LOGE("[ERROR] Fail to set assistant language, ret(%d)", ret);
1229 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1234 int CServicePlugin::set_callbacks(void)
1236 int ret = set_wakeup_event_callback(__wakeup_event_cb, this);
1238 MAS_LOGE("Fail to set wakeup event cb");
1242 ret = set_utterance_streaming_callback(__audio_streaming_cb, this);
1244 MAS_LOGE("Fail to set utterance streaming cb");
1248 ret = set_previous_utterance_streaming_callback(__audio_streaming_cb, this);
1250 MAS_LOGE("Fail to set previous utterance streaming cb");
1254 ret = set_follow_up_streaming_callback(__audio_streaming_cb, this);
1256 MAS_LOGE("Fail to set follow-up streaming cb");
1260 ret = set_speech_status_callback(__speech_status_cb, this);
1262 MAS_LOGE("Fail to set speech status changed cb");
1266 ret = set_setting_changed_callback(__setting_changed_cb, this);
1268 MAS_LOGE("Fail to set setting changed cb");
1272 ret = set_error_callback(__error_cb, this);
1274 MAS_LOGE("Fail to set error cb");
1278 ret = set_streaming_section_changed_callback(__streaming_section_changed_cb, this);
1280 MAS_LOGE("Fail to set streaming section changed cb");
1284 ret = set_wakeup_engine_command_callback(__wakeup_engine_command_cb, this);
1286 MAS_LOGE("Fail to set wakeup engine command cb");
1290 ret = set_wakeup_service_state_changed_callback(__wakeup_service_state_changed_cb, this);
1292 MAS_LOGE("Fail to set wakeup engine command cb");
1296 ret = set_voice_key_status_changed_callback(__wakeup_service_voice_key_status_changed_cb, this);
1298 MAS_LOGE("Fail to set wakeup engine command cb");
1305 int CServicePlugin::set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data)
1308 if (NULL != mPluginHandle) {
1309 wakeup_manager_set_wakeup_event_callback func = mWakeupManagerInterface.set_wakeup_event_callback;
1311 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
1313 ret = func(callback, user_data);
1314 MAS_LOGD("dalton debug : %p", user_data);
1316 MAS_LOGE("[ERROR] Fail to set wakeup event callback, ret(%d)", ret);
1320 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1325 int CServicePlugin::set_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1328 if (NULL != mPluginHandle) {
1329 wakeup_manager_set_utterance_streaming_callback func = mWakeupManagerInterface.set_utterance_streaming_callback;
1331 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_UTTERANCE_STREAMING_CALLBACK);
1333 ret = func(callback, user_data);
1335 MAS_LOGE("[ERROR] Fail to set utterance streaming callback, ret(%d)", ret);
1339 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1344 int CServicePlugin::set_previous_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1347 if (NULL != mPluginHandle) {
1348 wakeup_manager_set_previous_utterance_streaming_callback func = mWakeupManagerInterface.set_previous_utterance_streaming_callback;
1350 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_PREVIOUS_UTTERANCE_STREAMING_CALLBACK);
1352 ret = func(callback, user_data);
1354 MAS_LOGE("[ERROR] Fail to set utterance streaming callback, ret(%d)", ret);
1358 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1363 int CServicePlugin::set_follow_up_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1366 if (NULL != mPluginHandle) {
1367 wakeup_manager_set_follow_up_streaming_callback func = mWakeupManagerInterface.set_follow_up_streaming_callback;
1369 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_FOLLOW_UP_STREAMING_CALLBACK);
1371 ret = func(callback, user_data);
1373 MAS_LOGE("[ERROR] Fail to set follow-up streaming callback, ret(%d)", ret);
1377 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1382 int CServicePlugin::set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data)
1385 if (NULL != mPluginHandle) {
1386 wakeup_manager_set_speech_status_callback func = mWakeupManagerInterface.set_speech_status_callback;
1388 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK);
1390 ret = func(callback, user_data);
1392 MAS_LOGE("[ERROR] Fail to set speech status callback, ret(%d)", ret);
1399 int CServicePlugin::set_setting_changed_callback(wakeup_service_setting_changed_cb callback, void* user_data)
1402 if (NULL != mPluginHandle) {
1403 wakeup_manager_set_setting_changed_callback func = mWakeupManagerInterface.set_setting_changed_callback;
1405 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_SETTING_CHANGED_CALLBACK);
1407 ret = func(callback, user_data);
1409 MAS_LOGE("[ERROR] Fail to set setting_changed callback, ret(%d)", ret);
1416 int CServicePlugin::set_error_callback(wakeup_service_error_cb callback, void* user_data)
1419 if (NULL != mPluginHandle) {
1420 wakeup_manager_set_error_callback func = mWakeupManagerInterface.set_error_callback;
1422 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK);
1424 ret = func(callback, user_data);
1426 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1433 int CServicePlugin::set_streaming_section_changed_callback(wakeup_service_streaming_section_changed_cb callback, void* user_data)
1436 if (NULL != mPluginHandle) {
1437 wakeup_manager_set_streaming_section_changed_callback func = mWakeupManagerInterface.set_streaming_section_changed_callback;
1439 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_STREAMING_SECTION_CHANGED_CALLBACK);
1441 ret = func(callback, user_data);
1443 MAS_LOGE("[ERROR] Fail to set streaming section changed callback, ret(%d)", ret);
1450 int CServicePlugin::set_wakeup_engine_command_callback(wakeup_service_wakeup_engine_command_cb callback, void* user_data)
1453 if (NULL != mPluginHandle) {
1454 wakeup_manager_set_wakeup_engine_command_callback func = mWakeupManagerInterface.set_wakeup_engine_command_callback;
1456 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_ENGINE_COMMAND_CALLBACK);
1458 ret = func(callback, user_data);
1460 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1467 int CServicePlugin::set_wakeup_service_state_changed_callback(wakeup_service_wakeup_service_state_changed_cb callback, void* user_data)
1470 if (NULL != mPluginHandle) {
1471 wakeup_manager_set_wakeup_service_state_changed_callback func = mWakeupManagerInterface.set_wakeup_service_state_changed_callback;
1473 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_SERVICE_STATE_CHANGED_CALLBACK);
1475 ret = func(callback, user_data);
1477 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1484 int CServicePlugin::set_voice_key_status_changed_callback(wakeup_service_voice_key_status_changed_cb callback, void* user_data)
1487 if (NULL != mPluginHandle) {
1488 wakeup_manager_set_voice_key_status_changed_callback func = mWakeupManagerInterface.set_voice_key_status_changed_callback;
1490 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_STATUS_CHANGED_CALLBACK);
1492 ret = func(callback, user_data);
1494 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);