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 */
40 static int g_last_wakeup_event_id = 0;
45 CServicePlugin* plugin;
48 bool CServicePlugin::is_ui_panel_enabled()
50 /* By default we assume the ui panel is always enabled unless explicitly turned off */
52 if (mPluginSettings) {
53 ret = mPluginSettings->ui_panel_enabled;
55 MAS_LOGD("UI Panel Enabled : %d", ret);
59 #if 0 /* + TEST_CODE */
60 Eina_Bool __send_asr_result(void *data)
64 if (!strcmp((char*)data, "Today's")) {
65 masc_ui_dbus_send_asr_result(-1, 1, "Today's");
67 if (!strcmp((char*)data, "weather.")) {
68 masc_ui_dbus_send_asr_result(-1, 0, "Today's weather.");
75 Eina_Bool __send_result(void *data)
79 int ret = masc_ui_dbus_send_result(-1, (const char*)data, (const char*)data, "test");
81 MAS_LOGE("[ERROR] Fail to stop recording(%d)", ret);
88 #endif /* -TEST_CODE */
90 static void process_wakeup_event_by_appid_timer(void* data)
92 if (nullptr == data) return;
94 AsyncParam* param = static_cast<AsyncParam*>(data);
96 char* appid = static_cast<char*>(param->data);
97 MAS_LOGI("[ENTER] appid(%s), id(%d), g_last_wakeup_event_id(%d)",
98 appid, param->id, g_last_wakeup_event_id);
105 if (param->id < g_last_wakeup_event_id) {
113 CServicePlugin* plugin = param->plugin;
114 CServiceIpcDbus* service_ipc = nullptr;
115 CServiceMain* service_main = nullptr;
117 service_ipc = plugin->get_service_ipc();
118 service_main = plugin->get_service_main();
121 if (service_ipc && service_main) {
122 bool use_custom_ui = service_main->get_client_custom_ui_option_by_appid(appid);
123 bool ui_panel_enabled = false;
124 if (param->plugin) ui_panel_enabled = param->plugin->is_ui_panel_enabled();
125 if (ui_panel_enabled) {
126 service_ipc->masc_ui_dbus_enable_common_ui(!use_custom_ui);
127 service_ipc->masc_ui_dbus_change_assistant(appid);
130 service_main->set_current_client_by_appid(appid);
131 if ((pid = service_main->get_client_pid_by_appid(appid)) != -1) {
132 service_main->client_send_preprocessing_information(pid);
133 service_ipc->change_active_state(pid, MA_ACTIVE_STATE_ACTIVE);
134 service_main->process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
136 // Appropriate MA Client not available, trying to launch new one
137 MAS_LOGI("MA Client with appid %s does not exist, launching client", appid);
138 service_main->launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);
142 if (param->data) free(param->data);
146 static void process_wakeup_event_by_word_timer(void* data)
148 if (nullptr == data) return;
150 AsyncParam* param = static_cast<AsyncParam*>(data);
151 MAS_LOGI("[ENTER] wakeword(%s), id(%d)", (const char*)(param->data), param->id);
158 char* wakeup_word = static_cast<char*>(param->data);
159 const char* appid = nullptr;
161 CServicePlugin* plugin = param->plugin;
162 CServiceMain* service_main = nullptr;
165 service_main = plugin->get_service_main();
167 appid = service_main->get_client_appid_by_wakeup_word(wakeup_word);
175 if (service_main && appid) {
176 param = new(std::nothrow) AsyncParam;
179 param->data = static_cast<void*>(strdup(appid));
180 param->plugin = plugin;
181 process_wakeup_event_by_appid_timer(static_cast<void*>(param));
189 static void __wakeup_event_cb(mas_wakeup_event_info wakeup_info, void* user_data)
191 MAS_LOGI("[SUCCESS] __wakeup_event_cb is called, wakeup_word(%s)", wakeup_info.wakeup_word);
194 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
196 CServiceIpcDbus* service_ipc = plugin->get_service_ipc();
197 if (plugin->is_ui_panel_enabled() && service_ipc) {
200 ret = service_ipc->masc_ui_dbus_send_hello();
203 MAS_LOGE("[ERROR] Fail to receive reply for hello, ret(%d)", ret);
215 MAS_LOGD("[Recorder Info] File not found!");
219 snprintf(mDumpFilename, sizeof(mDumpFilename), "/tmp/ma_service_%d_%d", getpid(), mDumpCount);
220 int ret = access(mDumpFilename, 0);
223 MAS_LOGD("[Recorder ERROR] File is already exist");
224 if (0 == remove(mDumpFilename)) {
225 MAS_LOGD("[Recorder] Remove file");
235 MAS_LOGD("[Recorder] Temp file name=[%s]", mDumpFilename);
238 mDumpFile = fopen(mDumpFilename, "wb+x");
240 MAS_LOGD("[Recorder ERROR] File not found!");
246 #if 0 /* + TEST_CODE */
247 if (WAKEUP_EVENT_SUCCESS == event) {
248 ecore_thread_main_loop_begin();
249 ecore_timer_add(1.0, __send_asr_result, "Today's");
250 ecore_thread_main_loop_end();
252 ecore_thread_main_loop_begin();
253 ecore_timer_add(2.0, __send_asr_result, "weather.");
254 ecore_thread_main_loop_end();
256 ecore_thread_main_loop_begin();
257 ecore_timer_add(3.0, __send_result, "Partly cloudy with temperatures from 75 to 88");
258 ecore_thread_main_loop_end();
260 #endif /* - TEST_CODE */
261 if (wakeup_info.wakeup_appid) {
262 AsyncParam* param = new(std::nothrow) AsyncParam;
264 param->id = ++g_last_wakeup_event_id;
265 param->data = static_cast<void*>(strdup(wakeup_info.wakeup_appid));
266 param->plugin = static_cast<CServicePlugin*>(user_data);
267 ecore_main_loop_thread_safe_call_async(process_wakeup_event_by_appid_timer,
268 static_cast<void*>(param));
270 } else if (wakeup_info.wakeup_word) {
271 AsyncParam* param = new(std::nothrow) AsyncParam;
273 param->id = ++g_last_wakeup_event_id;
274 param->data = static_cast<void*>(strdup(wakeup_info.wakeup_word));
275 param->plugin = static_cast<CServicePlugin*>(user_data);
276 ecore_main_loop_thread_safe_call_async(process_wakeup_event_by_word_timer,
277 static_cast<void*>(param));
282 static bool __validate_streaming_event_order(pid_t pid, mas_speech_streaming_event_e *event)
286 static int previous_pid = -1;
287 static mas_speech_streaming_event_e previous_event = MAS_SPEECH_STREAMING_EVENT_FINISH;
289 if (NULL == event) return false;
291 mas_speech_streaming_event_e expected_sequence[][2] = {
292 {MAS_SPEECH_STREAMING_EVENT_START, MAS_SPEECH_STREAMING_EVENT_CONTINUE},
293 {MAS_SPEECH_STREAMING_EVENT_START, MAS_SPEECH_STREAMING_EVENT_FINISH},
294 {MAS_SPEECH_STREAMING_EVENT_CONTINUE, MAS_SPEECH_STREAMING_EVENT_CONTINUE},
295 {MAS_SPEECH_STREAMING_EVENT_CONTINUE, MAS_SPEECH_STREAMING_EVENT_FINISH},
296 {MAS_SPEECH_STREAMING_EVENT_FINISH, MAS_SPEECH_STREAMING_EVENT_START},
297 /* If there is no audio data even after the start streaming request */
298 {MAS_SPEECH_STREAMING_EVENT_FINISH, MAS_SPEECH_STREAMING_EVENT_FINISH},
301 if (pid != previous_pid) {
302 /* When sending streaming event to a new client, it always sends START message first */
303 previous_event = MAS_SPEECH_STREAMING_EVENT_FINISH;
306 for (int loop = 0;loop < sizeof(expected_sequence) / sizeof(expected_sequence[0]);loop++) {
307 if (previous_event == expected_sequence[loop][0] &&
308 *event == expected_sequence[loop][1]) {
313 /* In case of FINISH -> CONTINUE without START, simply modify current event value */
314 if (MAS_SPEECH_STREAMING_EVENT_FINISH == previous_event &&
315 MAS_SPEECH_STREAMING_EVENT_CONTINUE == *event) {
316 *event = MAS_SPEECH_STREAMING_EVENT_START;
319 MAS_LOGD("[WARNING] forcibly changed CONTINUE to START : %d -> %d (PID %d -> %d)",
320 previous_event, *event, previous_pid, pid);
326 previous_event = *event;
328 MAS_LOGE("[ERROR] State sequence validation failed : %d -> %d (PID %d -> %d)",
329 previous_event, *event, previous_pid, pid);
334 void handle_speech_streaming_event_failure(void* data)
336 AsyncParam* param = static_cast<AsyncParam*>(data);
337 if (NULL == param) return;
339 CServicePlugin* plugin = param->plugin;
340 CServiceMain* service_main = nullptr;
341 if (plugin) service_main = plugin->get_service_main();
344 pid_t pid = service_main->get_current_client_pid();
345 service_main->client_send_recognition_result(pid, MA_RECOGNITION_RESULT_EVENT_ERROR);
351 static void __audio_streaming_cb(mas_speech_streaming_event_e event, void* buffer, int len, void *user_data)
353 CServicePlugin* plugin = static_cast<CServicePlugin*>(user_data);
355 if (event == MAS_SPEECH_STREAMING_EVENT_FAIL) {
356 AsyncParam* param = new(std::nothrow) AsyncParam;
358 param->plugin = plugin;
359 ecore_main_loop_thread_safe_call_async(
360 handle_speech_streaming_event_failure, static_cast<void*>(param));
364 static int count = 0;
365 if (event != MAS_SPEECH_STREAMING_EVENT_CONTINUE || count % 100 == 0) {
366 MAS_LOGI("[SUCCESS] __audio_streaming_cb is called, event(%d), buffer(%p), len(%d)",
371 CServiceIpcDbus* service_ipc = nullptr;
372 CServiceMain* service_main = nullptr;
374 service_ipc = plugin->get_service_ipc();
375 service_main = plugin->get_service_main();
378 if (service_ipc && service_main) {
379 /* First check if we have dedicated audio processing app for current client */
380 pid_t pid = service_main->get_current_audio_processing_pid();
381 /* If not, send audio data to the main client */
382 if (-1 == pid) pid = service_main->get_current_client_pid();
384 int preprocessing_pid = service_main->get_current_preprocessing_client_pid();
386 MAS_LOGE("[ERROR] Fail to retrieve pid of current MA client");
388 if (__validate_streaming_event_order(pid, &event)) {
389 int ret = service_ipc->send_streaming_audio_data(pid,
392 MAS_LOGE("[ERROR] Fail to send speech data, ret(%d)", ret);
394 if (pid != preprocessing_pid && -1 != preprocessing_pid) {
395 int ret = service_ipc->send_streaming_audio_data(preprocessing_pid,
398 MAS_LOGE("[ERROR] Fail to send speech data to preprocessing client, ret(%d)", ret);
406 fwrite(speech_data->buffer, 1, speech_data->len, mDumpFile);
408 if (MAS_SPEECH_STREAMING_EVENT_FINISH == event) {
410 MAS_LOGE("[Recorder SUCCESS] File Close");
414 MAS_LOGE("[Recorder ERROR] File not found!");
420 static void __speech_status_cb(mas_speech_status_e status, void *user_data)
422 MAS_LOGD("[SUCCESS] __speech_status_cb is called, status(%d)", status);
425 static void __error_cb(int error, const char* err_msg, void* user_data)
427 MAS_LOGE("[SUCCESS] __error_cb is called, error(%d), err_msg(%s)", error, err_msg);
429 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
430 if (nullptr == plugin) return;
432 CServiceIpcDbus* service_ipc = plugin->get_service_ipc();
433 if (plugin->is_ui_panel_enabled() && service_ipc) {
434 int ret = service_ipc->masc_ui_dbus_send_error_message(error, err_msg);
436 MAS_LOGE("[ERROR] Fail to send error message, ret(%d)", ret);
441 static void __setting_changed_cb(void *user_data)
443 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
444 if (nullptr == plugin) return;
446 CServiceMain* service_main = plugin->get_service_main();
448 service_main->prelaunch_default_assistant();
449 service_main->update_voice_key_support_mode();
451 MAS_LOGD("[SUCCESS] __setting_changed_cb is called");
454 static void __streaming_section_changed_cb(ma_audio_streaming_data_section_e section, void* user_data)
456 MAS_LOGI("[SUCCESS] __streaming_section_changed_cb is called, section(%d)", section);
458 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
459 if (nullptr == plugin) return;
461 CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
462 CServiceMain* service_main = plugin->get_service_main();
463 if (service_ipc && service_main) {
464 pid_t pid = service_main->get_current_client_pid();
465 int ret = service_ipc->send_streaming_section_changed(pid, (int)section);
467 MAS_LOGE("[ERROR] Fail to send streaming section changed information, ret(%d)", ret);
472 static void __wakeup_engine_command_cb(mas_wakeup_engine_command_target_e target, const char* assistant_name, const char* command, void* user_data)
474 MAS_LOGD("[SUCCESS] __wakeup_engine_command_cb is called, command(%s)", command);
476 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
477 if (nullptr == plugin) return;
479 CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
480 CServiceMain* service_main = plugin->get_service_main();
481 if (service_ipc && service_main) {
482 pid_t pid = service_main->get_client_pid_by_appid(assistant_name);
484 int ret = service_ipc->send_wakeup_engine_command(pid, command);
486 MAS_LOGE("[ERROR] Fail to send wakeup engine command, ret(%d)", ret);
492 static void __wakeup_service_state_changed_cb(ma_service_state_e state, void* user_data)
494 MAS_LOGD("[SUCCESS] __wakeup_service_state_changed_cb is called, state(%d)", state);
496 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
497 if (nullptr == plugin) return;
499 CServiceMain* service_main = plugin->get_service_main();
501 service_main->set_current_service_state(state);
505 static void __wakeup_service_voice_key_status_changed_cb(ma_voice_key_status_e status, void* user_data)
507 MAS_LOGD("[SUCCESS] __wakeup_service_voice_key_status_changed_cb is called, state(%d)", status);
509 CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
510 if (nullptr == plugin) return;
512 CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
513 CServiceMain* service_main = plugin->get_service_main();
514 if (service_ipc && service_main) {
515 pid_t pid = service_main->get_current_client_pid();
516 int ret = service_ipc->change_voice_key_status(pid, status);
518 MAS_LOGE("[ERROR] Fail to send voice key status changed information, ret(%d)", ret);
523 int CServicePlugin::initialize(void)
527 char filepath[512] = {'\0', };
528 const char *default_engine_path = MA_WAKEUP_MANAGER_PATH;
529 snprintf(filepath, 512, "%s/%s", default_engine_path, MA_DEFAULT_WAKEUP_MANAGER_FILENAME);
532 mPluginHandle = nullptr;
533 mPluginHandle = dlopen(filepath, RTLD_LAZY);
534 if (nullptr != (error = dlerror())) {
535 MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error);
536 if (mPluginHandle) dlclose(mPluginHandle);
537 mPluginHandle = nullptr;
538 return -1; //MAS_ERROR_OPERATION_FAILED;
540 if (nullptr == mPluginHandle) {
541 MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error);
542 return -1; //MAS_ERROR_OPERATION_FAILED;
545 mWakeupManagerInterface.initialize =
546 (wakeup_manager_initialize)dlsym(mPluginHandle,
547 MA_WAKEUP_MANAGER_FUNC_INITIALIZE);
548 mWakeupManagerInterface.deinitialize =
549 (wakeup_manager_deinitialize)dlsym(mPluginHandle,
550 MA_WAKEUP_MANAGER_FUNC_DEINITIALIZE);
551 mWakeupManagerInterface.get_settings =
552 (wakeup_manager_get_settings)dlsym(mPluginHandle,
553 MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
554 mWakeupManagerInterface.add_assistant_wakeup_word =
555 (wakeup_manager_add_assistant_wakeup_word)dlsym(mPluginHandle,
556 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_WORD);
557 mWakeupManagerInterface.remove_assistant_wakeup_word =
558 (wakeup_manager_remove_assistant_wakeup_word)dlsym(mPluginHandle,
559 MA_WAKEUP_MANAGER_FUNC_REMOVE_ASSISTANT_WAKEUP_WORD);
560 mWakeupManagerInterface.add_assistant_language =
561 (wakeup_manager_add_assistant_language)dlsym(mPluginHandle,
562 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE);
563 mWakeupManagerInterface.set_assistant_wakeup_engine =
564 (wakeup_manager_set_assistant_wakeup_engine)dlsym(mPluginHandle,
565 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_WAKEUP_ENGINE);
566 mWakeupManagerInterface.set_default_assistant =
567 (wakeup_manager_set_default_assistant)dlsym(mPluginHandle,
568 MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT);
569 mWakeupManagerInterface.get_default_assistant =
570 (wakeup_manager_get_default_assistant)dlsym(mPluginHandle,
571 MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT);
572 mWakeupManagerInterface.set_language =
573 (wakeup_manager_set_language)dlsym(mPluginHandle,
574 MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE);
575 mWakeupManagerInterface.activate =
576 (wakeup_manager_activate)dlsym(mPluginHandle,
577 MA_WAKEUP_MANAGER_FUNC_ACTIVATE);
578 mWakeupManagerInterface.deactivate =
579 (wakeup_manager_deactivate)dlsym(mPluginHandle,
580 MA_WAKEUP_MANAGER_FUNC_DEACTIVATE);
581 mWakeupManagerInterface.update_voice_feedback_state =
582 (wakeup_manager_update_voice_feedback_state)dlsym(mPluginHandle,
583 MA_WAKEUP_MANAGER_FUNC_UPDATE_VOICE_FEEDBACK_STATE);
584 mWakeupManagerInterface.set_assistant_specific_command =
585 (wakeup_manager_set_assistant_specific_command)dlsym(mPluginHandle,
586 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_SPECIFIC_COMMAND);
587 mWakeupManagerInterface.set_background_volume =
588 (wakeup_manager_set_background_volume)dlsym(mPluginHandle,
589 MA_WAKEUP_MANAGER_FUNC_SET_BACKGROUND_VOLUME);
590 mWakeupManagerInterface.update_recognition_result =
591 (wakeup_manager_update_recognition_result)dlsym(mPluginHandle,
592 MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
593 mWakeupManagerInterface.process_plugin_event =
594 (wakeup_manager_process_plugin_event)dlsym(mPluginHandle,
595 MA_WAKEUP_MANAGER_FUNC_PROCESS_PLUGIN_EVENT);
596 mWakeupManagerInterface.start_streaming_utterance_data =
597 (wakeup_manager_start_streaming_utterance_data)dlsym(mPluginHandle,
598 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA);
599 mWakeupManagerInterface.stop_streaming_utterance_data =
600 (wakeup_manager_stop_streaming_utterance_data)dlsym(mPluginHandle,
601 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_UTTERANCE_DATA);
602 mWakeupManagerInterface.start_streaming_previous_utterance_data =
603 (wakeup_manager_start_streaming_previous_utterance_data)dlsym(mPluginHandle,
604 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_PREVIOUS_UTTERANCE_DATA);
605 mWakeupManagerInterface.stop_streaming_previous_utterance_data =
606 (wakeup_manager_stop_streaming_previous_utterance_data)dlsym(mPluginHandle,
607 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_PREVIOUS_UTTERANCE_DATA);
608 mWakeupManagerInterface.start_streaming_follow_up_data =
609 (wakeup_manager_start_streaming_follow_up_data)dlsym(mPluginHandle,
610 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_FOLLOW_UP_DATA);
611 mWakeupManagerInterface.stop_streaming_follow_up_data =
612 (wakeup_manager_stop_streaming_follow_up_data)dlsym(mPluginHandle,
613 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_FOLLOW_UP_DATA);
614 mWakeupManagerInterface.get_audio_format =
615 (wakeup_manager_get_audio_format)dlsym(mPluginHandle,
616 MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT);
617 mWakeupManagerInterface.get_audio_source_type =
618 (wakeup_manager_get_audio_source_type)dlsym(mPluginHandle,
619 MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
620 mWakeupManagerInterface.set_wake_word_audio_require_flag =
621 (wakeup_manager_set_wake_word_audio_require_flag)dlsym(mPluginHandle,
622 MA_WAKEUP_MANAGER_FUNC_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG);
623 mWakeupManagerInterface.set_assistant_language =
624 (wakeup_manager_set_assistant_language)dlsym(mPluginHandle,
625 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_LANGUAGE);
626 mWakeupManagerInterface.set_voice_key_tap_duration =
627 (wakeup_manager_set_voice_key_tap_duration)dlsym(mPluginHandle,
628 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_TAP_DURATION);
629 mWakeupManagerInterface.unset_voice_key_tap_duration =
630 (wakeup_manager_unset_voice_key_tap_duration)dlsym(mPluginHandle,
631 MA_WAKEUP_MANAGER_FUNC_UNSET_VOICE_KEY_TAP_DURATION);
632 mWakeupManagerInterface.set_voice_key_support_mode =
633 (wakeup_manager_set_voice_key_support_mode)dlsym(mPluginHandle,
634 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_SUPPORT_MODE);
635 mWakeupManagerInterface.set_wakeup_event_callback =
636 (wakeup_manager_set_wakeup_event_callback)dlsym(mPluginHandle,
637 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
638 mWakeupManagerInterface.set_utterance_streaming_callback =
639 (wakeup_manager_set_utterance_streaming_callback)dlsym(mPluginHandle,
640 MA_WAKEUP_MANAGER_FUNC_SET_UTTERANCE_STREAMING_CALLBACK);
641 mWakeupManagerInterface.set_previous_utterance_streaming_callback =
642 (wakeup_manager_set_previous_utterance_streaming_callback)dlsym(mPluginHandle,
643 MA_WAKEUP_MANAGER_FUNC_SET_PREVIOUS_UTTERANCE_STREAMING_CALLBACK);
644 mWakeupManagerInterface.set_follow_up_streaming_callback =
645 (wakeup_manager_set_follow_up_streaming_callback)dlsym(mPluginHandle,
646 MA_WAKEUP_MANAGER_FUNC_SET_FOLLOW_UP_STREAMING_CALLBACK);
647 mWakeupManagerInterface.set_speech_status_callback =
648 (wakeup_manager_set_speech_status_callback)dlsym(mPluginHandle,
649 MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK);
650 mWakeupManagerInterface.set_setting_changed_callback =
651 (wakeup_manager_set_setting_changed_callback)dlsym(mPluginHandle,
652 MA_WAKEUP_MANAGER_FUNC_SET_SETTING_CHANGED_CALLBACK);
653 mWakeupManagerInterface.set_error_callback =
654 (wakeup_manager_set_error_callback)dlsym(mPluginHandle,
655 MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK);
656 mWakeupManagerInterface.set_streaming_section_changed_callback =
657 (wakeup_manager_set_streaming_section_changed_callback)dlsym(mPluginHandle,
658 MA_WAKEUP_MANAGER_FUNC_SET_STREAMING_SECTION_CHANGED_CALLBACK);
659 mWakeupManagerInterface.set_wakeup_engine_command_callback =
660 (wakeup_manager_set_wakeup_engine_command_callback)dlsym(mPluginHandle,
661 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_ENGINE_COMMAND_CALLBACK);
662 mWakeupManagerInterface.set_wakeup_service_state_changed_callback =
663 (wakeup_manager_set_wakeup_service_state_changed_callback)dlsym(mPluginHandle,
664 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_SERVICE_STATE_CHANGED_CALLBACK);
665 mWakeupManagerInterface.set_voice_key_status_changed_callback =
666 (wakeup_manager_set_voice_key_status_changed_callback)dlsym(mPluginHandle,
667 MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_STATUS_CHANGED_CALLBACK);
670 if (NULL != mPluginHandle) {
671 wakeup_manager_initialize func = mWakeupManagerInterface.initialize;
674 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_INITIALIZE);
678 MAS_LOGE("[ERROR] Fail to initialize, ret(%d)", ret);
682 wakeup_manager_get_settings get_settings_func = mWakeupManagerInterface.get_settings;
684 if (NULL == get_settings_func) {
685 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
688 ret = get_settings_func(&mPluginSettings, &struct_size);
689 if (0 != ret || struct_size != sizeof(ma_plugin_settings)) {
690 MAS_LOGE("[ERROR] Fail to get settings, ret(%d), size %zu", ret, struct_size);
691 mPluginSettings = NULL;
695 MAS_LOGE("[ERROR] mPluginHandle is not valid");
700 int CServicePlugin::deinitialize(void)
707 MAS_LOGD("[Recorder ERROR] File not found!");
712 if (NULL != mPluginHandle) {
713 wakeup_manager_deinitialize func = mWakeupManagerInterface.deinitialize;
715 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_DEINITIALIZE);
719 MAS_LOGE("[ERROR] Fail to deinitialize, ret(%d)", ret);
723 dlclose(mPluginHandle);
724 mPluginHandle = NULL;
726 MAS_LOGE("[ERROR] mPluginHandle is not valid");
732 int CServicePlugin::get_settings(ma_plugin_settings **settings, size_t *struct_size)
735 if (NULL != mPluginHandle) {
736 wakeup_manager_get_settings func = mWakeupManagerInterface.get_settings;
738 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
740 ret = func(settings, struct_size);
742 MAS_LOGE("[ERROR] Fail to get settings, ret(%d)", ret);
746 MAS_LOGE("[ERROR] mPluginHandle is not valid");
751 int CServicePlugin::set_language(const char* language)
754 if (NULL != mPluginHandle) {
755 wakeup_manager_set_language func = mWakeupManagerInterface.set_language;
757 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE);
759 ret = func(language);
761 MAS_LOGE("[ERROR] Fail to set langauge(%s), ret(%d)", language, ret);
765 MAS_LOGE("[ERROR] mPluginHandle is not valid");
770 int CServicePlugin::add_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
773 if (NULL != mPluginHandle) {
774 wakeup_manager_add_assistant_wakeup_word func = mWakeupManagerInterface.add_assistant_wakeup_word;
776 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_WORD);
778 ret = func(appid, wakeup_word, language);
780 MAS_LOGE("[ERROR] Fail to add wakeup word(%s)(%s)(%s), ret(%d)", appid, wakeup_word, language, ret);
784 MAS_LOGE("[ERROR] mPluginHandle is not valid");
789 int CServicePlugin::remove_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
792 if (NULL != mPluginHandle) {
793 wakeup_manager_remove_assistant_wakeup_word func = mWakeupManagerInterface.remove_assistant_wakeup_word;
795 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_REMOVE_ASSISTANT_WAKEUP_WORD);
797 ret = func(appid, wakeup_word, language);
799 MAS_LOGE("[ERROR] Fail to remove wakeup word(%s)(%s)(%s), ret(%d)", appid, wakeup_word, language, ret);
803 MAS_LOGE("[ERROR] mPluginHandle is not valid");
808 int CServicePlugin::add_assistant_language(const char* appid, const char* language)
811 if (NULL != mPluginHandle) {
812 wakeup_manager_add_assistant_language func = mWakeupManagerInterface.add_assistant_language;
814 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE);
816 ret = func(appid, language);
818 MAS_LOGE("[ERROR] Fail to set wakeup word(%s)(%s), ret(%d)", appid, language, ret);
822 MAS_LOGE("[ERROR] mPluginHandle is not valid");
827 int CServicePlugin::set_assistant_wakeup_engine(const char* appid, const char* engine)
830 if (NULL != mPluginHandle) {
831 wakeup_manager_set_assistant_wakeup_engine func = mWakeupManagerInterface.set_assistant_wakeup_engine;
833 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_WAKEUP_ENGINE);
835 ret = func(appid, engine);
837 MAS_LOGE("[ERROR] Fail to set wakeup engine(%s)(%s), ret(%d)", appid, engine, ret);
841 MAS_LOGE("[ERROR] mPluginHandle is not valid");
846 int CServicePlugin::set_default_assistant(const char* appid)
849 if (NULL != mPluginHandle) {
850 wakeup_manager_set_default_assistant func = mWakeupManagerInterface.set_default_assistant;
852 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT);
856 MAS_LOGE("[ERROR] Fail to set default assistant(%s), ret(%d)", appid, ret);
860 MAS_LOGE("[ERROR] mPluginHandle is not valid");
865 int CServicePlugin::get_default_assistant(const char** appid)
869 MAS_LOGE("[ERROR] appid is not valid");
872 if (NULL != mPluginHandle) {
873 wakeup_manager_get_default_assistant func = mWakeupManagerInterface.get_default_assistant;
875 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT);
879 MAS_LOGE("[ERROR] Fail to get default assistant, ret(%d)", ret);
883 MAS_LOGE("[ERROR] mPluginHandle is not valid");
888 int CServicePlugin::activate(void)
891 if (NULL != mPluginHandle) {
892 wakeup_manager_activate func = mWakeupManagerInterface.activate;
894 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ACTIVATE);
898 MAS_LOGE("[ERROR] Fail to start recording, ret(%d)", ret);
902 MAS_LOGE("[ERROR] mPluginHandle is not valid");
907 int CServicePlugin::deactivate(void)
910 if (NULL != mPluginHandle) {
911 wakeup_manager_deactivate func = mWakeupManagerInterface.deactivate;
913 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_DEACTIVATE);
917 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
921 MAS_LOGE("[ERROR] mPluginHandle is not valid");
926 int CServicePlugin::update_voice_feedback_state(const char* appid, int state)
929 if (NULL != mPluginHandle) {
930 wakeup_manager_update_voice_feedback_state func = mWakeupManagerInterface.update_voice_feedback_state;
932 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_VOICE_FEEDBACK_STATE);
934 ret = func(appid, state);
936 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
940 MAS_LOGE("[ERROR] mPluginHandle is not valid");
945 int CServicePlugin::set_assistant_specific_command(const char* appid, const char* command)
948 if (NULL != mPluginHandle) {
949 wakeup_manager_set_assistant_specific_command func = mWakeupManagerInterface.set_assistant_specific_command;
951 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_SPECIFIC_COMMAND);
953 ret = func(appid, command);
955 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
959 MAS_LOGE("[ERROR] mPluginHandle is not valid");
964 int CServicePlugin::set_background_volume(const char* appid, double ratio)
967 if (NULL != mPluginHandle) {
968 wakeup_manager_set_background_volume func = mWakeupManagerInterface.set_background_volume;
970 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_BACKGROUND_VOLUME);
972 ret = func(appid, ratio);
974 MAS_LOGE("[ERROR] Fail to set background volume, ret(%d)", ret);
978 MAS_LOGE("[ERROR] mPluginHandle is not valid");
983 int CServicePlugin::update_recognition_result(const char* appid, int state)
986 if (NULL != mPluginHandle) {
987 wakeup_manager_update_recognition_result func = mWakeupManagerInterface.update_recognition_result;
989 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
991 ret = func(appid, state);
993 MAS_LOGE("[ERROR] Fail to update result state, ret(%d)", ret);
997 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1002 int CServicePlugin::process_event(int event, void *data, int len)
1005 if (NULL != mPluginHandle) {
1006 wakeup_manager_process_plugin_event func = mWakeupManagerInterface.process_plugin_event;
1008 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_PROCESS_PLUGIN_EVENT);
1010 ret = func((mas_plugin_event_e)event, data, len);
1012 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
1016 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1021 int CServicePlugin::start_streaming_utterance_data(void)
1025 if (NULL != mPluginHandle) {
1026 wakeup_manager_start_streaming_utterance_data func = mWakeupManagerInterface.start_streaming_utterance_data;
1028 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA);
1032 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1036 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1041 int CServicePlugin::stop_streaming_utterance_data(void)
1044 if (NULL != mPluginHandle) {
1045 wakeup_manager_stop_streaming_utterance_data func = mWakeupManagerInterface.stop_streaming_utterance_data;
1047 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_UTTERANCE_DATA);
1051 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1055 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1060 int CServicePlugin::start_streaming_previous_utterance_data(void)
1063 if (NULL != mPluginHandle) {
1064 wakeup_manager_start_streaming_previous_utterance_data func = mWakeupManagerInterface.start_streaming_previous_utterance_data;
1066 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_PREVIOUS_UTTERANCE_DATA);
1070 MAS_LOGE("[ERROR] Fail to request previous speech data, ret(%d)", ret);
1074 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1079 int CServicePlugin::stop_streaming_previous_utterance_data(void)
1082 if (NULL != mPluginHandle) {
1083 wakeup_manager_stop_streaming_previous_utterance_data func = mWakeupManagerInterface.stop_streaming_previous_utterance_data;
1085 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_PREVIOUS_UTTERANCE_DATA);
1089 MAS_LOGE("[ERROR] Fail to request previous speech data, ret(%d)", ret);
1093 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1098 int CServicePlugin::start_streaming_follow_up_data(void)
1101 if (NULL != mPluginHandle) {
1102 wakeup_manager_start_streaming_follow_up_data func = mWakeupManagerInterface.start_streaming_follow_up_data;
1104 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_FOLLOW_UP_DATA);
1108 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1112 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1117 int CServicePlugin::stop_streaming_follow_up_data(void)
1120 if (NULL != mPluginHandle) {
1121 wakeup_manager_stop_streaming_follow_up_data func = mWakeupManagerInterface.stop_streaming_follow_up_data;
1123 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_FOLLOW_UP_DATA);
1127 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
1131 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1136 int CServicePlugin::get_recording_audio_format(int *rate, int *channel, int *audio_type)
1139 if (NULL != mPluginHandle) {
1140 wakeup_manager_get_audio_format func = mWakeupManagerInterface.get_audio_format;
1142 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT);
1144 ret = func(rate, channel, audio_type);
1146 MAS_LOGE("[ERROR] Fail to get recording audio format, ret(%d)", ret);
1150 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1155 int CServicePlugin::get_recording_audio_source_type(char** type)
1158 if (NULL != mPluginHandle) {
1159 wakeup_manager_get_audio_source_type func = mWakeupManagerInterface.get_audio_source_type;
1161 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
1165 MAS_LOGE("[ERROR] Fail to get recording audio source type, ret(%d)", ret);
1169 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1174 int CServicePlugin::set_voice_key_tap_duration(float duration)
1177 if (NULL != mPluginHandle) {
1178 wakeup_manager_set_voice_key_tap_duration func = mWakeupManagerInterface.set_voice_key_tap_duration;
1180 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_TAP_DURATION);
1182 ret = func(duration);
1184 MAS_LOGE("[ERROR] Fail to set voice key tap duration, ret(%d)", ret);
1188 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1193 int CServicePlugin::unset_voice_key_tap_duration()
1196 if (NULL != mPluginHandle) {
1197 wakeup_manager_unset_voice_key_tap_duration func = mWakeupManagerInterface.unset_voice_key_tap_duration;
1199 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UNSET_VOICE_KEY_TAP_DURATION);
1203 MAS_LOGE("[ERROR] Fail to unset voice key tap duration, ret(%d)", ret);
1207 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1212 int CServicePlugin::set_voice_key_support_mode(int mode)
1215 if (NULL != mPluginHandle) {
1216 wakeup_manager_set_voice_key_support_mode func = mWakeupManagerInterface.set_voice_key_support_mode;
1218 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_SUPPORT_MODE);
1222 MAS_LOGE("[ERROR] Fail to set voice key support mode, ret(%d)", ret);
1226 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1231 int CServicePlugin::set_wake_word_audio_require_flag(const char* appid, bool require)
1234 if (NULL != mPluginHandle) {
1235 wakeup_manager_set_wake_word_audio_require_flag func = mWakeupManagerInterface.set_wake_word_audio_require_flag;
1237 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG);
1239 ret = func(require);
1241 MAS_LOGE("[ERROR] Fail to set wake word audio require flag, ret(%d)", ret);
1245 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1250 int CServicePlugin::set_assistant_language(const char* appid, const char* language)
1253 if (NULL != mPluginHandle) {
1254 wakeup_manager_set_assistant_language func = mWakeupManagerInterface.set_assistant_language;
1256 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_LANGUAGE);
1258 ret = func(appid, language);
1260 MAS_LOGE("[ERROR] Fail to set assistant language, ret(%d)", ret);
1264 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1269 int CServicePlugin::set_callbacks(void)
1271 int ret = set_wakeup_event_callback(__wakeup_event_cb, this);
1273 MAS_LOGE("Fail to set wakeup event cb");
1277 ret = set_utterance_streaming_callback(__audio_streaming_cb, this);
1279 MAS_LOGE("Fail to set utterance streaming cb");
1283 ret = set_previous_utterance_streaming_callback(__audio_streaming_cb, this);
1285 MAS_LOGE("Fail to set previous utterance streaming cb");
1289 ret = set_follow_up_streaming_callback(__audio_streaming_cb, this);
1291 MAS_LOGE("Fail to set follow-up streaming cb");
1295 ret = set_speech_status_callback(__speech_status_cb, this);
1297 MAS_LOGE("Fail to set speech status changed cb");
1301 ret = set_setting_changed_callback(__setting_changed_cb, this);
1303 MAS_LOGE("Fail to set setting changed cb");
1307 ret = set_error_callback(__error_cb, this);
1309 MAS_LOGE("Fail to set error cb");
1313 ret = set_streaming_section_changed_callback(__streaming_section_changed_cb, this);
1315 MAS_LOGE("Fail to set streaming section changed cb");
1319 ret = set_wakeup_engine_command_callback(__wakeup_engine_command_cb, this);
1321 MAS_LOGE("Fail to set wakeup engine command cb");
1325 ret = set_wakeup_service_state_changed_callback(__wakeup_service_state_changed_cb, this);
1327 MAS_LOGE("Fail to set wakeup engine command cb");
1331 ret = set_voice_key_status_changed_callback(__wakeup_service_voice_key_status_changed_cb, this);
1333 MAS_LOGE("Fail to set wakeup engine command cb");
1340 int CServicePlugin::set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data)
1343 if (NULL != mPluginHandle) {
1344 wakeup_manager_set_wakeup_event_callback func = mWakeupManagerInterface.set_wakeup_event_callback;
1346 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
1348 ret = func(callback, user_data);
1350 MAS_LOGE("[ERROR] Fail to set wakeup event callback, ret(%d)", ret);
1354 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1359 int CServicePlugin::set_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1362 if (NULL != mPluginHandle) {
1363 wakeup_manager_set_utterance_streaming_callback func = mWakeupManagerInterface.set_utterance_streaming_callback;
1365 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_UTTERANCE_STREAMING_CALLBACK);
1367 ret = func(callback, user_data);
1369 MAS_LOGE("[ERROR] Fail to set utterance streaming callback, ret(%d)", ret);
1373 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1378 int CServicePlugin::set_previous_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1381 if (NULL != mPluginHandle) {
1382 wakeup_manager_set_previous_utterance_streaming_callback func = mWakeupManagerInterface.set_previous_utterance_streaming_callback;
1384 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_PREVIOUS_UTTERANCE_STREAMING_CALLBACK);
1386 ret = func(callback, user_data);
1388 MAS_LOGE("[ERROR] Fail to set utterance streaming callback, ret(%d)", ret);
1392 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1397 int CServicePlugin::set_follow_up_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1400 if (NULL != mPluginHandle) {
1401 wakeup_manager_set_follow_up_streaming_callback func = mWakeupManagerInterface.set_follow_up_streaming_callback;
1403 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_FOLLOW_UP_STREAMING_CALLBACK);
1405 ret = func(callback, user_data);
1407 MAS_LOGE("[ERROR] Fail to set follow-up streaming callback, ret(%d)", ret);
1411 MAS_LOGE("[ERROR] mPluginHandle is not valid");
1416 int CServicePlugin::set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data)
1419 if (NULL != mPluginHandle) {
1420 wakeup_manager_set_speech_status_callback func = mWakeupManagerInterface.set_speech_status_callback;
1422 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK);
1424 ret = func(callback, user_data);
1426 MAS_LOGE("[ERROR] Fail to set speech status callback, ret(%d)", ret);
1433 int CServicePlugin::set_setting_changed_callback(wakeup_service_setting_changed_cb callback, void* user_data)
1436 if (NULL != mPluginHandle) {
1437 wakeup_manager_set_setting_changed_callback func = mWakeupManagerInterface.set_setting_changed_callback;
1439 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_SETTING_CHANGED_CALLBACK);
1441 ret = func(callback, user_data);
1443 MAS_LOGE("[ERROR] Fail to set setting_changed callback, ret(%d)", ret);
1450 int CServicePlugin::set_error_callback(wakeup_service_error_cb callback, void* user_data)
1453 if (NULL != mPluginHandle) {
1454 wakeup_manager_set_error_callback func = mWakeupManagerInterface.set_error_callback;
1456 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK);
1458 ret = func(callback, user_data);
1460 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1467 int CServicePlugin::set_streaming_section_changed_callback(wakeup_service_streaming_section_changed_cb callback, void* user_data)
1470 if (NULL != mPluginHandle) {
1471 wakeup_manager_set_streaming_section_changed_callback func = mWakeupManagerInterface.set_streaming_section_changed_callback;
1473 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_STREAMING_SECTION_CHANGED_CALLBACK);
1475 ret = func(callback, user_data);
1477 MAS_LOGE("[ERROR] Fail to set streaming section changed callback, ret(%d)", ret);
1484 int CServicePlugin::set_wakeup_engine_command_callback(wakeup_service_wakeup_engine_command_cb callback, void* user_data)
1487 if (NULL != mPluginHandle) {
1488 wakeup_manager_set_wakeup_engine_command_callback func = mWakeupManagerInterface.set_wakeup_engine_command_callback;
1490 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_ENGINE_COMMAND_CALLBACK);
1492 ret = func(callback, user_data);
1494 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1501 int CServicePlugin::set_wakeup_service_state_changed_callback(wakeup_service_wakeup_service_state_changed_cb callback, void* user_data)
1504 if (NULL != mPluginHandle) {
1505 wakeup_manager_set_wakeup_service_state_changed_callback func = mWakeupManagerInterface.set_wakeup_service_state_changed_callback;
1507 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_SERVICE_STATE_CHANGED_CALLBACK);
1509 ret = func(callback, user_data);
1511 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1518 int CServicePlugin::set_voice_key_status_changed_callback(wakeup_service_voice_key_status_changed_cb callback, void* user_data)
1521 if (NULL != mPluginHandle) {
1522 wakeup_manager_set_voice_key_status_changed_callback func = mWakeupManagerInterface.set_voice_key_status_changed_callback;
1524 MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_VOICE_KEY_STATUS_CHANGED_CALLBACK);
1526 ret = func(callback, user_data);
1528 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);