pal: remove redundant 2nd stage output level set
2nd stage output level is set to voice ui interface
in every loop of second stage processing which is
not needed.
Set 2nd stage output level only when second stage
detection/rejection comes.
Change-Id: I5b4daeae82891c69490e4ffac978d20529ec3d1f
diff --git a/session/src/SoundTriggerEngineCapi.cpp b/session/src/SoundTriggerEngineCapi.cpp
index 4ae520f..6ffa7f4 100644
--- a/session/src/SoundTriggerEngineCapi.cpp
+++ b/session/src/SoundTriggerEngineCapi.cpp
@@ -310,6 +310,7 @@
goto exit;
}
+ det_conf_score_ = result_cfg_ptr->best_confidence;
if (result_cfg_ptr->is_detected) {
exit_buffering_ = true;
detection_state_ = KEYWORD_DETECTION_SUCCESS;
@@ -317,15 +318,16 @@
buffer_start_, &start_idx);
__builtin_add_overflow(result_cfg_ptr->end_position * CNN_FRAME_SIZE,
buffer_start_, &end_idx);
+ vui_intf_->SetSecondStageDetLevels(stream_handle_,
+ engine_type_, det_conf_score_);
PAL_INFO(LOG_TAG, "KW Second Stage Detected, start index %zu, end index %zu",
start_idx, end_idx);
} else if (bytes_processed_ >= buffer_end_ - buffer_start_) {
detection_state_ = KEYWORD_DETECTION_REJECT;
+ vui_intf_->SetSecondStageDetLevels(stream_handle_,
+ engine_type_, det_conf_score_);
PAL_INFO(LOG_TAG, "KW Second Stage rejected");
}
- det_conf_score_ = result_cfg_ptr->best_confidence;
- vui_intf_->SetSecondStageDetLevels(stream_handle_,
- engine_type_, det_conf_score_);
PAL_INFO(LOG_TAG, "KW second stage conf level %d", det_conf_score_);
if (!first_buffer_processed) {
@@ -586,17 +588,19 @@
goto exit;
}
+ det_conf_score_ = (int32_t)result_cfg_ptr->final_user_score;
if (result_cfg_ptr->is_detected) {
exit_buffering_ = true;
detection_state_ = USER_VERIFICATION_SUCCESS;
+ vui_intf_->SetSecondStageDetLevels(stream_handle_,
+ engine_type_, det_conf_score_);
PAL_INFO(LOG_TAG, "UV Second Stage Detected");
} else if (bytes_processed_ >= buffer_end_ - buffer_start_) {
detection_state_ = USER_VERIFICATION_REJECT;
+ vui_intf_->SetSecondStageDetLevels(stream_handle_,
+ engine_type_, det_conf_score_);
PAL_INFO(LOG_TAG, "UV Second Stage Rejected");
}
- det_conf_score_ = (int32_t)result_cfg_ptr->final_user_score;
- vui_intf_->SetSecondStageDetLevels(stream_handle_,
- engine_type_, det_conf_score_);
PAL_INFO(LOG_TAG, "UV second stage conf level %d", det_conf_score_);
}
diff --git a/utils/src/CustomInterface.cpp b/utils/src/CustomInterface.cpp
index 2e26510..270e96f 100644
--- a/utils/src/CustomInterface.cpp
+++ b/utils/src/CustomInterface.cpp
@@ -461,8 +461,18 @@
listen_model_indicator_enum type,
uint32_t level) {
+ bool sec_det_level_exist = false;
+
if (sm_info_map_.find(s) != sm_info_map_.end() && sm_info_map_[s]) {
- sm_info_map_[s]->sec_det_level.push_back(std::make_pair(type, level));
+ for (auto &iter: sm_info_map_[s]->sec_det_level) {
+ if (iter.first == type) {
+ iter.second = level;
+ sec_det_level_exist = true;
+ break;
+ }
+ }
+ if (!sec_det_level_exist)
+ sm_info_map_[s]->sec_det_level.push_back(std::make_pair(type, level));
} else {
PAL_ERR(LOG_TAG, "Stream not registered to interface");
}
@@ -1658,7 +1668,7 @@
sm_info->info->GetConfLevelsSize(), j);
PAL_INFO(LOG_TAG, "First stage KW Conf levels[%d]-%d",
- j, sm_info->info->GetDetConfLevels()[j])
+ j, sm_info->info->GetDetConfLevels()[j]);
num_user_levels =
conf_levels_v2->conf_levels[i].kw_levels[j].num_user_levels;
@@ -1673,7 +1683,7 @@
sm_info->info->GetConfLevelsSize(), user_id);
PAL_INFO(LOG_TAG, "First stage User Conf levels[%d]-%d",
- k, sm_info->info->GetDetConfLevels()[user_id])
+ k, sm_info->info->GetDetConfLevels()[user_id]);
}
}
} else if (conf_levels_v2->conf_levels[i].sm_id & ST_SM_ID_SVA_S_STAGE_KWD ||
diff --git a/utils/src/SVAInterface.cpp b/utils/src/SVAInterface.cpp
index 3580118..8312f18 100644
--- a/utils/src/SVAInterface.cpp
+++ b/utils/src/SVAInterface.cpp
@@ -380,8 +380,18 @@
listen_model_indicator_enum type,
uint32_t level) {
+ bool sec_det_level_exist = false;
+
if (sm_info_map_.find(s) != sm_info_map_.end() && sm_info_map_[s]) {
- sm_info_map_[s]->sec_det_level.push_back(std::make_pair(type, level));
+ for (auto &iter: sm_info_map_[s]->sec_det_level) {
+ if (iter.first == type) {
+ iter.second = level;
+ sec_det_level_exist = true;
+ break;
+ }
+ }
+ if (!sec_det_level_exist)
+ sm_info_map_[s]->sec_det_level.push_back(std::make_pair(type, level));
} else {
PAL_ERR(LOG_TAG, "Stream not registered to interface");
}
@@ -1560,7 +1570,7 @@
sm_info->info->GetConfLevelsSize(), j);
PAL_INFO(LOG_TAG, "First stage KW Conf levels[%d]-%d",
- j, sm_info->info->GetDetConfLevels()[j])
+ j, sm_info->info->GetDetConfLevels()[j]);
num_user_levels =
conf_levels_v2->conf_levels[i].kw_levels[j].num_user_levels;
@@ -1575,7 +1585,7 @@
sm_info->info->GetConfLevelsSize(), user_id);
PAL_INFO(LOG_TAG, "First stage User Conf levels[%d]-%d",
- k, sm_info->info->GetDetConfLevels()[user_id])
+ k, sm_info->info->GetDetConfLevels()[user_id]);
}
}
} else if (conf_levels_v2->conf_levels[i].sm_id & ST_SM_ID_SVA_S_STAGE_KWD ||
diff --git a/utils/src/VoiceUIInterface.cpp b/utils/src/VoiceUIInterface.cpp
index 87b76e2..b2ca427 100644
--- a/utils/src/VoiceUIInterface.cpp
+++ b/utils/src/VoiceUIInterface.cpp
@@ -159,6 +159,8 @@
free(sm_info_map_[s]->wakeup_config);
if (sm_info_map_[s]->info)
delete(sm_info_map_[s]->info);
+ sm_info_map_[s]->sec_threshold.clear();
+ sm_info_map_[s]->sec_det_level.clear();
free(sm_info_map_[s]);
sm_info_map_.erase(iter);
} else {