@@ -865,6 +865,14 @@ void Manager::OnConversationalAwarenessChanged(bool enable)
865865 }
866866}
867867
868+ void Manager::OnConversationalAwarenessVolumePercentChanged (uint8_t percent)
869+ {
870+ std::lock_guard<std::mutex> lock{_mutex};
871+ // Clamp the value to valid range (10-100) matching UI slider constraints
872+ _conversationalAwarenessVolumePercent = std::clamp (percent, uint8_t {10 }, uint8_t {100 });
873+ LOG (Info, " Conversational awareness volume percent changed to {}%" , _conversationalAwarenessVolumePercent);
874+ }
875+
868876void Manager::OnPersonalizedVolumeChanged (bool enable)
869877{
870878 std::lock_guard<std::mutex> lock{_mutex};
@@ -910,6 +918,9 @@ void Manager::OnNoiseControlModeNotification(AAP::NoiseControlMode mode)
910918{
911919 LOG (Info, " Noise control mode changed to: {}" , Helper::ToString (mode).toStdString ());
912920
921+ // Track the current noise control mode
922+ _currentNoiseControlMode = mode;
923+
913924 // Update the cached state in the state manager if we have a current state
914925 auto state = _stateMgr.GetCurrentState ();
915926 if (state.has_value ()) {
@@ -968,20 +979,29 @@ void Manager::OnHeadTrackingData(AAP::HeadTrackingData data)
968979}
969980
970981// Volume levels for conversational awareness
971- constexpr int kConversationalAwarenessVolumePercent = 40 ; // Volume when user is speaking
972- constexpr int kFullVolumePercent = 100 ; // Normal volume when not speaking
982+ // kFullVolumePercent (100) signals to GlobalMedia::SetVolume to restore the saved pre-speaking volume
983+ // The actual restoration logic is in GlobalMedia_win.cpp which restores to the saved volume, not literally 100%
984+ constexpr int kFullVolumePercent = 100 ; // Signal value to restore to original volume
973985
974986void Manager::OnSpeakingLevelChanged (AAP::SpeakingLevel level)
975987{
976988 if (!_conversationalAwarenessEnabled) {
977989 return ;
978990 }
979991
992+ // Disable conversational awareness in transparency mode to avoid volume restoration bugs
993+ // The AAP firmware in transparency mode doesn't reliably send restoration events
994+ if (_currentNoiseControlMode.has_value () &&
995+ _currentNoiseControlMode.value () == AAP::NoiseControlMode::Transparency) {
996+ LOG (Info, " Conversational awareness disabled in transparency mode to avoid volume bugs" );
997+ return ;
998+ }
999+
9801000 switch (level) {
9811001 case AAP::SpeakingLevel::StartedSpeaking_GreatlyReduce:
9821002 case AAP::SpeakingLevel::StartedSpeaking_GreatlyReduce2:
983- LOG (Info, " User started speaking - reducing media volume to {}%" , kConversationalAwarenessVolumePercent );
984- Core::GlobalMedia::SetVolume (kConversationalAwarenessVolumePercent );
1003+ LOG (Info, " User started speaking - reducing media volume to {}%" , _conversationalAwarenessVolumePercent );
1004+ Core::GlobalMedia::SetVolume (_conversationalAwarenessVolumePercent );
9851005 break ;
9861006
9871007 case AAP::SpeakingLevel::StoppedSpeaking:
@@ -992,7 +1012,12 @@ void Manager::OnSpeakingLevelChanged(AAP::SpeakingLevel level)
9921012 break ;
9931013
9941014 default :
995- // Intermediate levels - could implement gradual volume adjustment
1015+ // Intermediate levels (0x04-0x07) - restore volume to be safe
1016+ // This ensures volume is restored even if final event is missed
1017+ if (static_cast <uint8_t >(level) >= 0x04 && static_cast <uint8_t >(level) <= 0x07 ) {
1018+ LOG (Info, " Intermediate speaking level detected - restoring media volume" );
1019+ Core::GlobalMedia::SetVolume (kFullVolumePercent );
1020+ }
9961021 break ;
9971022 }
9981023}
0 commit comments