mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-09-27 15:23:52 +08:00
Quiet Drive (#17)
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user