mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-08-07 01:13:18 +00:00
Stop playing if nobody's listening
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user