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 = nullptr;
505 mPluginHandle = dlopen(filepath, RTLD_LAZY);
506 if (nullptr != (error = dlerror())) {
507 MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error);
508 if (mPluginHandle) dlclose(mPluginHandle);
509 mPluginHandle = nullptr;
510 return -1; //MAS_ERROR_OPERATION_FAILED;
512 if (nullptr == mPluginHandle) {
513 MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error);
514 return -1; //MAS_ERROR_OPERATION_FAILED;
517 mWakeupManagerInterface.initialize =
518 (wakeup_manager_initialize)dlsym(mPluginHandle,
519 MA_WAKEUP_MANAGER_FUNC_INITIALIZE);
520 mWakeupManagerInterface.deinitialize =
521 (wakeup_manager_deinitialize)dlsym(mPluginHandle,
522 MA_WAKEUP_MANAGER_FUNC_DEINITIALIZE);
523 mWakeupManagerInterface.get_settings =
524 (wakeup_manager_get_settings)dlsym(mPluginHandle,
525 MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
526 mWakeupManagerInterface.add_assistant_wakeup_word =
527 (wakeup_manager_add_assistant_wakeup_word)dlsym(mPluginHandle,
528 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_WORD);
529 mWakeupManagerInterface.remove_assistant_wakeup_word =
530 (wakeup_manager_remove_assistant_wakeup_word)dlsym(mPluginHandle,
531 MA_WAKEUP_MANAGER_FUNC_REMOVE_ASSISTANT_WAKEUP_WORD);
532 mWakeupManagerInterface.add_assistant_language =
533 (wakeup_manager_add_assistant_language)dlsym(mPluginHandle,
534 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE);
535 mWakeupManagerInterface.set_assistant_wakeup_engine =
536 (wakeup_manager_set_assistant_wakeup_engine)dlsym(mPluginHandle,
537 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_WAKEUP_ENGINE);
538 mWakeupManagerInterface.set_default_assistant =
539 (wakeup_manager_set_default_assistant)dlsym(mPluginHandle,
540 MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT);
541 mWakeupManagerInterface.get_default_assistant =
542 (wakeup_manager_get_default_assistant)dlsym(mPluginHandle,
543 MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT);
544 mWakeupManagerInterface.set_language =
545 (wakeup_manager_set_language)dlsym(mPluginHandle,
546 MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE);
547 mWakeupManagerInterface.activate =
548 (wakeup_manager_activate)dlsym(mPluginHandle,
549 MA_WAKEUP_MANAGER_FUNC_ACTIVATE);
550 mWakeupManagerInterface.deactivate =
551 (wakeup_manager_deactivate)dlsym(mPluginHandle,
552 MA_WAKEUP_MANAGER_FUNC_DEACTIVATE);
553 mWakeupManagerInterface.update_voice_feedback_state =
554 (wakeup_manager_update_voice_feedback_state)dlsym(mPluginHandle,
555 MA_WAKEUP_MANAGER_FUNC_UPDATE_VOICE_FEEDBACK_STATE);
556 mWakeupManagerInterface.set_assistant_specific_command =
557 (wakeup_manager_set_assistant_specific_command)dlsym(mPluginHandle,
558 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_SPECIFIC_COMMAND);
559 mWakeupManagerInterface.set_background_volume =
560 (wakeup_manager_set_background_volume)dlsym(mPluginHandle,
561 MA_WAKEUP_MANAGER_FUNC_SET_BACKGROUND_VOLUME);
562 mWakeupManagerInterface.update_recognition_result =
563 (wakeup_manager_update_recognition_result)dlsym(mPluginHandle,
564 MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
565 mWakeupManagerInterface.process_plugin_event =
566 (wakeup_manager_process_plugin_event)dlsym(mPluginHandle,
567 MA_WAKEUP_MANAGER_FUNC_PROCESS_PLUGIN_EVENT);
568 mWakeupManagerInterface.start_streaming_utterance_data =
569 (wakeup_manager_start_streaming_utterance_data)dlsym(mPluginHandle,
570 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA);
571 mWakeupManagerInterface.stop_streaming_utterance_data =
572 (wakeup_manager_stop_streaming_utterance_data)dlsym(mPluginHandle,
573 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_UTTERANCE_DATA);
574 mWakeupManagerInterface.start_streaming_previous_utterance_data =
575 (wakeup_manager_start_streaming_previous_utterance_data)dlsym(mPluginHandle,
576 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_PREVIOUS_UTTERANCE_DATA);
577 mWakeupManagerInterface.stop_streaming_previous_utterance_data =
578 (wakeup_manager_stop_streaming_previous_utterance_data)dlsym(mPluginHandle,
579 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_PREVIOUS_UTTERANCE_DATA);
580 mWakeupManagerInterface.start_streaming_follow_up_data =
581 (wakeup_manager_start_streaming_follow_up_data)dlsym(mPluginHandle,
582 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_FOLLOW_UP_DATA);
583 mWakeupManagerInterface.stop_streaming_follow_up_data =
584 (wakeup_manager_stop_streaming_follow_up_data)dlsym(mPluginHandle,
585 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_FOLLOW_UP_DATA);
586 mWakeupManagerInterface.get_audio_format =
587 (wakeup_manager_get_audio_format)dlsym(mPluginHandle,
588 MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT);
589 mWakeupManagerInterface.get_audio_source_type =
590 (wakeup_manager_get_audio_source_type)dlsym(mPluginHandle,
591 MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
592 mWakeupManagerInterface.set_wake_word_audio_require_flag =
593 (wakeup_manager_set_wake_word_audio_require_flag)dlsym(mPluginHandle,
594 MA_WAKEUP_MANAGER_FUNC_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG);
595 mWakeupManagerInterface.set_assistant_language =
596 (wakeup_manager_set_assistant_language)dlsym(mPluginHandle,
597 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_LANGUAGE);
598 mWakeupManagerInterface.set_voice_key_tap_duration =
599 (wakeup_manager_set_voice_key_tap_duration)dlsym(mPluginHandle,
600 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_TAP_DURATION);
601 mWakeupManagerInterface.unset_voice_key_tap_duration =
602 (wakeup_manager_unset_voice_key_tap_duration)dlsym(mPluginHandle,
603 MA_WAKEUP_MANAGER_FUNC_UNSET_VOICE_KEY_TAP_DURATION);
604 mWakeupManagerInterface.set_voice_key_support_mode =
605 (wakeup_manager_set_voice_key_support_mode)dlsym(mPluginHandle,
606 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_SUPPORT_MODE);
607 mWakeupManagerInterface.set_wakeup_event_callback =
608 (wakeup_manager_set_wakeup_event_callback)dlsym(mPluginHandle,
609 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
610 mWakeupManagerInterface.set_utterance_streaming_callback =
611 (wakeup_manager_set_utterance_streaming_callback)dlsym(mPluginHandle,
612 MA_WAKEUP_MANAGER_FUNC_SET_UTTERANCE_STREAMING_CALLBACK);
613 mWakeupManagerInterface.set_previous_utterance_streaming_callback =
614 (wakeup_manager_set_previous_utterance_streaming_callback)dlsym(mPluginHandle,
615 MA_WAKEUP_MANAGER_FUNC_SET_PREVIOUS_UTTERANCE_STREAMING_CALLBACK);
616 mWakeupManagerInterface.set_follow_up_streaming_callback =
617 (wakeup_manager_set_follow_up_streaming_callback)dlsym(mPluginHandle,
618 MA_WAKEUP_MANAGER_FUNC_SET_FOLLOW_UP_STREAMING_CALLBACK);
619 mWakeupManagerInterface.set_speech_status_callback =
620 (wakeup_manager_set_speech_status_callback)dlsym(mPluginHandle,
621 MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK);
622 mWakeupManagerInterface.set_setting_changed_callback =
623 (wakeup_manager_set_setting_changed_callback)dlsym(mPluginHandle,
624 MA_WAKEUP_MANAGER_FUNC_SET_SETTING_CHANGED_CALLBACK);
625 mWakeupManagerInterface.set_error_callback =
626 (wakeup_manager_set_error_callback)dlsym(mPluginHandle,
627 MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK);
628 mWakeupManagerInterface.set_streaming_section_changed_callback =
629 (wakeup_manager_set_streaming_section_changed_callback)dlsym(mPluginHandle,
630 MA_WAKEUP_MANAGER_FUNC_SET_STREAMING_SECTION_CHANGED_CALLBACK);
631 mWakeupManagerInterface.set_wakeup_engine_command_callback =
632 (wakeup_manager_set_wakeup_engine_command_callback)dlsym(mPluginHandle,
633 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_ENGINE_COMMAND_CALLBACK);
634 mWakeupManagerInterface.set_wakeup_service_state_changed_callback =
635 (wakeup_manager_set_wakeup_service_state_changed_callback)dlsym(mPluginHandle,
636 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_SERVICE_STATE_CHANGED_CALLBACK);
637 mWakeupManagerInterface.set_voice_key_status_changed_callback =
638 (wakeup_manager_set_voice_key_status_changed_callback)dlsym(mPluginHandle,
639 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_STATUS_CHANGED_CALLBACK);
642 if (NULL != mPluginHandle) {
643 wakeup_manager_initialize func = mWakeupManagerInterface.initialize;
646 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_INITIALIZE);
650 MAS_LOGE("[ERROR] Fail to initialize, ret(%d)", ret);
654 wakeup_manager_get_settings get_settings_func = mWakeupManagerInterface.get_settings;
656 if (NULL == get_settings_func) {
657 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
660 ret = get_settings_func(&mPluginSettings, &struct_size);
661 if (0 != ret || struct_size != sizeof(ma_plugin_settings)) {
662 MAS_LOGE("[ERROR] Fail to get settings, ret(%d), size %zu", ret, struct_size);
663 mPluginSettings = NULL;
667 MAS_LOGE("[ERROR] mPluginHandle is not valid");
672 int CServicePlugin::deinitialize(void)
679 MAS_LOGD("[Recorder ERROR] File not found!");
684 if (NULL != mPluginHandle) {
685 wakeup_manager_deinitialize func = mWakeupManagerInterface.deinitialize;
687 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_DEINITIALIZE);
691 MAS_LOGE("[ERROR] Fail to deinitialize, ret(%d)", ret);
695 dlclose(mPluginHandle);
696 mPluginHandle = NULL;
698 MAS_LOGE("[ERROR] mPluginHandle is not valid");
704 int CServicePlugin::get_settings(ma_plugin_settings **settings, size_t *struct_size)
707 if (NULL != mPluginHandle) {
708 wakeup_manager_get_settings func = mWakeupManagerInterface.get_settings;
710 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
712 ret = func(settings, struct_size);
714 MAS_LOGE("[ERROR] Fail to get settings, ret(%d)", ret);
718 MAS_LOGE("[ERROR] mPluginHandle is not valid");
723 int CServicePlugin::set_language(const char* language)
726 if (NULL != mPluginHandle) {
727 wakeup_manager_set_language func = mWakeupManagerInterface.set_language;
729 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE);
731 ret = func(language);
733 MAS_LOGE("[ERROR] Fail to set langauge(%s), ret(%d)", language, ret);
737 MAS_LOGE("[ERROR] mPluginHandle is not valid");
742 int CServicePlugin::add_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
745 if (NULL != mPluginHandle) {
746 wakeup_manager_add_assistant_wakeup_word func = mWakeupManagerInterface.add_assistant_wakeup_word;
748 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_WORD);
750 ret = func(appid, wakeup_word, language);
752 MAS_LOGE("[ERROR] Fail to add wakeup word(%s)(%s)(%s), ret(%d)", appid, wakeup_word, language, ret);
756 MAS_LOGE("[ERROR] mPluginHandle is not valid");
761 int CServicePlugin::remove_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
764 if (NULL != mPluginHandle) {
765 wakeup_manager_remove_assistant_wakeup_word func = mWakeupManagerInterface.remove_assistant_wakeup_word;
767 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_REMOVE_ASSISTANT_WAKEUP_WORD);
769 ret = func(appid, wakeup_word, language);
771 MAS_LOGE("[ERROR] Fail to remove wakeup word(%s)(%s)(%s), ret(%d)", appid, wakeup_word, language, ret);
775 MAS_LOGE("[ERROR] mPluginHandle is not valid");
780 int CServicePlugin::add_assistant_language(const char* appid, const char* language)
783 if (NULL != mPluginHandle) {
784 wakeup_manager_add_assistant_language func = mWakeupManagerInterface.add_assistant_language;
786 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE);
788 ret = func(appid, language);
790 MAS_LOGE("[ERROR] Fail to set wakeup word(%s)(%s), ret(%d)", appid, language, ret);
794 MAS_LOGE("[ERROR] mPluginHandle is not valid");
799 int CServicePlugin::set_assistant_wakeup_engine(const char* appid, const char* engine)
802 if (NULL != mPluginHandle) {
803 wakeup_manager_set_assistant_wakeup_engine func = mWakeupManagerInterface.set_assistant_wakeup_engine;
805 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_WAKEUP_ENGINE);
807 ret = func(appid, engine);
809 MAS_LOGE("[ERROR] Fail to set wakeup engine(%s)(%s), ret(%d)", appid, engine, ret);
813 MAS_LOGE("[ERROR] mPluginHandle is not valid");
818 int CServicePlugin::set_default_assistant(const char* appid)
821 if (NULL != mPluginHandle) {
822 wakeup_manager_set_default_assistant func = mWakeupManagerInterface.set_default_assistant;
824 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT);
828 MAS_LOGE("[ERROR] Fail to set default assistant(%s), ret(%d)", appid, ret);
832 MAS_LOGE("[ERROR] mPluginHandle is not valid");
837 int CServicePlugin::get_default_assistant(const char** appid)
841 MAS_LOGE("[ERROR] appid is not valid");
844 if (NULL != mPluginHandle) {
845 wakeup_manager_get_default_assistant func = mWakeupManagerInterface.get_default_assistant;
847 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT);
851 MAS_LOGE("[ERROR] Fail to get default assistant, ret(%d)", ret);
855 MAS_LOGE("[ERROR] mPluginHandle is not valid");
860 int CServicePlugin::activate(void)
863 if (NULL != mPluginHandle) {
864 wakeup_manager_activate func = mWakeupManagerInterface.activate;
866 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ACTIVATE);
870 MAS_LOGE("[ERROR] Fail to start recording, ret(%d)", ret);
874 MAS_LOGE("[ERROR] mPluginHandle is not valid");
879 int CServicePlugin::deactivate(void)
882 if (NULL != mPluginHandle) {
883 wakeup_manager_deactivate func = mWakeupManagerInterface.deactivate;
885 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_DEACTIVATE);
889 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
893 MAS_LOGE("[ERROR] mPluginHandle is not valid");
898 int CServicePlugin::update_voice_feedback_state(const char* appid, int state)
901 if (NULL != mPluginHandle) {
902 wakeup_manager_update_voice_feedback_state func = mWakeupManagerInterface.update_voice_feedback_state;
904 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_VOICE_FEEDBACK_STATE);
906 ret = func(appid, state);
908 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
912 MAS_LOGE("[ERROR] mPluginHandle is not valid");
917 int CServicePlugin::set_assistant_specific_command(const char* appid, const char* command)
920 if (NULL != mPluginHandle) {
921 wakeup_manager_set_assistant_specific_command func = mWakeupManagerInterface.set_assistant_specific_command;
923 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_SPECIFIC_COMMAND);
925 ret = func(appid, command);
927 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
931 MAS_LOGE("[ERROR] mPluginHandle is not valid");
936 int CServicePlugin::set_background_volume(const char* appid, double ratio)
939 if (NULL != mPluginHandle) {
940 wakeup_manager_set_background_volume func = mWakeupManagerInterface.set_background_volume;
942 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_BACKGROUND_VOLUME);
944 ret = func(appid, ratio);
946 MAS_LOGE("[ERROR] Fail to set background volume, ret(%d)", ret);
950 MAS_LOGE("[ERROR] mPluginHandle is not valid");
955 int CServicePlugin::update_recognition_result(const char* appid, int state)
958 if (NULL != mPluginHandle) {
959 wakeup_manager_update_recognition_result func = mWakeupManagerInterface.update_recognition_result;
961 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
963 ret = func(appid, state);
965 MAS_LOGE("[ERROR] Fail to update result state, ret(%d)", ret);
969 MAS_LOGE("[ERROR] mPluginHandle is not valid");
974 int CServicePlugin::process_event(int event, void *data, int len)
977 if (NULL != mPluginHandle) {
978 wakeup_manager_process_plugin_event func = mWakeupManagerInterface.process_plugin_event;
980 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_PROCESS_PLUGIN_EVENT);
982 ret = func((mas_plugin_event_e)event, data, len);
984 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
988 MAS_LOGE("[ERROR] mPluginHandle is not valid");
993 int CServicePlugin::start_streaming_utterance_data(void)
996 if (NULL != mPluginHandle) {
997 wakeup_manager_start_streaming_utterance_data func = mWakeupManagerInterface.start_streaming_utterance_data;
999 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA);
1003 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1007 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1012 int CServicePlugin::stop_streaming_utterance_data(void)
1015 if (NULL != mPluginHandle) {
1016 wakeup_manager_stop_streaming_utterance_data func = mWakeupManagerInterface.stop_streaming_utterance_data;
1018 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_UTTERANCE_DATA);
1022 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1026 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1031 int CServicePlugin::start_streaming_previous_utterance_data(void)
1034 if (NULL != mPluginHandle) {
1035 wakeup_manager_start_streaming_previous_utterance_data func = mWakeupManagerInterface.start_streaming_previous_utterance_data;
1037 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_PREVIOUS_UTTERANCE_DATA);
1041 MAS_LOGE("[ERROR] Fail to request previous speech data, ret(%d)", ret);
1045 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1050 int CServicePlugin::stop_streaming_previous_utterance_data(void)
1053 if (NULL != mPluginHandle) {
1054 wakeup_manager_stop_streaming_previous_utterance_data func = mWakeupManagerInterface.stop_streaming_previous_utterance_data;
1056 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_PREVIOUS_UTTERANCE_DATA);
1060 MAS_LOGE("[ERROR] Fail to request previous speech data, ret(%d)", ret);
1064 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1069 int CServicePlugin::start_streaming_follow_up_data(void)
1072 if (NULL != mPluginHandle) {
1073 wakeup_manager_start_streaming_follow_up_data func = mWakeupManagerInterface.start_streaming_follow_up_data;
1075 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_FOLLOW_UP_DATA);
1079 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1083 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1088 int CServicePlugin::stop_streaming_follow_up_data(void)
1091 if (NULL != mPluginHandle) {
1092 wakeup_manager_stop_streaming_follow_up_data func = mWakeupManagerInterface.stop_streaming_follow_up_data;
1094 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_FOLLOW_UP_DATA);
1098 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1102 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1107 int CServicePlugin::get_recording_audio_format(int *rate, int *channel, int *audio_type)
1110 if (NULL != mPluginHandle) {
1111 wakeup_manager_get_audio_format func = mWakeupManagerInterface.get_audio_format;
1113 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT);
1115 ret = func(rate, channel, audio_type);
1117 MAS_LOGE("[ERROR] Fail to get recording audio format, ret(%d)", ret);
1121 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1126 int CServicePlugin::get_recording_audio_source_type(char** type)
1129 if (NULL != mPluginHandle) {
1130 wakeup_manager_get_audio_source_type func = mWakeupManagerInterface.get_audio_source_type;
1132 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
1136 MAS_LOGE("[ERROR] Fail to get recording audio source type, ret(%d)", ret);
1140 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1145 int CServicePlugin::set_voice_key_tap_duration(float duration)
1148 if (NULL != mPluginHandle) {
1149 wakeup_manager_set_voice_key_tap_duration func = mWakeupManagerInterface.set_voice_key_tap_duration;
1151 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_TAP_DURATION);
1153 ret = func(duration);
1155 MAS_LOGE("[ERROR] Fail to set voice key tap duration, ret(%d)", ret);
1159 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1164 int CServicePlugin::unset_voice_key_tap_duration()
1167 if (NULL != mPluginHandle) {
1168 wakeup_manager_unset_voice_key_tap_duration func = mWakeupManagerInterface.unset_voice_key_tap_duration;
1170 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UNSET_VOICE_KEY_TAP_DURATION);
1174 MAS_LOGE("[ERROR] Fail to unset voice key tap duration, ret(%d)", ret);
1178 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1183 int CServicePlugin::set_voice_key_support_mode(int mode)
1186 if (NULL != mPluginHandle) {
1187 wakeup_manager_set_voice_key_support_mode func = mWakeupManagerInterface.set_voice_key_support_mode;
1189 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_SUPPORT_MODE);
1193 MAS_LOGE("[ERROR] Fail to set voice key support mode, ret(%d)", ret);
1197 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1202 int CServicePlugin::set_wake_word_audio_require_flag(const char* appid, bool require)
1205 if (NULL != mPluginHandle) {
1206 wakeup_manager_set_wake_word_audio_require_flag func = mWakeupManagerInterface.set_wake_word_audio_require_flag;
1208 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG);
1210 ret = func(require);
1212 MAS_LOGE("[ERROR] Fail to set wake word audio require flag, ret(%d)", ret);
1216 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1221 int CServicePlugin::set_assistant_language(const char* appid, const char* language)
1224 if (NULL != mPluginHandle) {
1225 wakeup_manager_set_assistant_language func = mWakeupManagerInterface.set_assistant_language;
1227 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_LANGUAGE);
1229 ret = func(appid, language);
1231 MAS_LOGE("[ERROR] Fail to set assistant language, ret(%d)", ret);
1235 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1240 int CServicePlugin::set_callbacks(void)
1242 int ret = set_wakeup_event_callback(__wakeup_event_cb, this);
1244 MAS_LOGE("Fail to set wakeup event cb");
1248 ret = set_utterance_streaming_callback(__audio_streaming_cb, this);
1250 MAS_LOGE("Fail to set utterance streaming cb");
1254 ret = set_previous_utterance_streaming_callback(__audio_streaming_cb, this);
1256 MAS_LOGE("Fail to set previous utterance streaming cb");
1260 ret = set_follow_up_streaming_callback(__audio_streaming_cb, this);
1262 MAS_LOGE("Fail to set follow-up streaming cb");
1266 ret = set_speech_status_callback(__speech_status_cb, this);
1268 MAS_LOGE("Fail to set speech status changed cb");
1272 ret = set_setting_changed_callback(__setting_changed_cb, this);
1274 MAS_LOGE("Fail to set setting changed cb");
1278 ret = set_error_callback(__error_cb, this);
1280 MAS_LOGE("Fail to set error cb");
1284 ret = set_streaming_section_changed_callback(__streaming_section_changed_cb, this);
1286 MAS_LOGE("Fail to set streaming section changed cb");
1290 ret = set_wakeup_engine_command_callback(__wakeup_engine_command_cb, this);
1292 MAS_LOGE("Fail to set wakeup engine command cb");
1296 ret = set_wakeup_service_state_changed_callback(__wakeup_service_state_changed_cb, this);
1298 MAS_LOGE("Fail to set wakeup engine command cb");
1302 ret = set_voice_key_status_changed_callback(__wakeup_service_voice_key_status_changed_cb, this);
1304 MAS_LOGE("Fail to set wakeup engine command cb");
1311 int CServicePlugin::set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data)
1314 if (NULL != mPluginHandle) {
1315 wakeup_manager_set_wakeup_event_callback func = mWakeupManagerInterface.set_wakeup_event_callback;
1317 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
1319 ret = func(callback, user_data);
1320 MAS_LOGD("dalton debug : %p", user_data);
1322 MAS_LOGE("[ERROR] Fail to set wakeup event callback, ret(%d)", ret);
1326 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1331 int CServicePlugin::set_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1334 if (NULL != mPluginHandle) {
1335 wakeup_manager_set_utterance_streaming_callback func = mWakeupManagerInterface.set_utterance_streaming_callback;
1337 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_UTTERANCE_STREAMING_CALLBACK);
1339 ret = func(callback, user_data);
1341 MAS_LOGE("[ERROR] Fail to set utterance streaming callback, ret(%d)", ret);
1345 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1350 int CServicePlugin::set_previous_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1353 if (NULL != mPluginHandle) {
1354 wakeup_manager_set_previous_utterance_streaming_callback func = mWakeupManagerInterface.set_previous_utterance_streaming_callback;
1356 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_PREVIOUS_UTTERANCE_STREAMING_CALLBACK);
1358 ret = func(callback, user_data);
1360 MAS_LOGE("[ERROR] Fail to set utterance streaming callback, ret(%d)", ret);
1364 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1369 int CServicePlugin::set_follow_up_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1372 if (NULL != mPluginHandle) {
1373 wakeup_manager_set_follow_up_streaming_callback func = mWakeupManagerInterface.set_follow_up_streaming_callback;
1375 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_FOLLOW_UP_STREAMING_CALLBACK);
1377 ret = func(callback, user_data);
1379 MAS_LOGE("[ERROR] Fail to set follow-up streaming callback, ret(%d)", ret);
1383 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1388 int CServicePlugin::set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data)
1391 if (NULL != mPluginHandle) {
1392 wakeup_manager_set_speech_status_callback func = mWakeupManagerInterface.set_speech_status_callback;
1394 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK);
1396 ret = func(callback, user_data);
1398 MAS_LOGE("[ERROR] Fail to set speech status callback, ret(%d)", ret);
1405 int CServicePlugin::set_setting_changed_callback(wakeup_service_setting_changed_cb callback, void* user_data)
1408 if (NULL != mPluginHandle) {
1409 wakeup_manager_set_setting_changed_callback func = mWakeupManagerInterface.set_setting_changed_callback;
1411 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_SETTING_CHANGED_CALLBACK);
1413 ret = func(callback, user_data);
1415 MAS_LOGE("[ERROR] Fail to set setting_changed callback, ret(%d)", ret);
1422 int CServicePlugin::set_error_callback(wakeup_service_error_cb callback, void* user_data)
1425 if (NULL != mPluginHandle) {
1426 wakeup_manager_set_error_callback func = mWakeupManagerInterface.set_error_callback;
1428 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK);
1430 ret = func(callback, user_data);
1432 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1439 int CServicePlugin::set_streaming_section_changed_callback(wakeup_service_streaming_section_changed_cb callback, void* user_data)
1442 if (NULL != mPluginHandle) {
1443 wakeup_manager_set_streaming_section_changed_callback func = mWakeupManagerInterface.set_streaming_section_changed_callback;
1445 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_STREAMING_SECTION_CHANGED_CALLBACK);
1447 ret = func(callback, user_data);
1449 MAS_LOGE("[ERROR] Fail to set streaming section changed callback, ret(%d)", ret);
1456 int CServicePlugin::set_wakeup_engine_command_callback(wakeup_service_wakeup_engine_command_cb callback, void* user_data)
1459 if (NULL != mPluginHandle) {
1460 wakeup_manager_set_wakeup_engine_command_callback func = mWakeupManagerInterface.set_wakeup_engine_command_callback;
1462 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_ENGINE_COMMAND_CALLBACK);
1464 ret = func(callback, user_data);
1466 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1473 int CServicePlugin::set_wakeup_service_state_changed_callback(wakeup_service_wakeup_service_state_changed_cb callback, void* user_data)
1476 if (NULL != mPluginHandle) {
1477 wakeup_manager_set_wakeup_service_state_changed_callback func = mWakeupManagerInterface.set_wakeup_service_state_changed_callback;
1479 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_SERVICE_STATE_CHANGED_CALLBACK);
1481 ret = func(callback, user_data);
1483 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1490 int CServicePlugin::set_voice_key_status_changed_callback(wakeup_service_voice_key_status_changed_cb callback, void* user_data)
1493 if (NULL != mPluginHandle) {
1494 wakeup_manager_set_voice_key_status_changed_callback func = mWakeupManagerInterface.set_voice_key_status_changed_callback;
1496 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_STATUS_CHANGED_CALLBACK);
1498 ret = func(callback, user_data);
1500 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);