soundd: set volume on changes (#29389)
* set volume on change * async set volumn * Revert "async set volumn" This reverts commit 7bc88c498353fff158b0de3d1923aa2c0f004a37. old-commit-hash: 55c156dfb25d4cc594524d197a588a929a99f01f
This commit is contained in:
@@ -36,7 +36,10 @@ void Sound::update() {
|
||||
if (sm.updated("microphone")) {
|
||||
float volume = util::map_val(sm["microphone"].getMicrophone().getFilteredSoundPressureWeightedDb(), 30.f, 60.f, 0.f, 1.f);
|
||||
volume = QAudio::convertVolume(volume, QAudio::LogarithmicVolumeScale, QAudio::LinearVolumeScale);
|
||||
Hardware::set_volume(volume);
|
||||
// set volume on changes
|
||||
if (std::exchange(current_volume, std::nearbyint(volume * 10)) != current_volume) {
|
||||
Hardware::set_volume(volume);
|
||||
}
|
||||
}
|
||||
|
||||
setAlert(Alert::get(sm, 0));
|
||||
|
||||
@@ -30,4 +30,5 @@ protected:
|
||||
SubMaster sm;
|
||||
Alert current_alert = {};
|
||||
QMap<AudibleAlert, QPair<QSoundEffect *, int>> sounds;
|
||||
int current_volume = -1;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user