Skip to content

Commit fd5bcf6

Browse files
Address code review feedback: use std::clamp and improve comments
Co-authored-by: YimingZhanshen <76594627+YimingZhanshen@users.noreply.github.com>
1 parent 8e87d94 commit fd5bcf6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Source/Core/AirPods.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -868,11 +868,9 @@ void Manager::OnConversationalAwarenessChanged(bool enable)
868868
void Manager::OnConversationalAwarenessVolumePercentChanged(uint8_t percent)
869869
{
870870
std::lock_guard<std::mutex> lock{_mutex};
871-
// Clamp the value to valid range (1-100)
872-
if (percent < 1) percent = 1;
873-
if (percent > 100) percent = 100;
874-
_conversationalAwarenessVolumePercent = percent;
875-
LOG(Info, "Conversational awareness volume percent changed to {}%", percent);
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);
876874
}
877875

878876
void Manager::OnPersonalizedVolumeChanged(bool enable)
@@ -978,8 +976,9 @@ void Manager::OnHeadTrackingData(AAP::HeadTrackingData data)
978976
}
979977

980978
// Volume levels for conversational awareness
981-
// kFullVolumePercent is used to restore to the original volume (before speaking)
982-
constexpr int kFullVolumePercent = 100; // Normal volume when not speaking
979+
// kFullVolumePercent (100) signals to GlobalMedia::SetVolume to restore the saved pre-speaking volume
980+
// The actual restoration logic is in GlobalMedia_win.cpp which restores to the saved volume, not literally 100%
981+
constexpr int kFullVolumePercent = 100; // Signal value to restore to original volume
983982

984983
void Manager::OnSpeakingLevelChanged(AAP::SpeakingLevel level)
985984
{

Source/Gui/MainWindow.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ void MainWindow::PlayAnimation()
479479
// Reinitialize video widget rendering surface after hide/show cycle
480480
// This is critical for x64 builds to prevent transparent/hollow video area
481481
// Force recreation of the native window handle to ensure proper rendering
482-
_videoWidget->winId(); // Force native window creation
482+
// Calling winId() for its side effect - it creates/retrieves the native window handle
483+
(void)_videoWidget->winId();
483484
_mediaPlayer->setVideoOutput(nullptr);
484485
_mediaPlayer->setVideoOutput(_videoWidget);
485486
_mediaPlayer->play();

0 commit comments

Comments
 (0)