setvolumne on change

pull/22796/head
deanlee 4 years ago
parent c3e5eba4d0
commit e2b4233adf
  1. 4
      selfdrive/ui/soundd.cc

@ -54,10 +54,13 @@ public:
// scale volume with speed // scale volume with speed
float volume = util::map_val(sm["carState"].getCarState().getVEgo(), 0.f, 20.f, float volume = util::map_val(sm["carState"].getCarState().getVEgo(), 0.f, 20.f,
Hardware::MIN_VOLUME, Hardware::MAX_VOLUME); Hardware::MIN_VOLUME, Hardware::MAX_VOLUME);
if (current_volume != volume) {
current_volume = volume;
for (auto &[s, loops] : sounds) { for (auto &[s, loops] : sounds) {
s->setVolume(std::round(100 * volume) / 100); s->setVolume(std::round(100 * volume) / 100);
} }
} }
}
auto alert = get_alert(sm, 1); auto alert = get_alert(sm, 1);
if (alert) { if (alert) {
@ -92,6 +95,7 @@ public:
private: private:
AudibleAlert current_sound = AudibleAlert::NONE; AudibleAlert current_sound = AudibleAlert::NONE;
QString current_alert_type; QString current_alert_type;
float current_volume = 0.;
QMap<AudibleAlert, QPair<QSoundEffect*, int>> sounds; QMap<AudibleAlert, QPair<QSoundEffect*, int>> sounds;
SubMaster sm; SubMaster sm;

Loading…
Cancel
Save