Deactivate wakeup engines with no activated assistant
[platform/core/uifw/multi-assistant-service.git] / src / multi_assistant_service_plugin.c
1 /*
2  * Copyright 2018  Samsung Electronics Co., Ltd
3  *
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
7  *
8  * http://floralicense.org/license/
9  *
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.
15  */
16
17 #include <tizen.h>
18 #include <service_app.h>
19 #include <app_manager.h>
20 #include <app.h>
21 #include <malloc.h>
22 #include <Ecore.h>
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <glib.h>
28 #include <dlfcn.h>
29
30 #include "multi_wakeup_recognizer.h"
31 #include "multi_assistant_main.h"
32 #include "multi_assistant_service.h"
33 #include "multi_assistant_service_plugin.h"
34 #include "multi_assistant_dbus.h"
35 #include "multi_assistant_common.h"
36
37 /* Sound buf save for test */
38 #if 0
39 #define BUF_SAVE_MODE
40 #endif
41
42 #ifdef BUF_SAVE_MODE
43 static char g_temp_file_name[128] = {'\0',};
44
45 static FILE* g_pFile = NULL;
46
47 static int g_count = 1;
48 #endif
49
50 static void *g_handle = NULL;
51
52 static wakeup_manager_interface _wakeup_manager_interface = { NULL, };
53 static ma_plugin_settings* g_plugin_settings = NULL;
54
55 static bool is_ui_panel_enabled()
56 {
57         /* By default we assume the ui panel is always enabled unless explicitly turned off */
58         bool ret = true;
59         if (g_plugin_settings) {
60                 ret = g_plugin_settings->ui_panel_enabled;
61         }
62         MAS_LOGD("UI Panel Enabled : %d", ret);
63         return ret;
64 }
65
66 #if 0 /* + TEST_CODE */
67 Eina_Bool __send_asr_result(void *data)
68 {
69         MAS_LOGD("[ENTER]");
70
71         if (!strcmp((char*)data, "Today's")) {
72                 masc_ui_dbus_send_asr_result(-1, 1, "Today's");
73         }
74         if (!strcmp((char*)data, "weather.")) {
75                 masc_ui_dbus_send_asr_result(-1, 0, "Today's weather.");
76         }
77
78         MAS_LOGD("END");
79         return EINA_FALSE;
80 }
81
82 Eina_Bool __send_result(void *data)
83 {
84         MAS_LOGD("[ENTER]");
85
86         int ret = masc_ui_dbus_send_result(-1, (const char*)data, (const char*)data, "test");
87         if (0 != ret) {
88                 MAS_LOGE("[ERROR] Fail to stop recording(%d)", ret);
89                 return EINA_TRUE;
90         }
91
92         MAS_LOGD("END");
93         return EINA_FALSE;
94 }
95 #endif /* -TEST_CODE */
96
97 Eina_Bool process_wakeup_event_by_appid_timer(char* appid)
98 {
99         MAS_LOGD("[ENTER] appid(%s)", appid);
100
101         int pid = -1;
102         if (!appid) return ECORE_CALLBACK_CANCEL;
103
104         bool use_custom_ui = mas_get_client_custom_ui_option_by_appid(appid);
105         bool ui_panel_enabled = is_ui_panel_enabled();
106         if (ui_panel_enabled) masc_ui_dbus_enable_common_ui(!use_custom_ui);
107
108         mas_set_current_client_by_appid(appid);
109         if (ui_panel_enabled) masc_ui_dbus_change_assistant(appid);
110         if ((pid = mas_get_client_pid_by_appid(appid)) != -1) {
111                 mas_client_send_preprocessing_information(pid);
112                 mas_client_activate(pid);
113         } else {
114                 // Appropriate MA Client not available, trying to launch new one
115                 MAS_LOGD("MA Client with appid %s does not exist, launching client", appid);
116                 mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);
117         }
118         mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_WAKEUP);
119
120         if (appid) free(appid);
121
122         MAS_LOGD("END");
123         return ECORE_CALLBACK_CANCEL;
124 }
125
126 Eina_Bool process_wakeup_event_by_word_timer(char* wakeup_word)
127 {
128         MAS_LOGD("[ENTER]");
129
130         if (!wakeup_word) return EINA_FALSE;
131
132         const char* appid = mas_get_client_appid_by_wakeup_word(wakeup_word);
133         process_wakeup_event_by_appid_timer(strdup(appid));
134
135         if (wakeup_word) free(wakeup_word);
136
137         MAS_LOGD("END");
138         return ECORE_CALLBACK_CANCEL;
139 }
140
141 static void __wakeup_event_cb(wakeup_event_info wakeup_info, void* user_data)
142 {
143         MAS_LOGD("[SUCCESS] __wakeup_event_cb is called, wakeup_word(%s)", wakeup_info.wakeup_word);
144         int ret = -1;
145
146         if (is_ui_panel_enabled()) {
147                 int retry_cnt = 0;
148                 while (0 != ret) {
149                         ret = masc_ui_dbus_send_hello();
150                         retry_cnt++;
151                         if (5 < retry_cnt) {
152                                 MAS_LOGE("[ERROR] Fail to receive reply for hello, ret(%d)", ret);
153                                 break;
154                         }
155                 }
156         }
157
158 #ifdef BUF_SAVE_MODE
159         if (g_pFile) {
160                 fclose(g_pFile);
161                 g_pFile = NULL;
162         } else {
163                 MAS_LOGD("[Recorder Info] File not found!");
164         }
165
166         while (1) {
167                 snprintf(g_temp_file_name, sizeof(g_temp_file_name), "/tmp/ma_service_%d_%d", getpid(), g_count);
168                 int ret = access(g_temp_file_name, 0);
169
170                 if (0 == ret) {
171                         MAS_LOGD("[Recorder ERROR] File is already exist");
172                         if (0 == remove(g_temp_file_name)) {
173                                 MAS_LOGD("[Recorder] Remove file");
174                                 break;
175                         } else {
176                                 g_count++;
177                         }
178                 } else {
179                         break;
180                 }
181         }
182
183         MAS_LOGD("[Recorder] Temp file name=[%s]", g_temp_file_name);
184
185         /* open test file */
186         g_pFile = fopen(g_temp_file_name, "wb+x");
187         if (!g_pFile) {
188                 MAS_LOGD("[Recorder ERROR] File not found!");
189                 return;
190         }
191         g_count++;
192 #endif
193
194 #if 0 /* + TEST_CODE */
195         if (WAKEUP_EVENT_SUCCESS == event) {
196                 ecore_thread_main_loop_begin();
197                 ecore_timer_add(1.0, __send_asr_result, "Today's");
198                 ecore_thread_main_loop_end();
199
200                 ecore_thread_main_loop_begin();
201                 ecore_timer_add(2.0, __send_asr_result, "weather.");
202                 ecore_thread_main_loop_end();
203
204                 ecore_thread_main_loop_begin();
205                 ecore_timer_add(3.0, __send_result, "Partly cloudy with temperatures from 75 to 88");
206                 ecore_thread_main_loop_end();
207         }
208 #endif /* - TEST_CODE */
209         if (wakeup_info.wakeup_appid) {
210                 ecore_thread_main_loop_begin();
211                 ecore_timer_add(0.0f, process_wakeup_event_by_appid_timer, (void*)strdup(wakeup_info.wakeup_appid));
212                 ecore_thread_main_loop_end();
213         } else if (wakeup_info.wakeup_word) {
214                 ecore_thread_main_loop_begin();
215                 ecore_timer_add(0.0f, process_wakeup_event_by_word_timer, (void*)strdup(wakeup_info.wakeup_word));
216                 ecore_thread_main_loop_end();
217         }
218
219 }
220
221 static bool __validate_streaming_event_order(int pid, wakeup_speech_streaming_event_e *event)
222 {
223         bool ret = false;
224
225         static int previous_pid = -1;
226         static wakeup_speech_streaming_event_e previous_event = WAKEUP_SPEECH_STREAMING_EVENT_FINISH;
227
228         if (NULL == event) return false;
229
230         wakeup_speech_streaming_event_e expected_sequence [][2] = {
231                 {WAKEUP_SPEECH_STREAMING_EVENT_START, WAKEUP_SPEECH_STREAMING_EVENT_CONTINUE},
232                 {WAKEUP_SPEECH_STREAMING_EVENT_START, WAKEUP_SPEECH_STREAMING_EVENT_FINISH},
233                 {WAKEUP_SPEECH_STREAMING_EVENT_CONTINUE, WAKEUP_SPEECH_STREAMING_EVENT_CONTINUE},
234                 {WAKEUP_SPEECH_STREAMING_EVENT_CONTINUE, WAKEUP_SPEECH_STREAMING_EVENT_FINISH},
235                 {WAKEUP_SPEECH_STREAMING_EVENT_FINISH, WAKEUP_SPEECH_STREAMING_EVENT_START},
236         };
237
238         if (pid != previous_pid) {
239                 /* When sending streaming event to a new client, it always sends START message first */
240                 previous_event = WAKEUP_SPEECH_STREAMING_EVENT_FINISH;
241         }
242
243         for (int loop = 0;loop < sizeof(expected_sequence) / sizeof(expected_sequence[0]);loop++) {
244                 if (previous_event == expected_sequence[loop][0] &&
245                         *event == expected_sequence[loop][1]) {
246                         ret = true;
247                 }
248         }
249         if (!ret) {
250                 /* In case of FINISH -> CONTINUE without START, simply modify current event value */
251                 if (WAKEUP_SPEECH_STREAMING_EVENT_FINISH == previous_event &&
252                         WAKEUP_SPEECH_STREAMING_EVENT_CONTINUE == *event) {
253                         *event = WAKEUP_SPEECH_STREAMING_EVENT_START;
254                         ret = true;
255
256                         MAS_LOGD("[WARNING] forcibly changed CONTINUE to START : %d -> %d (PID %d -> %d)",
257                                 previous_event, *event, previous_pid, pid);
258                 }
259         }
260
261         if (ret) {
262                 previous_pid = pid;
263                 previous_event = *event;
264         } else {
265                 MAS_LOGE("[ERROR] State sequence validation failed : %d -> %d (PID %d -> %d)",
266                         previous_event, *event, previous_pid, pid);
267         }
268         return ret;
269 }
270
271 static void handle_speech_streaming_event_failure(void *data)
272 {
273         mas_client_send_recognition_result(0, MA_RECOGNITION_RESULT_EVENT_ERROR);
274 }
275
276 static void __audio_streaming_cb(wakeup_speech_streaming_event_e event, unsigned char* buffer, int len, void *user_data)
277 {
278         if (event == WAKEUP_SPEECH_STREAMING_EVENT_FAIL) {
279                 ecore_main_loop_thread_safe_call_async(handle_speech_streaming_event_failure, NULL);
280                 return;
281         }
282         static int count = 0;
283         if (event != WAKEUP_SPEECH_STREAMING_EVENT_CONTINUE || count % 100 == 0) {
284                 MAS_LOGD( "[SUCCESS] __audio_streaming_cb is called, event(%d), buffer(%p), len(%d)", event, buffer, len);
285         }
286         ++count;
287
288         int pid = mas_get_current_client_pid();
289         int preprocessing_pid = mas_get_current_preprocessing_client_pid();
290         if (pid == -1) {
291                 MAS_LOGE("[ERROR] Fail to retrieve pid of current MA client");
292         } else {
293                 if (__validate_streaming_event_order(pid, &event)) {
294                         int ret = masc_dbus_send_streaming_audio_data(pid, event, buffer, len);
295                         if (0 != ret) {
296                                 MAS_LOGE("[ERROR] Fail to send speech data, ret(%d)", ret);
297                         }
298                         if (pid != preprocessing_pid && -1 != preprocessing_pid) {
299                                 int ret = masc_dbus_send_streaming_audio_data(preprocessing_pid, event, buffer, len);
300                                 if (0 != ret) {
301                                         MAS_LOGE("[ERROR] Fail to send speech data to preprocessing client, ret(%d)", ret);
302                                 }
303                         }
304                 }
305         }
306
307 #ifdef BUF_SAVE_MODE
308         /* write pcm buffer */
309         if (g_pFile)
310                 fwrite(buffer, 1, len, g_pFile);
311
312         if (WAKEUP_SPEECH_STREAMING_EVENT_FINISH == event) {
313                 if (g_pFile) {
314                         MAS_LOGE("[Recorder SUCCESS] File Close");
315                         fclose(g_pFile);
316                         g_pFile = NULL;
317                 } else {
318                         MAS_LOGE("[Recorder ERROR] File not found!");
319                 }
320         }
321 #endif
322 }
323
324 static void __speech_status_cb(wakeup_speech_status_e status, void *user_data)
325 {
326         MAS_LOGD( "[SUCCESS] __speech_status_cb is called, status(%d)", status);
327 }
328
329 static void __error_cb(int error, const char* err_msg, void* user_data)
330 {
331         MAS_LOGD( "[SUCCESS] __error_cb is called, error(%d), err_msg(%s)", error, err_msg);
332
333         if (is_ui_panel_enabled()) {
334                 int ret = masc_ui_dbus_send_error_message(error, err_msg);
335                 if (0 != ret) {
336                         MAS_LOGE("[ERROR] Fail to send error message, ret(%d)", ret);
337                 }
338         }
339 }
340
341 static void __streaming_section_changed_cb(ma_audio_streaming_data_section_e section, void* user_data)
342 {
343         MAS_LOGD( "[SUCCESS] __streaming_section_changed_cb is called, section(%d)", section);
344
345         int pid = mas_get_current_client_pid();
346         int ret = masc_dbus_send_streaming_section_changed(pid, (int)section);
347         if (0 != ret) {
348                 MAS_LOGE("[ERROR] Fail to send streaming section changed information, ret(%d)", ret);
349         }
350 }
351
352 int multi_assistant_service_plugin_initialize(void)
353 {
354         MAS_LOGD( "[Enter]");
355
356         char filepath[512] = {'\0',};
357         const char *default_engine_path = MA_WAKEUP_MANAGER_PATH;
358         snprintf(filepath, 512, "%s/%s", default_engine_path, MA_DEFAULT_WAKEUP_MANAGER_FILENAME);
359
360         char *error;
361         g_handle = NULL;
362         g_handle = dlopen(filepath, RTLD_LAZY);
363         if (NULL != (error = dlerror())) {
364                 MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error);
365                 return -1; //MAS_ERROR_OPERATION_FAILED;
366         }
367
368         _wakeup_manager_interface.initialize =
369                 (wakeup_manager_initialize)dlsym(g_handle,
370                 MA_WAKEUP_MANAGER_FUNC_INITIALIZE);
371         _wakeup_manager_interface.deinitialize =
372                 (wakeup_manager_deinitialize)dlsym(g_handle,
373                 MA_WAKEUP_MANAGER_FUNC_DEINITIALIZE);
374         _wakeup_manager_interface.get_settings =
375                 (wakeup_manager_get_settings)dlsym(g_handle,
376                 MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
377         _wakeup_manager_interface.add_assistant_wakeup_word =
378                 (wakeup_manager_add_assistant_wakeup_word)dlsym(g_handle,
379                 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_WORD);
380         _wakeup_manager_interface.add_assistant_language =
381                 (wakeup_manager_add_assistant_language)dlsym(g_handle,
382                 MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE);
383         _wakeup_manager_interface.set_assistant_wakeup_engine =
384                 (wakeup_manager_set_assistant_wakeup_engine)dlsym(g_handle,
385                 MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_WAKEUP_ENGINE);
386         _wakeup_manager_interface.set_default_assistant =
387                 (wakeup_manager_set_default_assistant)dlsym(g_handle,
388                 MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT);
389         _wakeup_manager_interface.get_default_assistant =
390                 (wakeup_manager_get_default_assistant)dlsym(g_handle,
391                 MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT);
392         _wakeup_manager_interface.set_language =
393                 (wakeup_manager_set_language)dlsym(g_handle,
394                 MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE);
395         _wakeup_manager_interface.activate =
396                 (wakeup_manager_activate)dlsym(g_handle,
397                 MA_WAKEUP_MANAGER_FUNC_ACTIVATE);
398         _wakeup_manager_interface.deactivate =
399                 (wakeup_manager_deactivate)dlsym(g_handle,
400                 MA_WAKEUP_MANAGER_FUNC_DEACTIVATE);
401         _wakeup_manager_interface.update_voice_feedback_state =
402                 (wakeup_manager_update_voice_feedback_state)dlsym(g_handle,
403                 MA_WAKEUP_MANAGER_FUNC_UPDATE_VOICE_FEEDBACK_STATE);
404         _wakeup_manager_interface.send_assistant_specific_command =
405                 (wakeup_manager_send_assistant_specific_command)dlsym(g_handle,
406                 MA_WAKEUP_MANAGER_FUNC_SEND_ASSISTANT_SPECIFIC_COMMAND);
407         _wakeup_manager_interface.set_background_volume =
408                 (wakeup_manager_set_background_volume)dlsym(g_handle,
409                 MA_WAKEUP_MANAGER_FUNC_SET_BACKGROUND_VOLUME);
410         _wakeup_manager_interface.update_recognition_result =
411                 (wakeup_manager_update_recognition_result)dlsym(g_handle,
412                 MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
413         _wakeup_manager_interface.process_event =
414                 (wakeup_manager_process_event)dlsym(g_handle,
415                 MA_WAKEUP_MANAGER_FUNC_PROCESS_EVENT);
416         _wakeup_manager_interface.start_streaming_utterance_data =
417                 (wakeup_manager_start_streaming_utterance_data)dlsym(g_handle,
418                 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA);
419         _wakeup_manager_interface.stop_streaming_utterance_data =
420                 (wakeup_manager_stop_streaming_utterance_data)dlsym(g_handle,
421                 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_UTTERANCE_DATA);
422         _wakeup_manager_interface.start_streaming_previous_utterance_data =
423                 (wakeup_manager_start_streaming_previous_utterance_data)dlsym(g_handle,
424                 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_PREVIOUS_UTTERANCE_DATA);
425         _wakeup_manager_interface.stop_streaming_previous_utterance_data =
426                 (wakeup_manager_stop_streaming_previous_utterance_data)dlsym(g_handle,
427                 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_PREVIOUS_UTTERANCE_DATA);
428         _wakeup_manager_interface.start_streaming_follow_up_data =
429                 (wakeup_manager_start_streaming_follow_up_data)dlsym(g_handle,
430                 MA_WAKEUP_MANAGER_FUNC_START_STREAMING_FOLLOW_UP_DATA);
431         _wakeup_manager_interface.stop_streaming_follow_up_data =
432                 (wakeup_manager_stop_streaming_follow_up_data)dlsym(g_handle,
433                 MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_FOLLOW_UP_DATA);
434         _wakeup_manager_interface.get_audio_format =
435                 (wakeup_manager_get_audio_format)dlsym(g_handle,
436                 MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT);
437         _wakeup_manager_interface.get_audio_source_type =
438                 (wakeup_manager_get_audio_source_type)dlsym(g_handle,
439                 MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
440         _wakeup_manager_interface.set_wake_word_audio_require_flag =
441                 (wakeup_manager_set_wake_word_audio_require_flag)dlsym(g_handle,
442                 MA_WAKEUP_MANAGER_FUNC_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG);
443         _wakeup_manager_interface.set_wakeup_event_callback =
444                 (wakeup_manager_set_wakeup_event_callback)dlsym(g_handle,
445                 MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
446         _wakeup_manager_interface.set_utterance_streaming_callback =
447                 (wakeup_manager_set_utterance_streaming_callback)dlsym(g_handle,
448                 MA_WAKEUP_MANAGER_FUNC_SET_UTTERANCE_STREAMING_CALLBACK);
449         _wakeup_manager_interface.set_previous_utterance_streaming_callback =
450                 (wakeup_manager_set_previous_utterance_streaming_callback)dlsym(g_handle,
451                 MA_WAKEUP_MANAGER_FUNC_SET_PREVIOUS_UTTERANCE_STREAMING_CALLBACK);
452         _wakeup_manager_interface.set_follow_up_streaming_callback =
453                 (wakeup_manager_set_follow_up_streaming_callback)dlsym(g_handle,
454                 MA_WAKEUP_MANAGER_FUNC_SET_FOLLOW_UP_STREAMING_CALLBACK);
455         _wakeup_manager_interface.set_speech_status_callback =
456                 (wakeup_manager_set_speech_status_callback)dlsym(g_handle,
457                 MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK);
458         _wakeup_manager_interface.set_error_callback =
459                 (wakeup_manager_set_error_callback)dlsym(g_handle,
460                 MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK);
461         _wakeup_manager_interface.set_streaming_section_changed_callback =
462                 (wakeup_manager_set_streaming_section_changed_callback)dlsym(g_handle,
463                 MA_WAKEUP_MANAGER_FUNC_SET_STREAMING_SECTION_CHANGED_CALLBACK);
464
465         int ret = -1;
466         if (NULL != g_handle) {
467                 wakeup_manager_initialize func = _wakeup_manager_interface.initialize;
468
469                 if (NULL == func) {
470                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_INITIALIZE);
471                 } else {
472                         ret = func();
473                         if (0 != ret) {
474                                 MAS_LOGE("[ERROR] Fail to initialize, ret(%d)", ret);
475                         }
476                 }
477
478                 wakeup_manager_get_settings get_settings_func = _wakeup_manager_interface.get_settings;
479
480                 if (NULL == get_settings_func) {
481                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
482                 } else {
483                         size_t struct_size;
484                         ret = get_settings_func(&g_plugin_settings, &struct_size);
485                         if (0 != ret || struct_size != sizeof(ma_plugin_settings)) {
486                                 MAS_LOGE("[ERROR] Fail to get settings, ret(%d), size %zu", ret, struct_size);
487                                 g_plugin_settings = NULL;
488                         }
489                 }
490         } else {
491                 MAS_LOGE("[ERROR] g_handle is not valid");
492         }
493         return ret;
494 }
495
496 int multi_assistant_service_plugin_deinitialize(void)
497 {
498 #ifdef BUF_SAVE_MODE
499         if (g_pFile) {
500                 fclose(g_pFile);
501                 g_pFile = NULL;
502         } else {
503                 MAS_LOGD("[Recorder ERROR] File not found!");
504         }
505 #endif
506         int ret = -1;
507         if (NULL != g_handle) {
508                 wakeup_manager_deinitialize func = _wakeup_manager_interface.deinitialize;
509                 if (NULL == func) {
510                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_DEINITIALIZE);
511                 } else {
512                         ret = func();
513                         if (0 != ret) {
514                                 MAS_LOGE("[ERROR] Fail to deinitialize, ret(%d)", ret);
515                         }
516                 }
517
518                 dlclose(g_handle);
519                 g_handle = NULL;
520         } else {
521                 MAS_LOGE("[ERROR] g_handle is not valid");
522         }
523
524         return ret;
525 }
526
527 int multi_assistant_service_plugin_get_settings(ma_plugin_settings **settings, size_t *struct_size)
528 {
529         int ret = -1;
530         if (NULL != g_handle) {
531                 wakeup_manager_get_settings func = _wakeup_manager_interface.get_settings;
532                 if (NULL == func) {
533                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_SETTINGS);
534                 } else {
535                         ret = func(settings, struct_size);
536                         if (0 != ret) {
537                                 MAS_LOGE("[ERROR] Fail to get settings, ret(%d)", ret);
538                         }
539                 }
540         } else {
541                 MAS_LOGE("[ERROR] g_handle is not valid");
542         }
543         return ret;
544 }
545
546 int multi_assistant_service_plugin_set_language(const char* language)
547 {
548         int ret = -1;
549         if (NULL != g_handle) {
550                 wakeup_manager_set_language func = _wakeup_manager_interface.set_language;
551                 if (NULL == func) {
552                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE);
553                 } else {
554                         ret = func(language);
555                         if (0 != ret) {
556                                 MAS_LOGE("[ERROR] Fail to set langauge(%s), ret(%d)", language, ret);
557                         }
558                 }
559         } else {
560                 MAS_LOGE("[ERROR] g_handle is not valid");
561         }
562         return ret;
563 }
564
565 int multi_assistant_service_plugin_add_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
566 {
567         int ret = -1;
568         if (NULL != g_handle) {
569                 wakeup_manager_add_assistant_wakeup_word func = _wakeup_manager_interface.add_assistant_wakeup_word;
570                 if (NULL == func) {
571                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_WORD);
572                 } else {
573                         ret = func(appid, wakeup_word, language);
574                         if (0 != ret) {
575                                 MAS_LOGE("[ERROR] Fail to set wakeup word(%s)(%s)(%s), ret(%d)", appid, wakeup_word, language, ret);
576                         }
577                 }
578         } else {
579                 MAS_LOGE("[ERROR] g_handle is not valid");
580         }
581         return ret;
582 }
583
584 int multi_assistant_service_plugin_add_assistant_language(const char* appid, const char* language)
585 {
586         int ret = -1;
587         if (NULL != g_handle) {
588                 wakeup_manager_add_assistant_language func = _wakeup_manager_interface.add_assistant_language;
589                 if (NULL == func) {
590                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE);
591                 } else {
592                         ret = func(appid, language);
593                         if (0 != ret) {
594                                 MAS_LOGE("[ERROR] Fail to set wakeup word(%s)(%s), ret(%d)", appid, language, ret);
595                         }
596                 }
597         } else {
598                 MAS_LOGE("[ERROR] g_handle is not valid");
599         }
600         return ret;
601 }
602
603 int multi_assistant_service_plugin_set_assistant_wakeup_engine(const char* appid, const char* engine)
604 {
605         int ret = -1;
606         if (NULL != g_handle) {
607                 wakeup_manager_set_assistant_wakeup_engine func = _wakeup_manager_interface.set_assistant_wakeup_engine;
608                 if (NULL == func) {
609                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_WAKEUP_ENGINE);
610                 } else {
611                         ret = func(appid, engine);
612                         if (0 != ret) {
613                                 MAS_LOGE("[ERROR] Fail to set wakeup engine(%s)(%s), ret(%d)", appid, engine, ret);
614                         }
615                 }
616         } else {
617                 MAS_LOGE("[ERROR] g_handle is not valid");
618         }
619         return ret;
620 }
621
622 int multi_assistant_service_plugin_set_default_assistant(const char* appid)
623 {
624         int ret = -1;
625         if (NULL != g_handle) {
626                 wakeup_manager_set_default_assistant func = _wakeup_manager_interface.set_default_assistant;
627                 if (NULL == func) {
628                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT);
629                 } else {
630                         ret = func(appid);
631                         if (0 != ret) {
632                                 MAS_LOGE("[ERROR] Fail to set default assistant(%s), ret(%d)", appid, ret);
633                         }
634                 }
635         } else {
636                 MAS_LOGE("[ERROR] g_handle is not valid");
637         }
638         return ret;
639 }
640
641 int multi_assistant_service_plugin_get_default_assistant(const char** appid)
642 {
643         int ret = -1;
644         if (NULL == appid) {
645                 MAS_LOGE("[ERROR] appid is not valid");
646                 return ret;
647         }
648         if (NULL != g_handle) {
649                 wakeup_manager_get_default_assistant func = _wakeup_manager_interface.get_default_assistant;
650                 if (NULL == func) {
651                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT);
652                 } else {
653                         ret = func(appid);
654                         if (0 != ret) {
655                                 MAS_LOGE("[ERROR] Fail to get default assistant, ret(%d)", ret);
656                         }
657                 }
658         } else {
659                 MAS_LOGE("[ERROR] g_handle is not valid");
660         }
661         return ret;
662 }
663
664 int multi_assistant_service_plugin_activate(void)
665 {
666         int ret = -1;
667         if (NULL != g_handle) {
668                 wakeup_manager_activate func = _wakeup_manager_interface.activate;
669                  if (NULL == func) {
670                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ACTIVATE);
671                 } else {
672                         ret = func();
673                         if (0 != ret) {
674                                 MAS_LOGE("[ERROR] Fail to start recording, ret(%d)", ret);
675                         }
676                 }
677         } else {
678                 MAS_LOGE("[ERROR] g_handle is not valid");
679         }
680         return ret;
681 }
682
683 int multi_assistant_service_plugin_deactivate(void)
684 {
685         int ret = -1;
686         if (NULL != g_handle) {
687                 wakeup_manager_deactivate func = _wakeup_manager_interface.deactivate;
688                  if (NULL == func) {
689                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_DEACTIVATE);
690                 } else {
691                         ret = func();
692                         if (0 != ret) {
693                                 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
694                         }
695                 }
696         } else {
697                 MAS_LOGE("[ERROR] g_handle is not valid");
698         }
699         return ret;
700 }
701
702 int multi_assistant_service_plugin_update_voice_feedback_state(const char* appid, int state)
703 {
704         int ret = -1;
705         if (NULL != g_handle) {
706                 wakeup_manager_update_voice_feedback_state func = _wakeup_manager_interface.update_voice_feedback_state;
707                  if (NULL == func) {
708                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_VOICE_FEEDBACK_STATE);
709                 } else {
710                         ret = func(appid, state);
711                         if (0 != ret) {
712                                 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
713                         }
714                 }
715         } else {
716                 MAS_LOGE("[ERROR] g_handle is not valid");
717         }
718         return ret;
719 }
720
721 int multi_assistant_service_plugin_send_assistant_specific_command(const char* appid, const char* command)
722 {
723         int ret = -1;
724         if (NULL != g_handle) {
725                 wakeup_manager_send_assistant_specific_command func = _wakeup_manager_interface.send_assistant_specific_command;
726                  if (NULL == func) {
727                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SEND_ASSISTANT_SPECIFIC_COMMAND);
728                 } else {
729                         ret = func(appid, command);
730                         if (0 != ret) {
731                                 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
732                         }
733                 }
734         } else {
735                 MAS_LOGE("[ERROR] g_handle is not valid");
736         }
737         return ret;
738 }
739
740 int multi_assistant_service_plugin_set_background_volume(const char* appid, double ratio)
741 {
742         int ret = -1;
743         if (NULL != g_handle) {
744                 wakeup_manager_set_background_volume func = _wakeup_manager_interface.set_background_volume;
745                  if (NULL == func) {
746                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_BACKGROUND_VOLUME);
747                 } else {
748                         ret = func(appid, ratio);
749                         if (0 != ret) {
750                                 MAS_LOGE("[ERROR] Fail to set background volume, ret(%d)", ret);
751                         }
752                 }
753         } else {
754                 MAS_LOGE("[ERROR] g_handle is not valid");
755         }
756         return ret;
757 }
758
759 int multi_assistant_service_plugin_update_recognition_result(const char* appid, int state)
760 {
761         int ret = -1;
762         if (NULL != g_handle) {
763                 wakeup_manager_update_recognition_result func = _wakeup_manager_interface.update_recognition_result;
764                  if (NULL == func) {
765                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
766                 } else {
767                         ret = func(appid, state);
768                         if (0 != ret) {
769                                 MAS_LOGE("[ERROR] Fail to update result state, ret(%d)", ret);
770                         }
771                 }
772         } else {
773                 MAS_LOGE("[ERROR] g_handle is not valid");
774         }
775         return ret;
776 }
777
778 int multi_assistant_service_plugin_process_event(int event, void *data, int len)
779 {
780         int ret = -1;
781         if (NULL != g_handle) {
782                 wakeup_manager_process_event func = _wakeup_manager_interface.process_event;
783                  if (NULL == func) {
784                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_PROCESS_EVENT);
785                 } else {
786                         ret = func(event, data, len);
787                         if (0 != ret) {
788                                 MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret);
789                         }
790                 }
791         } else {
792                 MAS_LOGE("[ERROR] g_handle is not valid");
793         }
794         return ret;
795 }
796
797 int multi_assistant_service_plugin_start_streaming_utterance_data(void)
798 {
799         int ret = -1;
800         if (NULL != g_handle) {
801                 wakeup_manager_start_streaming_utterance_data func = _wakeup_manager_interface.start_streaming_utterance_data;
802                 if (NULL == func) {
803                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA);
804                 } else {
805                         ret = func();
806                         if (0 != ret) {
807                                 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
808                         }
809                 }
810         } else {
811                 MAS_LOGE("[ERROR] g_handle is not valid");
812         }
813         return ret;
814 }
815
816 int multi_assistant_service_plugin_stop_streaming_utterance_data(void)
817 {
818         int ret = -1;
819         if (NULL != g_handle) {
820                 wakeup_manager_stop_streaming_utterance_data func = _wakeup_manager_interface.stop_streaming_utterance_data;
821                 if (NULL == func) {
822                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_UTTERANCE_DATA);
823                 } else {
824                         ret = func();
825                         if (0 != ret) {
826                                 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
827                         }
828                 }
829         } else {
830                 MAS_LOGE("[ERROR] g_handle is not valid");
831         }
832         return ret;
833 }
834
835 int multi_assistant_service_plugin_start_streaming_previous_utterance_data(void)
836 {
837         int ret = -1;
838         if (NULL != g_handle) {
839                 wakeup_manager_start_streaming_previous_utterance_data func = _wakeup_manager_interface.start_streaming_previous_utterance_data;
840                 if (NULL == func) {
841                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_PREVIOUS_UTTERANCE_DATA);
842                 } else {
843                         ret = func();
844                         if (0 != ret) {
845                                 MAS_LOGE("[ERROR] Fail to request previous speech data, ret(%d)", ret);
846                         }
847                 }
848         } else {
849                 MAS_LOGE("[ERROR] g_handle is not valid");
850         }
851         return ret;
852 }
853
854 int multi_assistant_service_plugin_stop_streaming_previous_utterance_data(void)
855 {
856         int ret = -1;
857         if (NULL != g_handle) {
858                 wakeup_manager_stop_streaming_previous_utterance_data func = _wakeup_manager_interface.stop_streaming_previous_utterance_data;
859                 if (NULL == func) {
860                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_PREVIOUS_UTTERANCE_DATA);
861                 } else {
862                         ret = func();
863                         if (0 != ret) {
864                                 MAS_LOGE("[ERROR] Fail to request previous speech data, ret(%d)", ret);
865                         }
866                 }
867         } else {
868                 MAS_LOGE("[ERROR] g_handle is not valid");
869         }
870         return ret;
871 }
872
873 int multi_assistant_service_plugin_start_streaming_follow_up_data(void)
874 {
875         int ret = -1;
876         if (NULL != g_handle) {
877                 wakeup_manager_start_streaming_follow_up_data func = _wakeup_manager_interface.start_streaming_follow_up_data;
878                 if (NULL == func) {
879                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_FOLLOW_UP_DATA);
880                 } else {
881                         ret = func();
882                         if (0 != ret) {
883                                 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
884                         }
885                 }
886         } else {
887                 MAS_LOGE("[ERROR] g_handle is not valid");
888         }
889         return ret;
890 }
891
892 int multi_assistant_service_plugin_stop_streaming_follow_up_data(void)
893 {
894         int ret = -1;
895         if (NULL != g_handle) {
896                 wakeup_manager_stop_streaming_follow_up_data func = _wakeup_manager_interface.stop_streaming_follow_up_data;
897                 if (NULL == func) {
898                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_STOP_STREAMING_FOLLOW_UP_DATA);
899                 } else {
900                         ret = func();
901                         if (0 != ret) {
902                                 MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret);
903                         }
904                 }
905         } else {
906                 MAS_LOGE("[ERROR] g_handle is not valid");
907         }
908         return ret;
909 }
910
911 int multi_assistant_service_plugin_get_recording_audio_format(int *rate, int *channel, int *audio_type)
912 {
913         int ret = -1;
914         if (NULL != g_handle) {
915                 wakeup_manager_get_audio_format func = _wakeup_manager_interface.get_audio_format;
916                 if (NULL == func) {
917                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT);
918                 } else {
919                         ret = func(rate, channel, audio_type);
920                         if (0 != ret) {
921                                 MAS_LOGE("[ERROR] Fail to get recording audio format, ret(%d)", ret);
922                         }
923                 }
924         } else {
925                 MAS_LOGE("[ERROR] g_handle is not valid");
926         }
927         return ret;
928 }
929
930 int multi_assistant_service_plugin_get_recording_audio_source_type(char** type)
931 {
932         int ret = -1;
933         if (NULL != g_handle) {
934                 wakeup_manager_get_audio_source_type func = _wakeup_manager_interface.get_audio_source_type;
935                 if (NULL == func) {
936                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
937                 } else {
938                         ret = func(type);
939                         if (0 != ret) {
940                                 MAS_LOGE("[ERROR] Fail to get recording audio source type, ret(%d)", ret);
941                         }
942                 }
943         } else {
944                 MAS_LOGE("[ERROR] g_handle is not valid");
945         }
946         return ret;
947 }
948
949 int multi_assistant_service_plugin_set_wake_word_audio_require_flag(const char* appid, bool require)
950 {
951         int ret = -1;
952         if (NULL != g_handle) {
953                 wakeup_manager_set_wake_word_audio_require_flag func = _wakeup_manager_interface.set_wake_word_audio_require_flag;
954                 if (NULL == func) {
955                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG);
956                 } else {
957                         ret = func(require);
958                         if (0 != ret) {
959                                 MAS_LOGE("[ERROR] Fail to set wake word audio require flag, ret(%d)", ret);
960                         }
961                 }
962         } else {
963                 MAS_LOGE("[ERROR] g_handle is not valid");
964         }
965         return ret;
966 }
967
968 int multi_assistant_service_plugin_set_callbacks(void)
969 {
970         int ret = multi_assistant_service_plugin_set_wakeup_event_callback(__wakeup_event_cb, NULL);
971         if (0 != ret) {
972                 MAS_LOGE("Fail to set wakeup event cb");
973                 return ret;
974         }
975
976         ret = multi_assistant_service_plugin_set_utterance_streaming_callback(__audio_streaming_cb, NULL);
977         if (0 != ret) {
978                 MAS_LOGE("Fail to set utterance streaming cb");
979                 return ret;
980         }
981
982         ret = multi_assistant_service_plugin_set_previous_utterance_streaming_callback(__audio_streaming_cb, NULL);
983         if (0 != ret) {
984                 MAS_LOGE("Fail to set previous utterance streaming cb");
985                 return ret;
986         }
987
988         ret = multi_assistant_service_plugin_set_follow_up_streaming_callback(__audio_streaming_cb, NULL);
989         if (0 != ret) {
990                 MAS_LOGE("Fail to set follow-up streaming cb");
991                 return ret;
992         }
993
994         ret = multi_assistant_service_plugin_set_speech_status_callback(__speech_status_cb, NULL);
995         if (0 != ret) {
996                 MAS_LOGE("Fail to set speech status changed cb");
997                 return ret;
998         }
999
1000         ret = multi_assistant_service_plugin_set_error_callback(__error_cb, NULL);
1001         if (0 != ret) {
1002                 MAS_LOGE("Fail to set error cb");
1003                 return ret;
1004         }
1005
1006         ret = multi_assistant_service_plugin_set_streaming_section_changed_callback(__streaming_section_changed_cb, NULL);
1007         if (0 != ret) {
1008                 MAS_LOGE("Fail to set streaming section changed cb");
1009                 return ret;
1010         }
1011
1012         return 0;
1013 }
1014
1015 int multi_assistant_service_plugin_set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data)
1016 {
1017         int ret = -1;
1018         if (NULL != g_handle) {
1019                 wakeup_manager_set_wakeup_event_callback func = _wakeup_manager_interface.set_wakeup_event_callback;
1020                 if (NULL == func) {
1021                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
1022                 } else {
1023                         ret = func(callback, user_data);
1024                         if (0 != ret) {
1025                                 MAS_LOGE("[ERROR] Fail to set wakeup event callback, ret(%d)", ret);
1026                         }
1027                 }
1028         } else {
1029                 MAS_LOGE("[ERROR] g_handle is not valid");
1030         }
1031         return ret;
1032 }
1033
1034 int multi_assistant_service_plugin_set_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1035 {
1036         int ret = -1;
1037         if (NULL != g_handle) {
1038                 wakeup_manager_set_utterance_streaming_callback func = _wakeup_manager_interface.set_utterance_streaming_callback;
1039                 if (NULL == func) {
1040                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_UTTERANCE_STREAMING_CALLBACK);
1041                 } else {
1042                         ret = func(callback, user_data);
1043                         if (0 != ret) {
1044                                 MAS_LOGE("[ERROR] Fail to set utterance streaming callback, ret(%d)", ret);
1045                         }
1046                 }
1047         } else {
1048                 MAS_LOGE("[ERROR] g_handle is not valid");
1049         }
1050         return ret;
1051 }
1052
1053 int multi_assistant_service_plugin_set_previous_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1054 {
1055         int ret = -1;
1056         if (NULL != g_handle) {
1057                 wakeup_manager_set_previous_utterance_streaming_callback func = _wakeup_manager_interface.set_previous_utterance_streaming_callback;
1058                 if (NULL == func) {
1059                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_PREVIOUS_UTTERANCE_STREAMING_CALLBACK);
1060                 } else {
1061                         ret = func(callback, user_data);
1062                         if (0 != ret) {
1063                                 MAS_LOGE("[ERROR] Fail to set utterance streaming callback, ret(%d)", ret);
1064                         }
1065                 }
1066         } else {
1067                 MAS_LOGE("[ERROR] g_handle is not valid");
1068         }
1069         return ret;
1070 }
1071
1072 int multi_assistant_service_plugin_set_follow_up_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
1073 {
1074         int ret = -1;
1075         if (NULL != g_handle) {
1076                 wakeup_manager_set_follow_up_streaming_callback func = _wakeup_manager_interface.set_follow_up_streaming_callback;
1077                 if (NULL == func) {
1078                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_FOLLOW_UP_STREAMING_CALLBACK);
1079                 } else {
1080                         ret = func(callback, user_data);
1081                         if (0 != ret) {
1082                                 MAS_LOGE("[ERROR] Fail to set follow-up streaming callback, ret(%d)", ret);
1083                         }
1084                 }
1085         } else {
1086                 MAS_LOGE("[ERROR] g_handle is not valid");
1087         }
1088         return ret;
1089 }
1090
1091 int multi_assistant_service_plugin_set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data)
1092 {
1093         int ret = -1;
1094         if (NULL != g_handle) {
1095                 wakeup_manager_set_speech_status_callback func = _wakeup_manager_interface.set_speech_status_callback;
1096                 if (NULL == func) {
1097                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK);
1098                 } else {
1099                         ret = func(callback, user_data);
1100                         if (0 != ret) {
1101                                 MAS_LOGE("[ERROR] Fail to set speech status callback, ret(%d)", ret);
1102                         }
1103                 }
1104         }
1105         return ret;
1106 }
1107
1108 int multi_assistant_service_plugin_set_error_callback(wakeup_service_error_cb callback, void* user_data)
1109 {
1110         int ret = -1;
1111         if (NULL != g_handle) {
1112                 wakeup_manager_set_error_callback func = _wakeup_manager_interface.set_error_callback;
1113                 if (NULL == func) {
1114                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK);
1115                 } else {
1116                         ret = func(callback, user_data);
1117                         if (0 != ret) {
1118                                 MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret);
1119                         }
1120                 }
1121         }
1122         return ret;
1123 }
1124
1125 int multi_assistant_service_plugin_set_streaming_section_changed_callback(wakeup_service_streaming_section_changed_cb callback, void* user_data)
1126 {
1127         int ret = -1;
1128         if (NULL != g_handle) {
1129                 wakeup_manager_set_streaming_section_changed_callback func = _wakeup_manager_interface.set_streaming_section_changed_callback;
1130                 if (NULL == func) {
1131                         MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_STREAMING_SECTION_CHANGED_CALLBACK);
1132                 } else {
1133                         ret = func(callback, user_data);
1134                         if (0 != ret) {
1135                                 MAS_LOGE("[ERROR] Fail to set streaming section changed callback, ret(%d)", ret);
1136                         }
1137                 }
1138         }
1139         return ret;
1140 }