mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-09-29 19:03:51 +08:00
only run system() command when vol has changed (#1148)
* only run system command when vol has changed * fix indent
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