Improved audio lib error handling and aborting playback
All checks were successful
Deploy Docs / build-and-deploy (push) Successful in 12s

This commit is contained in:
2026-02-15 20:40:06 +01:00
parent fae79ad8b0
commit 8305adf917
3 changed files with 26 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
#include <zephyr/logging/log.h>
#include <fs_mgmt.h>
#include <audio.h>
#include <hal/nrf_i2s.h>
LOG_MODULE_REGISTER(MMS, LOG_LEVEL_INF);
@@ -27,10 +28,16 @@ int main(void)
LOG_INF("Triggering first sound...");
audio_play_sound("s1");
audio_play_sound("dead");
audio_play_sound("g1");
k_sleep(K_MSEC(100));
audio_stop();
LOG_INF("Triggering second sound after abort...");
audio_play_sound("s1");
k_sleep(K_MSEC(100));
// Directly stop the I2S peripheral to simulate an abrupt stop that might occur with a DMA failure or similar issue. This will cause the next playback attempt to hit the slab timeout and trigger the I2S reset logic in the audio thread.
NRF_I2S0->TASKS_STOP = 1;
NRF_I2S0->ENABLE = 0;
LOG_INF("Triggering third sound after failure simulation...");
audio_play_sound("s1");
audio_play_sound("dead");
audio_play_sound("g1");
return 0;
}