Quiet Drive (#17)

This commit is contained in:
Jason Wen
2023-02-05 14:08:29 -05:00
committed by GitHub
parent 6ec1b029b9
commit ff1eebcc47
3 changed files with 12 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

+8 -1
View File
@@ -68,10 +68,17 @@ void Sound::setAlert(const Alert &alert) {
}
// play sound
if (alert.sound != AudibleAlert::NONE) {
if (shouldPlaySound(alert)) {
auto &[s, loops] = sounds[alert.sound];
s->setLoopCount(loops);
s->play();
}
}
}
bool Sound::shouldPlaySound(const Alert &alert) {
bool isQuietDrive = params.getBool("QuietDrive");
return (alert.sound == AudibleAlert::WARNING_SOFT || alert.sound == AudibleAlert::WARNING_IMMEDIATE ||
alert.sound == AudibleAlert::PROMPT_DISTRACTED || alert.sound == AudibleAlert::PROMPT_REPEAT) ||
(!isQuietDrive && alert.sound != AudibleAlert::NONE);
}
+4
View File
@@ -26,9 +26,13 @@ public:
protected:
void update();
void setAlert(const Alert &alert);
bool shouldPlaySound(const Alert &alert);
Alert current_alert = {};
QMap<AudibleAlert, QPair<QSoundEffect *, int>> sounds;
SubMaster sm;
uint64_t started_frame;
private:
Params params;
};