From e2b4233adf0b623fafe6c519340d8da342117d33 Mon Sep 17 00:00:00 2001 From: deanlee Date: Sat, 6 Nov 2021 08:01:51 +0800 Subject: [PATCH] setvolumne on change --- selfdrive/ui/soundd.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/soundd.cc b/selfdrive/ui/soundd.cc index d44fcfe11e..2292b6cde3 100644 --- a/selfdrive/ui/soundd.cc +++ b/selfdrive/ui/soundd.cc @@ -54,8 +54,11 @@ public: // scale volume with speed float volume = util::map_val(sm["carState"].getCarState().getVEgo(), 0.f, 20.f, Hardware::MIN_VOLUME, Hardware::MAX_VOLUME); - for (auto &[s, loops] : sounds) { - s->setVolume(std::round(100 * volume) / 100); + if (current_volume != volume) { + current_volume = volume; + for (auto &[s, loops] : sounds) { + s->setVolume(std::round(100 * volume) / 100); + } } } @@ -92,6 +95,7 @@ public: private: AudibleAlert current_sound = AudibleAlert::NONE; QString current_alert_type; + float current_volume = 0.; QMap> sounds; SubMaster sm;