bool set_assistant_enabled(string appid, bool enabled);
bool get_assistant_enabled(string appid);
bool set_default_assistant(string appid);
- bool process_default_assistant_changed(string appid);
+ bool process_default_assistant_changed(string appid, bool expected);
string get_default_assistant();
bool update_voice_feedback_state(string appid, bool state);
void set_streaming_duration_timer(Ecore_Timer* timer);
Ecore_Timer* get_streaming_duration_timer();
+
+ void start_periodic_monitor_timer();
+ void stop_periodic_monitor_timer();
+
private:
bool change_voice_key_status(ma_voice_key_status_e status);
STREAMING_MODE mStreamingMode{STREAMING_MODE::NONE};
Ecore_Timer* mStreamingDurationTimer{nullptr};
+ Ecore_Timer* mPeriodicMonitorTimer{nullptr};
wakeup_manager_state_e mWakeupManagerState{WAKEUP_MANAGER_STATE_INACTIVE};
#include "dependency_resolver.h"
#include <algorithm>
+#include <iostream>
#include <boost/optional.hpp>
bool CWakeupManager::initialize()
{
MWR_LOGE("[ENTER]");
+ std::cerr << "WakeupManager Initialize" << std::endl;
mPolicyEventObserver.set_wakeup_manager(this);
mEngineEventObserver.set_wakeup_manager(this);
dependency_resolver_initialize(interface);
initialize_wakeup_policy();
+ start_periodic_monitor_timer();
MWR_LOGD("[END]");
return true;
bool CWakeupManager::deinitialize()
{
MWR_LOGE("[ENTER]");
+ std::cerr << "WakeupManager Deinitialize" << std::endl;
+ stop_periodic_monitor_timer();
stop_streaming_duration_timer();
dependency_resolver_deinitialize();
{
MWR_LOGE("[ENTER] %s %s", appid.c_str(), mCurrentDefaultAssistant.c_str());
- process_default_assistant_changed(appid);
+ /* Passing 'expected' as true since MAS is changing the default assistant config */
+ process_default_assistant_changed(appid, true);
mWakeupSettings.set_default_assistant_appid(appid);
return true;
}
-bool CWakeupManager::process_default_assistant_changed(string appid)
+bool CWakeupManager::process_default_assistant_changed(string appid, bool expected)
{
MWR_LOGE("[ENTER] %s %s", appid.c_str(), mCurrentDefaultAssistant.c_str());
if (mWakeupManagerState == WAKEUP_MANAGER_STATE_UTTERANCE ||
mWakeupManagerState == WAKEUP_MANAGER_STATE_PROCESSING) {
- update_recognition_result(mCurrentDefaultAssistant, MA_RECOGNITION_RESULT_EVENT_ERROR);
+ if (expected) {
+ stop_streaming_utterance_data();
+ stop_streaming_previous_utterance_data();
+ stop_streaming_follow_up_data();
+
+ mWakeupEngineManager.update_recognition_result(appid, MA_RECOGNITION_RESULT_EVENT_ERROR);
+ } else {
+ /* If this is an unexpected change, invalidate previous recognition process */
+ update_recognition_result(mCurrentDefaultAssistant, MA_RECOGNITION_RESULT_EVENT_ERROR);
+ }
}
/* Check if previous default assistant has to be deactivated */
void CWakeupManager::feed_audio_data(mas_speech_streaming_event_e event, void* buffer, int len)
{
+ const std::chrono::seconds interval(5);
+ static auto last = std::chrono::steady_clock::now();
+ auto now = std::chrono::steady_clock::now();
+ if (now - last > interval) {
+ std::cerr << "Feeding Audio : " << len << std::endl;
+ last = now;
+ }
+
mAudioManager.feed_audio_data(event, buffer, len);
}
mWakeupEngineManager.engine_set_dependency_module_command(engine_name, command);
}
+static Eina_Bool periodic_monitor_func(void *data)
+{
+ std::cerr << "MAS PERIODIC HEALTH CHECK" << std::endl;
+ return ECORE_CALLBACK_RENEW;
+}
+
+void CWakeupManager::start_periodic_monitor_timer()
+{
+ MWR_LOGI("MONITOR_TIMER START");
+ mPeriodicMonitorTimer = ecore_timer_add(
+ 30.0f,
+ periodic_monitor_func, nullptr);
+}
+
+void CWakeupManager::stop_periodic_monitor_timer()
+{
+ if (mPeriodicMonitorTimer) {
+ ecore_timer_del(mPeriodicMonitorTimer);
+ mPeriodicMonitorTimer = nullptr;
+ }
+}
+
void CWakeupManager::start_streaming_duration_timer()
{
MWR_LOGI("DURATION_TIMER START");
const char* appid)
{
if (nullptr == mWakeupManager || nullptr == appid) return false;
- mWakeupManager->process_default_assistant_changed(std::string(appid));
+ /* Passing 'expected' as false since the change was occurred outside of MAS */
+ mWakeupManager->process_default_assistant_changed(std::string(appid), false);
vector<ISettingValueObserver*> observers = mWakeupManager->get_setting_observers();
for (const auto& observer : observers) {
observer->on_value_changed();