Skip to content

Commit a2d8645

Browse files
authored
I2S: Fix silent RTTTL regression (#8129)
1 parent fc9f1ac commit a2d8645

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/AudioThread.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class AudioThread : public concurrency::OSThread
2626
i2sRtttl->begin(rtttlFile, audioOut);
2727
}
2828

29+
// Also handles actually playing the RTTTL, needs to be called in loop
2930
bool isPlaying()
3031
{
3132
if (i2sRtttl != nullptr) {

src/modules/ExternalNotificationModule.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,12 @@ int32_t ExternalNotificationModule::runOnce()
8989
return INT32_MAX; // we don't need this thread here...
9090
} else {
9191
uint32_t delay = EXT_NOTIFICATION_MODULE_OUTPUT_MS;
92-
bool isPlaying = rtttl::isPlaying();
92+
bool isRtttlPlaying = rtttl::isPlaying();
9393
#ifdef HAS_I2S
94-
isPlaying = rtttl::isPlaying() || audioThread->isPlaying();
94+
// audioThread->isPlaying() also handles actually playing the RTTTL, needs to be called in loop
95+
isRtttlPlaying = isRtttlPlaying || audioThread->isPlaying();
9596
#endif
96-
if ((nagCycleCutoff < millis()) && !isPlaying) {
97+
if ((nagCycleCutoff < millis()) && !isRtttlPlaying) {
9798
// let the song finish if we reach timeout
9899
nagCycleCutoff = UINT32_MAX;
99100
LOG_INFO("Turning off external notification: ");
@@ -187,12 +188,14 @@ int32_t ExternalNotificationModule::runOnce()
187188

188189
// Play RTTTL over i2s audio interface if enabled as buzzer
189190
#ifdef HAS_I2S
190-
if (moduleConfig.external_notification.use_i2s_as_buzzer && canBuzz()) {
191+
if (moduleConfig.external_notification.use_i2s_as_buzzer) {
191192
if (audioThread->isPlaying()) {
192193
// Continue playing
193194
} else if (isNagging && (nagCycleCutoff >= millis())) {
194195
audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone));
195196
}
197+
// we need fast updates to play the RTTTL
198+
delay = EXT_NOTIFICATION_FAST_THREAD_MS;
196199
}
197200
#endif
198201
// now let the PWM buzzer play

0 commit comments

Comments
 (0)