Send voice key status after recording control 86/265786/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Thu, 28 Oct 2021 11:19:11 +0000 (20:19 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Thu, 28 Oct 2021 11:19:11 +0000 (20:19 +0900)
Change-Id: I0df6b18411a218ec5eb271fc6dba6858276db74b

plugins/wakeup-manager/src/wakeup_manager.cpp

index 7f856ea..6ed89fd 100644 (file)
@@ -21,6 +21,9 @@
 #include "dependency_resolver.h"
 
 #include <algorithm>
+
+#include <boost/optional.hpp>
+
 namespace multiassistant
 {
 namespace wakeup
@@ -518,22 +521,23 @@ bool CWakeupManager::process_plugin_event(mas_plugin_event_e event, void* data,
        bool start_recording = false;
        bool stop_recording = false;
 
+       boost::optional<ma_voice_key_status_e> next_voice_key_status;
        if (MAS_PLUGIN_EVENT_VOICE_KEY_PRESSED == event) {
                if (VOICE_KEY_SUPPORT_MODE_NONE != mCurrentVoiceKeySupportMode) {
                        start_recording = true;
                }
-               change_voice_key_status(MA_VOICE_KEY_STATUS_PRESSED);
+               next_voice_key_status = MA_VOICE_KEY_STATUS_PRESSED;
        } else if (MAS_PLUGIN_EVENT_VOICE_KEY_RELEASED_AFTER_PUSH == event) {
                if (VOICE_KEY_SUPPORT_MODE_PUSH_TO_TALK == mCurrentVoiceKeySupportMode ||
                        VOICE_KEY_SUPPORT_MODE_ALL == mCurrentVoiceKeySupportMode) {
                        stop_recording = true;
                }
-               change_voice_key_status(MA_VOICE_KEY_STATUS_RELEASED_AFTER_PUSH);
+               next_voice_key_status = MA_VOICE_KEY_STATUS_RELEASED_AFTER_PUSH;
        } else if (MAS_PLUGIN_EVENT_VOICE_KEY_RELEASED_AFTER_TAP == event) {
                if (VOICE_KEY_SUPPORT_MODE_PUSH_TO_TALK == mCurrentVoiceKeySupportMode) {
                        stop_recording = true;
                }
-               change_voice_key_status(MA_VOICE_KEY_STATUS_RELEASED_AFTER_TAP);
+               next_voice_key_status = MA_VOICE_KEY_STATUS_RELEASED_AFTER_TAP;
        }
 
        if (start_recording) {
@@ -586,6 +590,10 @@ bool CWakeupManager::process_plugin_event(mas_plugin_event_e event, void* data,
                }
        }
 
+       if (next_voice_key_status) {
+               change_voice_key_status(*next_voice_key_status);
+       }
+
        MWR_LOGD("[END]");
        return true;
 }