mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-06 22:22:11 +08:00
soundd: fix test case (#23075)
* init sound_stats * send deviceState msg old-commit-hash: eb0724d7e3bff078f803d45d5d305b5f793c8f22
This commit is contained in:
@@ -9,6 +9,7 @@ class TestSound : public Sound {
|
||||
public:
|
||||
TestSound() : Sound() {
|
||||
for (auto i = sounds.constBegin(); i != sounds.constEnd(); ++i) {
|
||||
sound_stats[i.key()] = {0, 0};
|
||||
QObject::connect(i.value().first, &QSoundEffect::playingChanged, [=, s = i.value().first, a = i.key()]() {
|
||||
if (s->isPlaying()) {
|
||||
sound_stats[a].first++;
|
||||
@@ -23,7 +24,11 @@ public:
|
||||
};
|
||||
|
||||
void controls_thread(int loop_cnt) {
|
||||
PubMaster pm({"controlsState"});
|
||||
PubMaster pm({"controlsState", "deviceState"});
|
||||
MessageBuilder deviceStateMsg;
|
||||
auto deviceState = deviceStateMsg.initEvent().initDeviceState();
|
||||
deviceState.setStarted(true);
|
||||
|
||||
const int DT_CTRL = 10; // ms
|
||||
for (int i = 0; i < loop_cnt; ++i) {
|
||||
for (auto &[alert, fn, loops] : sound_list) {
|
||||
@@ -34,6 +39,7 @@ void controls_thread(int loop_cnt) {
|
||||
cs.setAlertSound(alert);
|
||||
cs.setAlertType(fn.toStdString());
|
||||
pm.send("controlsState", msg);
|
||||
pm.send("deviceState", deviceStateMsg);
|
||||
QThread::msleep(DT_CTRL);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user