From: Ji-hoon Lee Date: Thu, 23 Jun 2022 06:20:45 +0000 (+0900) Subject: Support checking recording_by_voice_key state for TTT X-Git-Tag: accepted/tizen/unified/20220715.141411~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ecf20243343953be45e556f024681e2116012ace;p=platform%2Fcore%2Fuifw%2Fmulti-assistant-service.git Support checking recording_by_voice_key state for TTT Change-Id: Ie91e1ece1e9eeb459b1ec18d3d22703bddbc1240 --- diff --git a/plugins/wakeup-manager/inc/wakeup_manager.h b/plugins/wakeup-manager/inc/wakeup_manager.h index 0eae063..267216f 100644 --- a/plugins/wakeup-manager/inc/wakeup_manager.h +++ b/plugins/wakeup-manager/inc/wakeup_manager.h @@ -108,7 +108,8 @@ public: bool get_audio_format(int* rate, int* channel, int* audio_type); bool get_audio_source_type(char** type); bool set_language(string language); - bool get_voice_key_pressed(); + bool get_recording_by_voice_key(); + void set_recording_by_voice_key(bool recording); bool set_voice_key_tap_duration(float duration); bool unset_voice_key_tap_duration(); bool set_voice_key_support_mode(VOICE_KEY_SUPPORT_MODE mode); @@ -150,8 +151,6 @@ public: void stop_periodic_monitor_timer(); private: - bool change_voice_key_status(ma_voice_key_status_e status); - class CEngineEventObserver : public IEngineEventObserver { public: @@ -235,7 +234,8 @@ private: thread mEngineDataThread; atomic_bool mStopEngineDataThread{false}; - bool mVoiceKeyPressed{false}; + bool mRecordingByVoiceKey{false}; + string mCurrentLanguage; string mCurrentDefaultAssistant; /* Assume Push-to-talk is the default mode */ diff --git a/plugins/wakeup-manager/src/wakeup_manager.cpp b/plugins/wakeup-manager/src/wakeup_manager.cpp index 82537ba..b209f8f 100644 --- a/plugins/wakeup-manager/src/wakeup_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager.cpp @@ -218,6 +218,7 @@ bool CWakeupManager::deactivate(void) return false; mAudioManager.stop_recording(true); + mRecordingByVoiceKey = false; change_manager_state(WAKEUP_MANAGER_STATE_INACTIVE); stop_streaming_utterance_data(); @@ -426,9 +427,14 @@ bool CWakeupManager::set_language(string language) return valid; } -bool CWakeupManager::get_voice_key_pressed() +bool CWakeupManager::get_recording_by_voice_key() { - return mVoiceKeyPressed; + return mRecordingByVoiceKey; +} + +void CWakeupManager::set_recording_by_voice_key(bool recording) +{ + mRecordingByVoiceKey = recording; } STREAMING_MODE CWakeupManager::get_streaming_mode() @@ -536,20 +542,6 @@ static long long get_current_milliseconds_after_epoch() return value.count(); } -bool CWakeupManager::change_voice_key_status(ma_voice_key_status_e status) { - for (const auto& observer : mWakeupObservers) { - observer->on_voice_key_status_changed(status); - } - if (MA_VOICE_KEY_STATUS_PRESSED == status) { - mVoiceKeyPressed = true; - } else if ( - MA_VOICE_KEY_STATUS_RELEASED_AFTER_PUSH == status || - MA_VOICE_KEY_STATUS_RELEASED_AFTER_TAP == status) { - mVoiceKeyPressed = false; - } - return true; -} - bool CWakeupManager::process_plugin_event(mas_plugin_event_e event, void* data, int len) { MWR_LOGE("[ENTER] : %d", event); @@ -583,6 +575,8 @@ bool CWakeupManager::process_plugin_event(mas_plugin_event_e event, void* data, } if (start_recording) { + mRecordingByVoiceKey = true; + mAudioManager.stop_recording(true); stop_streaming_utterance_data(); @@ -616,6 +610,8 @@ bool CWakeupManager::process_plugin_event(mas_plugin_event_e event, void* data, } } if (stop_recording) { + mRecordingByVoiceKey = false; + stop_streaming_duration_timer(); mAudioManager.finalize_audio_data(); @@ -634,7 +630,9 @@ 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); + for (const auto& observer : mWakeupObservers) { + observer->on_voice_key_status_changed(*next_voice_key_status); + } } MWR_LOGD("[END]"); @@ -681,6 +679,7 @@ static Eina_Bool streaming_duration_expired(void *data) case STREAMING_MODE::FOLLOW_UP: audio_manager->stop_streaming_follow_up_data(); audio_manager->stop_recording(true); + wakeup_manager->set_recording_by_voice_key(false); audio_manager->clear_audio_data(); break; } @@ -689,6 +688,7 @@ static Eina_Bool streaming_duration_expired(void *data) if (WAKEUP_MANAGER_STATE_UTTERANCE == wakeup_manager->get_manager_state()) { audio_manager->stop_recording(true); + wakeup_manager->set_recording_by_voice_key(false); audio_manager->set_recording_session(RECORDING_SESSION_WAKE_WORD); if (engine_manager->get_audio_data_required()) { /* Restart recorder thread using appropriate recording device */ @@ -741,6 +741,7 @@ bool CWakeupManager::stop_streaming_utterance_data() if (WAKEUP_MANAGER_STATE_UTTERANCE == mWakeupManagerState) { change_manager_state(WAKEUP_MANAGER_STATE_PROCESSING); mAudioManager.stop_recording(true); + mRecordingByVoiceKey = false; mAudioManager.set_recording_session(RECORDING_SESSION_WAKE_WORD); if (mWakeupEngineManager.get_audio_data_required()) { /* Restart recorder thread using appropriate recording device */ @@ -794,6 +795,7 @@ bool CWakeupManager::stop_streaming_follow_up_data() if (WAKEUP_MANAGER_STATE_UTTERANCE == mWakeupManagerState) { change_manager_state(WAKEUP_MANAGER_STATE_PROCESSING); mAudioManager.stop_recording(true); + mRecordingByVoiceKey = false; mAudioManager.set_recording_session(RECORDING_SESSION_WAKE_WORD); if (mWakeupEngineManager.get_audio_data_required()) { /* Restart recorder thread using appropriate recording device */ @@ -1070,12 +1072,12 @@ bool CWakeupManager::CEngineEventObserver::on_audio_data_require_status(string e if (audio_manager && engine_manager) { if (engine_manager->get_audio_data_required()) { - if (mWakeupManager->get_voice_key_pressed() != true) { + if (mWakeupManager->get_recording_by_voice_key() != true) { audio_manager->set_recording_session(RECORDING_SESSION_WAKE_WORD); audio_manager->start_recording(true); } } else { - if (mWakeupManager->get_voice_key_pressed() != true) { + if (mWakeupManager->get_recording_by_voice_key() != true) { audio_manager->stop_recording(true); } } @@ -1164,7 +1166,7 @@ bool CWakeupManager::CAudioEventObserver::on_recording_audio_data(long time, voi if (false == mEngineManager->get_audio_data_required()) return false; - if (mWakeupManager->get_voice_key_pressed() != true) { + if (mWakeupManager->get_recording_by_voice_key() != true) { /* When follow-up streaming in progress, no need to feed audio data to wakeup engines */ if (STREAMING_MODE::FOLLOW_UP != mWakeupManager->get_streaming_mode()) { mEngineManager->engine_feed_audio_data(time, data, len);