From: Ji-hoon Lee Date: Wed, 16 Oct 2019 07:38:12 +0000 (+0900) Subject: Add sample code for terminating host process X-Git-Tag: accepted/tizen/5.5/unified/20191031.020045~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ce5f8f324192d9cec13056b71a55c20bf3691a34;p=platform%2Fcore%2Fuifw%2Fmulti-assistant-service.git Add sample code for terminating host process Change-Id: I4106710af29912e58bd0c4d0123cc1348f8ecc69 --- diff --git a/plugins/wakeup-manager/dependency-default/src/dependency_default.cpp b/plugins/wakeup-manager/dependency-default/src/dependency_default.cpp index be13250..edff076 100644 --- a/plugins/wakeup-manager/dependency-default/src/dependency_default.cpp +++ b/plugins/wakeup-manager/dependency-default/src/dependency_default.cpp @@ -2,9 +2,16 @@ #include "dependency_default_audio.h" #include "dependency_default_button.h" +#include +#include + +#include + static mas_proxy_interface g_proxy_interface; const int g_dependency_version = 1; +static bool g_should_exit = false; + int mas_dependency_initialize(mas_proxy_interface interface, int *dependency_version) { g_proxy_interface = interface; @@ -16,6 +23,20 @@ int mas_dependency_initialize(mas_proxy_interface interface, int *dependency_ver *dependency_version = g_dependency_version; } + /* If the service process has to terminate in certain circumstances, + set g_should_exit variable to true as below. */ + // g_should_exit = true; + + if (g_should_exit) { + LOGE("g_should_exit value contains positive value, registering timer"); + std::thread([]() { + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + LOGE("Now trying to exit"); + mas_dependency_deinitialize(); + service_app_exit_without_restart(); + }).detach(); + } + return 0; } diff --git a/plugins/wakeup-manager/dependency-default/src/dependency_default_audio.cpp b/plugins/wakeup-manager/dependency-default/src/dependency_default_audio.cpp index 1bc67c5..e803739 100644 --- a/plugins/wakeup-manager/dependency-default/src/dependency_default_audio.cpp +++ b/plugins/wakeup-manager/dependency-default/src/dependency_default_audio.cpp @@ -190,6 +190,8 @@ void dependency_default_audio_initialize(mas_proxy_interface interfaces) void dependency_default_audio_deinitialize() { + dependency_default_audio_stop_recording(); + int ret = 0; if (g_virtual_sound_stream) { sound_manager_stop_virtual_stream(g_virtual_sound_stream); @@ -268,13 +270,15 @@ static void recorder_thread_func() void dependency_default_audio_start_recording() { - int ret = audio_in_resume(g_audio_in); - if (AUDIO_IO_ERROR_NONE != ret) { - LOGD("[Recorder ERROR] Fail to resume audio in : %d", ret); + if (g_audio_in) { + int ret = audio_in_resume(g_audio_in); + if (AUDIO_IO_ERROR_NONE != ret) { + LOGD("[Recorder ERROR] Fail to resume audio in : %d", ret); + } + g_stop_recorder_thread.store(false); + LOGD("Starting recorder thread"); + g_recorder_thread = thread(recorder_thread_func); } - g_stop_recorder_thread.store(false); - LOGD("Starting recorder thread"); - g_recorder_thread = thread(recorder_thread_func); } void dependency_default_audio_stop_recording() @@ -284,9 +288,11 @@ void dependency_default_audio_stop_recording() g_stop_recorder_thread.store(true); g_recorder_thread.join(); } - int ret = audio_in_pause(g_audio_in); - if (AUDIO_IO_ERROR_NONE != ret) { - LOGD("[Recorder ERROR] Fail to pause audio in : %d", ret); + if (g_audio_in) { + int ret = audio_in_pause(g_audio_in); + if (AUDIO_IO_ERROR_NONE != ret) { + LOGD("[Recorder ERROR] Fail to pause audio in : %d", ret); + } } }