mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 08:14:00 +08:00
only run system() command when vol has changed (#1148)
* only run system command when vol has changed * fix indent old-commit-hash: 431155029399e904258d6e7b525ebec037ae608c
This commit is contained in:
+10
-5
@@ -13,12 +13,17 @@ extern "C"{
|
||||
#include "slplay.h"
|
||||
}
|
||||
|
||||
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);
|
||||
int last_volume = 0;
|
||||
|
||||
// 5 second timeout at 60fps
|
||||
int volume_changed = system(volume_change_cmd);
|
||||
void set_volume(int 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);
|
||||
last_volume = volume;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user