soundd: Set volume on receiving carState (#22795)

pull/22797/head
Willem Melching 4 years ago committed by GitHub
parent ee33f8a8cd
commit 6d9b414c20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      selfdrive/ui/soundd.cc

@ -63,6 +63,9 @@ private slots:
// scale volume with speed
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 (sm->updated("controlsState")) {
const cereal::ControlsState::Reader &cs = (*sm)["controlsState"].getControlsState();
@ -91,7 +94,6 @@ private slots:
if (alert.sound != AudibleAlert::NONE) {
auto &[s, loops] = sounds[alert.sound];
s->setLoopCount(loops);
s->setVolume(volume);
s->play();
}
}

Loading…
Cancel
Save