setvolumne on change

pull/22796/head
deanlee 4 years ago
parent c3e5eba4d0
commit e2b4233adf
  1. 8
      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<AudibleAlert, QPair<QSoundEffect*, int>> sounds;
SubMaster sm;

Loading…
Cancel
Save