Add retry mechanism for volume write (#3121)

This commit is contained in:
qwer123
2026-04-10 14:33:48 +08:00
committed by GitHub
parent ef2ae9874b
commit fc18992442
6 changed files with 34 additions and 26 deletions
+9 -2
View File
@@ -225,8 +225,15 @@ volume_range_t volume_range() {
return audio_codec->headphone_gain_range();
}
void set_volume(const volume_t volume) {
audio_codec->set_headphone_volume(volume);
bool set_volume(const volume_t volume) {
// add retry method
for (int i = 0; i < 100; ++i) {
if (audio_codec->set_headphone_volume(volume)) {
return true;
}
chThdSleepMilliseconds(2);
}
return false;
}
} /* namespace headphone */