From: Wonnam Jang Date: Wed, 7 Nov 2018 10:17:23 +0000 (+0900) Subject: Update libraries and fix crash when g_handle is null X-Git-Tag: submit/tizen/20181204.065424^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F57%2F192657%2F1;p=platform%2Fcore%2Fuifw%2Fwakeup-engine-default.git Update libraries and fix crash when g_handle is null Change-Id: I1a1a9ff0e5f2dcd57a08a03b4110e2a27287f485 Signed-off-by: Wonnam Jang --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d4cb41..9483a17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,7 +92,7 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/armv7l/libspeex.so DESTINATION ${PREFIX}/l INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/armv7l/libvoiceactivity.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/armv7l/libvoice-transport.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) ELSEIF("${ARCH}" MATCHES "^i586.*") -TARGET_LINK_LIBRARIES(${BINNAME} -Llib/i586 -lopus -lboost_iostreams -ln66asrdll -lspeex -lvoiceactivity -lvoice-transport -lmulti-wakeup-recognizer -ldl ${pkgs_LDFLAGS} ${EXTRA_LDFLAGS}) +TARGET_LINK_LIBRARIES(${BINNAME} -Llib/i586 -lopus -lboost_iostreams -ln66asrdll -lspeex -lvoiceactivity -lvoice-transport -ldl ${pkgs_LDFLAGS} ${EXTRA_LDFLAGS}) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/i586/libmulti-wakeup-recognizer.so DESTINATION ${TZ_SYS_RO_SHARE}/multiassistant/ma/1.0/engine/ COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/i586/libopus.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/i586/libboost_iostreams.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) @@ -101,7 +101,7 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/i586/libspeex.so DESTINATION ${PREFIX}/lib INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/i586/libvoiceactivity.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/i586/libvoice-transport.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) ELSEIF("${ARCH}" MATCHES "^i686.*") -TARGET_LINK_LIBRARIES(${BINNAME} -Llib/i586 -lopus -lboost_iostreams -ln66asrdll -lspeex -lvoiceactivity -lvoice-transport -lmulti-wakeup-recognizer -ldl ${pkgs_LDFLAGS} ${EXTRA_LDFLAGS}) +TARGET_LINK_LIBRARIES(${BINNAME} -Llib/i586 -lopus -lboost_iostreams -ln66asrdll -lspeex -lvoiceactivity -lvoice-transport -ldl ${pkgs_LDFLAGS} ${EXTRA_LDFLAGS}) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/i586/libmulti-wakeup-recognizer.so DESTINATION ${TZ_SYS_RO_SHARE}/multiassistant/ma/1.0/engine/ COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/i586/libopus.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/i586/libboost_iostreams.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) @@ -110,7 +110,7 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/i586/libspeex.so DESTINATION ${PREFIX}/lib INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/i586/libvoiceactivity.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/i586/libvoice-transport.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) ELSEIF("${ARCH}" MATCHES "^aarch64.*") -TARGET_LINK_LIBRARIES(${BINNAME} -Llib/aarch64 -lopus -lboost_iostreams -ln66asrdll -lspeex -lvoiceactivity -lvoice-transport -lmulti-wakeup-recognizer -ldl ${pkgs_LDFLAGS} ${EXTRA_LDFLAGS}) +TARGET_LINK_LIBRARIES(${BINNAME} -Llib/aarch64 -lopus -lboost_iostreams -ln66asrdll -lspeex -lvoiceactivity -lvoice-transport -ldl ${pkgs_LDFLAGS} ${EXTRA_LDFLAGS}) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/aarch64/libmulti-wakeup-recognizer.so DESTINATION ${TZ_SYS_RO_SHARE}/multiassistant/ma/1.0/engine/ COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/aarch64/libopus.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/aarch64/libboost_iostreams.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) @@ -119,7 +119,7 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/aarch64/libspeex.so DESTINATION ${PREFIX}/ INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/aarch64/libvoiceactivity.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/aarch64/libvoice-transport.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) ELSEIF("${ARCH}" MATCHES "^x86_64.*") -TARGET_LINK_LIBRARIES(${BINNAME} -Llib/x86_64 -lopus -lboost_iostreams -ln66asrdll -lspeex -lvoiceactivity -lvoice-transport -lmulti-wakeup-recognizer -ldl ${pkgs_LDFLAGS} ${EXTRA_LDFLAGS}) +TARGET_LINK_LIBRARIES(${BINNAME} -Llib/x86_64 -lopus -lboost_iostreams -ln66asrdll -lspeex -lvoiceactivity -lvoice-transport -ldl ${pkgs_LDFLAGS} ${EXTRA_LDFLAGS}) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/x86_64/libmulti-wakeup-recognizer.so DESTINATION ${TZ_SYS_RO_SHARE}/multiassistant/ma/1.0/engine/ COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/x86_64/libopus.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/x86_64/libboost_iostreams.so DESTINATION ${PREFIX}/lib COMPONENT RuntimeLibraries) diff --git a/lib/aarch64/libn66asrdll.so b/lib/aarch64/libn66asrdll.so old mode 100755 new mode 100644 index bddf89d..39e84f3 Binary files a/lib/aarch64/libn66asrdll.so and b/lib/aarch64/libn66asrdll.so differ diff --git a/lib/aarch64/libopus.so b/lib/aarch64/libopus.so old mode 100755 new mode 100644 index d85d589..337f181 Binary files a/lib/aarch64/libopus.so and b/lib/aarch64/libopus.so differ diff --git a/lib/aarch64/libvoice-transport.so b/lib/aarch64/libvoice-transport.so old mode 100755 new mode 100644 index 9c90da2..f98cbdc Binary files a/lib/aarch64/libvoice-transport.so and b/lib/aarch64/libvoice-transport.so differ diff --git a/lib/aarch64/libvoiceactivity.so b/lib/aarch64/libvoiceactivity.so index 0256b46..73220fa 100644 Binary files a/lib/aarch64/libvoiceactivity.so and b/lib/aarch64/libvoiceactivity.so differ diff --git a/lib/armv7l/libmulti-wakeup-recognizer.so b/lib/armv7l/libmulti-wakeup-recognizer.so index a42c30c..eb293a9 100644 Binary files a/lib/armv7l/libmulti-wakeup-recognizer.so and b/lib/armv7l/libmulti-wakeup-recognizer.so differ diff --git a/lib/armv7l/libn66asrdll.so b/lib/armv7l/libn66asrdll.so index 1e733ba..ba52ec7 100644 Binary files a/lib/armv7l/libn66asrdll.so and b/lib/armv7l/libn66asrdll.so differ diff --git a/lib/armv7l/libopus.so b/lib/armv7l/libopus.so index 998e511..ccec2c9 100644 Binary files a/lib/armv7l/libopus.so and b/lib/armv7l/libopus.so differ diff --git a/lib/armv7l/libvoice-transport.so b/lib/armv7l/libvoice-transport.so index 4d8212b..2e5aac2 100644 Binary files a/lib/armv7l/libvoice-transport.so and b/lib/armv7l/libvoice-transport.so differ diff --git a/lib/armv7l/libvoiceactivity.so b/lib/armv7l/libvoiceactivity.so index 24d205c..545ce36 100644 Binary files a/lib/armv7l/libvoiceactivity.so and b/lib/armv7l/libvoiceactivity.so differ diff --git a/lib/i586/libn66asrdll.so b/lib/i586/libn66asrdll.so old mode 100755 new mode 100644 index 7279ede..d0c6b7a Binary files a/lib/i586/libn66asrdll.so and b/lib/i586/libn66asrdll.so differ diff --git a/lib/i586/libopus.so b/lib/i586/libopus.so old mode 100755 new mode 100644 index 6033ab1..01f1ffe Binary files a/lib/i586/libopus.so and b/lib/i586/libopus.so differ diff --git a/lib/i586/libvoice-transport.so b/lib/i586/libvoice-transport.so old mode 100755 new mode 100644 index 9c5454d..fc3f91b Binary files a/lib/i586/libvoice-transport.so and b/lib/i586/libvoice-transport.so differ diff --git a/lib/i586/libvoiceactivity.so b/lib/i586/libvoiceactivity.so index 3fb1cdf..ea5870a 100644 Binary files a/lib/i586/libvoiceactivity.so and b/lib/i586/libvoiceactivity.so differ diff --git a/lib/x86_64/libn66asrdll.so b/lib/x86_64/libn66asrdll.so old mode 100755 new mode 100644 index a08adb1..f631ec7 Binary files a/lib/x86_64/libn66asrdll.so and b/lib/x86_64/libn66asrdll.so differ diff --git a/lib/x86_64/libopus.so b/lib/x86_64/libopus.so old mode 100755 new mode 100644 index 0fa0eeb..beb869f Binary files a/lib/x86_64/libopus.so and b/lib/x86_64/libopus.so differ diff --git a/lib/x86_64/libvoice-transport.so b/lib/x86_64/libvoice-transport.so old mode 100755 new mode 100644 index 7450aa2..16372bc Binary files a/lib/x86_64/libvoice-transport.so and b/lib/x86_64/libvoice-transport.so differ diff --git a/lib/x86_64/libvoiceactivity.so b/lib/x86_64/libvoiceactivity.so index c0b8ce6..a289369 100644 Binary files a/lib/x86_64/libvoiceactivity.so and b/lib/x86_64/libvoiceactivity.so differ diff --git a/packaging/org.tizen.multi-assistant-service.spec b/packaging/org.tizen.multi-assistant-service.spec index e9c2bf4..d56ad44 100644 --- a/packaging/org.tizen.multi-assistant-service.spec +++ b/packaging/org.tizen.multi-assistant-service.spec @@ -74,6 +74,9 @@ mkdir -p %{_libdir}/multiassistant/ma/1.0/engine #/usr/bin/signing-client/hash-signer-client.sh -a -d -p platform /usr/apps/org.tizen.multi-assistant-service mv %{_appdir}/lib/libboost_iostreams.so %{_appdir}/lib/libboost_iostreams.so.1.58.0 ln -s %{_appdir}/lib/libboost_iostreams.so.1.58.0 %{_appdir}/lib/libboost_iostreams.so +mv %{_appdir}/lib/libopus.so %{_appdir}/lib/libopus.so.0.6.1 +ln -s %{_appdir}/lib/libopus.so.0.6.1 %{_appdir}/lib/libopus.so.0 +ln -s %{_appdir}/lib/libopus.so.0.6.1 %{_appdir}/lib/libopus.so /sbin/ldconfig exit 0 diff --git a/src/multi_assistant_service_plugin.c b/src/multi_assistant_service_plugin.c index 8dbf332..92f7bdb 100644 --- a/src/multi_assistant_service_plugin.c +++ b/src/multi_assistant_service_plugin.c @@ -92,11 +92,16 @@ Eina_Bool __request_speech_data(void *data) if ((pid = mas_get_client_pid_by_wakeup_word(wakeup_word)) != -1) { MAS_LOGD("MA Client with wakeup word %s exists, requesting speech data", (wakeup_word ? wakeup_word : "NULL")); ma_client_set_temp_speech_data_requested(1); - int (*ws_request_speech_data)(void); - ws_request_speech_data = (int (*)(void))dlsym(g_handle, "wakeup_service_request_speech_data"); - int ret = ws_request_speech_data(); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to request speech data(%d)", ret); + int ret = -1; + if (NULL != g_handle) { + int (*ws_request_speech_data)(void); + ws_request_speech_data = (int (*)(void))dlsym(g_handle, "wakeup_service_request_speech_data"); + ret = ws_request_speech_data(); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to request speech data(%d)", ret); + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); } } else { // Appropriate MA Client not available, trying to launch new one @@ -262,18 +267,24 @@ int multi_assistant_service_plugin_initialize(void) char filepath[512] = {'\0',}; snprintf(filepath, 512, "%s/%s", MA_DEFAULT_ENGINE, "libmulti-wakeup-recognizer.so"); + char *error; g_handle = NULL; g_handle = dlopen(filepath, RTLD_LAZY); - if (NULL != dlerror()) { - MAS_LOGE("[ERROR] Fail to dlopen"); + if (NULL != (error = dlerror())) { + MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error); return -1; //MAS_ERROR_OPERATION_FAILED; } - int (*ws_initialize)(void); - ws_initialize = (int (*)(void))dlsym(g_handle, "wakeup_service_initialize"); - int ret = ws_initialize(); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to initialize, ret(%d)", ret); + int ret = -1; + if (NULL != g_handle) { + int (*ws_initialize)(void); + ws_initialize = (int (*)(void))dlsym(g_handle, "wakeup_service_initialize"); + ret = ws_initialize(); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to initialize, ret(%d)", ret); + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); } return ret; } @@ -288,17 +299,19 @@ int multi_assistant_service_plugin_deinitialize(void) MAS_LOGD("[Recorder ERROR] File not found!"); } #endif + int ret = -1; + if (NULL != g_handle) { + int (*ws_deinitialize)(void); + ws_deinitialize = (int (*)(void))dlsym(g_handle, "wakeup_service_deinitialize"); + ret = ws_deinitialize(); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to deinitialize, ret(%d)", ret); + } - int (*ws_deinitialize)(void); - ws_deinitialize = (int (*)(void))dlsym(g_handle, "wakeup_service_deinitialize"); - int ret = ws_deinitialize(); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to deinitialize, ret(%d)", ret); - } - - if (g_handle) { dlclose(g_handle); g_handle = NULL; + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); } return ret; @@ -306,66 +319,96 @@ int multi_assistant_service_plugin_deinitialize(void) int multi_assistant_service_plugin_set_language(const char* language) { - int (*ws_set_language)(const char* language); - ws_set_language = (int (*)(const char* language))dlsym(g_handle, "wakeup_service_set_language"); - int ret = ws_set_language(language); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to set langauge(%s), ret(%d)", language, ret); + int ret = -1; + if (NULL != g_handle) { + int (*ws_set_language)(const char* language); + ws_set_language = (int (*)(const char* language))dlsym(g_handle, "wakeup_service_set_language"); + ret = ws_set_language(language); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to set langauge(%s), ret(%d)", language, ret); + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); } return ret; } int multi_assistant_service_plugin_set_wakeup_word(const char* language, const char* wakeup_word) { - int (*ws_set_wakeup_word)(const char* language, const char* wakeup_word); - ws_set_wakeup_word = (int (*)(const char* language, const char* wakeup_word))dlsym(g_handle, "wakeup_service_set_wakeup_word"); - int ret = ws_set_wakeup_word(language, wakeup_word); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to set wakeup word(%s)(%s), ret(%d)", language, wakeup_word, ret); + int ret = -1; + if (NULL != g_handle) { + int (*ws_set_wakeup_word)(const char* language, const char* wakeup_word); + ws_set_wakeup_word = (int (*)(const char* language, const char* wakeup_word))dlsym(g_handle, "wakeup_service_set_wakeup_word"); + ret = ws_set_wakeup_word(language, wakeup_word); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to set wakeup word(%s)(%s), ret(%d)", language, wakeup_word, ret); + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); } return ret; } int multi_assistant_service_plugin_start_recording(void) { - int (*ws_start_recording)(void); - ws_start_recording = (int (*)(void))dlsym(g_handle, "wakeup_service_start_recording"); - int ret = ws_start_recording(); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to start recording, ret(%d)", ret); + int ret = -1; + if (NULL != g_handle) { + int (*ws_start_recording)(void); + ws_start_recording = (int (*)(void))dlsym(g_handle, "wakeup_service_start_recording"); + ret = ws_start_recording(); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to start recording, ret(%d)", ret); + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); } return ret; } int multi_assistant_service_plugin_stop_recording(void) { - int (*ws_stop_recording)(void); - ws_stop_recording = (int (*)(void))dlsym(g_handle, "wakeup_service_stop_recording"); - int ret = ws_stop_recording(); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret); + int ret = -1; + if (NULL != g_handle) { + int (*ws_stop_recording)(void); + ws_stop_recording = (int (*)(void))dlsym(g_handle, "wakeup_service_stop_recording"); + ret = ws_stop_recording(); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret); + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); } return ret; } int multi_assistant_service_plugin_cancel_recording(void) { - int (*ws_cancel_recording)(void); - ws_cancel_recording = (int (*)(void))dlsym(g_handle, "wakeup_service_cancel_recording"); - int ret = ws_cancel_recording(); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to cancel recording, ret(%d)", ret); + int ret = -1; + if (NULL != g_handle) { + int (*ws_cancel_recording)(void); + ws_cancel_recording = (int (*)(void))dlsym(g_handle, "wakeup_service_cancel_recording"); + ret = ws_cancel_recording(); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to cancel recording, ret(%d)", ret); + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); } return ret; } int multi_assistant_service_plugin_request_speech_data(void) { - int (*ws_request_speech_data)(void); - ws_request_speech_data = (int (*)(void))dlsym(g_handle, "wakeup_service_request_speech_data"); - int ret = ws_request_speech_data(); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret); + int ret = -1; + if (NULL != g_handle) { + int (*ws_request_speech_data)(void); + ws_request_speech_data = (int (*)(void))dlsym(g_handle, "wakeup_service_request_speech_data"); + ret = ws_request_speech_data(); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret); + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); } return ret; } @@ -400,55 +443,76 @@ int multi_assistant_service_plugin_set_callbacks(void) int multi_assistant_service_plugin_get_recording_audio_format(int *rate, int *channel, int *audio_type) { - int (*ws_get_recording_audio_format)(int *rate, int *channel, int *audio_type); - ws_get_recording_audio_format = (int (*)(int *rate, int *channel, int *audio_type))dlsym(g_handle, "wakeup_service_get_recording_audio_format"); - int ret = ws_get_recording_audio_format(rate, channel, audio_type); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to get recording audio format, ret(%d)", ret); + int ret = -1; + if (NULL != g_handle) { + int (*ws_get_recording_audio_format)(int *rate, int *channel, int *audio_type); + ws_get_recording_audio_format = (int (*)(int *rate, int *channel, int *audio_type))dlsym(g_handle, "wakeup_service_get_recording_audio_format"); + ret = ws_get_recording_audio_format(rate, channel, audio_type); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to get recording audio format, ret(%d)", ret); + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); } return ret; } int multi_assistant_service_plugin_set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data) { - int (*ws_set_wakeup_event_callback)(wakeup_service_wakeup_event_cb callback, void* user_data); - ws_set_wakeup_event_callback = (int (*)(wakeup_service_wakeup_event_cb callback, void* user_data))dlsym(g_handle, "wakeup_service_set_wakeup_event_callback"); - int ret = ws_set_wakeup_event_callback(callback, user_data); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to set wakeup event callback, ret(%d)", ret); + int ret = -1; + if (NULL != g_handle) { + int (*ws_set_wakeup_event_callback)(wakeup_service_wakeup_event_cb callback, void* user_data); + ws_set_wakeup_event_callback = (int (*)(wakeup_service_wakeup_event_cb callback, void* user_data))dlsym(g_handle, "wakeup_service_set_wakeup_event_callback"); + ret = ws_set_wakeup_event_callback(callback, user_data); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to set wakeup event callback, ret(%d)", ret); + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); } return ret; } int multi_assistant_service_plugin_set_speech_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data) { - int (*ws_set_speech_streaming_callback)(wakeup_service_speech_streaming_cb callback, void* user_data); - ws_set_speech_streaming_callback = (int (*)(wakeup_service_speech_streaming_cb callback, void* user_data))dlsym(g_handle, "wakeup_service_set_speech_streaming_callback"); - int ret = ws_set_speech_streaming_callback(callback, user_data); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to speech streaming callback, ret(%d)", ret); + int ret = -1; + if (NULL != g_handle) { + int (*ws_set_speech_streaming_callback)(wakeup_service_speech_streaming_cb callback, void* user_data); + ws_set_speech_streaming_callback = (int (*)(wakeup_service_speech_streaming_cb callback, void* user_data))dlsym(g_handle, "wakeup_service_set_speech_streaming_callback"); + ret = ws_set_speech_streaming_callback(callback, user_data); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to speech streaming callback, ret(%d)", ret); + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); } return ret; } int multi_assistant_service_plugin_set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data) { - int (*ws_set_speech_status_callback)(wakeup_service_speech_status_cb callback, void* user_data); - ws_set_speech_status_callback = (int (*)(wakeup_service_speech_status_cb callback, void* user_data))dlsym(g_handle, "wakeup_service_set_speech_status_callback"); - int ret = ws_set_speech_status_callback(callback, user_data); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to set speech status callback, ret(%d)", ret); + int ret = -1; + if (NULL != g_handle) { + int (*ws_set_speech_status_callback)(wakeup_service_speech_status_cb callback, void* user_data); + ws_set_speech_status_callback = (int (*)(wakeup_service_speech_status_cb callback, void* user_data))dlsym(g_handle, "wakeup_service_set_speech_status_callback"); + ret = ws_set_speech_status_callback(callback, user_data); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to set speech status callback, ret(%d)", ret); + } } return ret; } int multi_assistant_service_plugin_set_error_callback(wakeup_service_error_cb callback, void* user_data) { - int (*ws_set_error_callback)(wakeup_service_error_cb callback, void* user_data); - ws_set_error_callback = (int (*)(wakeup_service_error_cb callback, void* user_data))dlsym(g_handle, "wakeup_service_set_error_callback"); - int ret = ws_set_error_callback(callback, user_data); - if (0 != ret) { - MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret); + int ret = -1; + if (NULL != g_handle) { + int (*ws_set_error_callback)(wakeup_service_error_cb callback, void* user_data); + ws_set_error_callback = (int (*)(wakeup_service_error_cb callback, void* user_data))dlsym(g_handle, "wakeup_service_set_error_callback"); + ret = ws_set_error_callback(callback, user_data); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to set error callback, ret(%d)", ret); + } } return ret; }