mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-29 02:22:09 +08:00
soundd: Set volume on receiving carState (#22795)
old-commit-hash: 6d9b414c200f21d40134422b35b2b94f7ffdfe3f
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user