diff --git a/selfdrive/ui/soundd.cc b/selfdrive/ui/soundd.cc index 28288d6f75..f6d3cfc597 100644 --- a/selfdrive/ui/soundd.cc +++ b/selfdrive/ui/soundd.cc @@ -121,13 +121,15 @@ void test_sound() { } void run_test(Sound *sound) { - static QMap stats; + static QMap> stats; for (auto i = sound->sounds.constBegin(); i != sound->sounds.constEnd(); ++i) { QObject::connect(i.value().first, &QSoundEffect::playingChanged, [s = i.value().first, a = i.key()]() { if (s->isPlaying()) { bool repeat = a == AudibleAlert::CHIME_WARNING_REPEAT || a == AudibleAlert::CHIME_WARNING2_REPEAT; assert(s->loopsRemaining() == repeat ? QSoundEffect::Infinite : 1); - stats[a]++; + stats[a].first++; + } else { + stats[a].second++; } }); } @@ -135,8 +137,8 @@ void run_test(Sound *sound) { QThread *t = new QThread(qApp); QObject::connect(t, &QThread::started, [=]() { test_sound(); }); QObject::connect(t, &QThread::finished, [&]() { - for (int n : stats) { - assert(n == test_loop_cnt); + for (auto [play, stop] : stats) { + assert(play == test_loop_cnt && stop == test_loop_cnt); } qApp->quit(); });