only run system() command when vol has changed (#1148)

* only run system command when vol has changed

* fix indent
old-commit-hash: 4311550293
vw-mqb-aeb
eFini 5 years ago committed by GitHub
parent 3f5d11ff3b
commit 02ad0e743e
  1. 13
      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;
}
}

Loading…
Cancel
Save