diff --git a/selfdrive/ui/sound.cc b/selfdrive/ui/sound.cc index 701fa56b4..9acf92523 100644 --- a/selfdrive/ui/sound.cc +++ b/selfdrive/ui/sound.cc @@ -13,12 +13,17 @@ extern "C"{ #include "slplay.h" } +int last_volume = 0; + void set_volume(int volume) { - char volume_change_cmd[64]; - sprintf(volume_change_cmd, "service call audio 3 i32 3 i32 %d i32 1 &", volume); + if (last_volume != volume) { + char volume_change_cmd[64]; + sprintf(volume_change_cmd, "service call audio 3 i32 3 i32 %d i32 1 &", volume); - // 5 second timeout at 60fps - int volume_changed = system(volume_change_cmd); + // 5 second timeout at 60fps + int volume_changed = system(volume_change_cmd); + last_volume = volume; + } }