Stop playing if nobody's listening

This commit is contained in:
Allen Hill
2026-06-18 15:56:30 -07:00
parent 26b0d6c55f
commit 95925b563a
2 changed files with 8 additions and 0 deletions
+1
View File
@@ -218,6 +218,7 @@ AVCLAN_frame_t *AVCLAN_getStatusFrame();
void AVCLAN_generateStatus(AVCLAN_frame_t *status, bool is_unicast, devices to); void AVCLAN_generateStatus(AVCLAN_frame_t *status, bool is_unicast, devices to);
bool AVCLAN_isPlaying(); bool AVCLAN_isPlaying();
void AVCLAN_stopPlaying();
void AVCLAN_incrementTime(); void AVCLAN_incrementTime();
void AVCLAN_setTime(uint8_t mins, uint8_t secs); void AVCLAN_setTime(uint8_t mins, uint8_t secs);
void AVCLAN_normalizeState(); void AVCLAN_normalizeState();
+7
View File
@@ -110,6 +110,7 @@ int main() {
uint8_t seqIdx = 0; // current index in data_tmp uint8_t seqIdx = 0; // current index in data_tmp
uint8_t err = 0; uint8_t err = 0;
uint8_t failedStatusReports = 0;
for (uint8_t i = 0; i < CACHE_SIZE; ++i) { for (uint8_t i = 0; i < CACHE_SIZE; ++i) {
frames[i].control = 0x0f; frames[i].control = 0x0f;
@@ -169,6 +170,12 @@ int main() {
err = AVCLAN_sendframe( err = AVCLAN_sendframe(
out, (log_t){.print = printAllFrames, .binary = printBinary}); out, (log_t){.print = printAllFrames, .binary = printBinary});
if (err || resp->r == r_Handled) { if (err || resp->r == r_Handled) {
if (err && out == AVCLAN_getStatusFrame() &&
failedStatusReports++ > 1) {
failedStatusReports = 0;
AVCLAN_stopPlaying(); // Disable periodic updates if e.g. no-one's
// listening (car was turned off?)
}
return_resp(resp); return_resp(resp);
} else { } else {
resp = AVCLAN_statemachine(resp); resp = AVCLAN_statemachine(resp);