diff options
| author | Joel Challis <git@zvecr.com> | 2025-07-14 13:53:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-14 13:53:57 +0100 |
| commit | 20555f9a3366abf9d4246e00ad032590ff16236a (patch) | |
| tree | c78a2a08206023b1eed13883a97681da3b2c3a41 /quantum | |
| parent | 56ad3a5f435b57605388ad986e85ca6e4d607eb2 (diff) | |
Relocate `AUDIO_INIT_DELAY` implementation (#25491)
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/audio/audio.c | 19 | ||||
| -rw-r--r-- | quantum/audio/audio.h | 6 | ||||
| -rw-r--r-- | quantum/keyboard.c | 20 |
3 files changed, 26 insertions, 19 deletions
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index 247b737331..461ec89544 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c | |||
| @@ -183,6 +183,25 @@ void audio_init(void) { | |||
| 183 | #endif | 183 | #endif |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | void audio_task(void) { | ||
| 187 | #ifdef AUDIO_INIT_DELAY | ||
| 188 | // startup song potentially needs to be run a little bit | ||
| 189 | // after keyboard startup, or else they will not work correctly | ||
| 190 | // because of interaction with the USB device state, which | ||
| 191 | // may still be in flux... | ||
| 192 | static bool delayed_tasks_run = false; | ||
| 193 | static uint16_t delayed_task_timer = 0; | ||
| 194 | if (!delayed_tasks_run) { | ||
| 195 | if (!delayed_task_timer) { | ||
| 196 | delayed_task_timer = timer_read(); | ||
| 197 | } else if (timer_elapsed(delayed_task_timer) > 300) { | ||
| 198 | audio_startup(); | ||
| 199 | delayed_tasks_run = true; | ||
| 200 | } | ||
| 201 | } | ||
| 202 | #endif | ||
| 203 | } | ||
| 204 | |||
| 186 | void audio_startup(void) { | 205 | void audio_startup(void) { |
| 187 | if (audio_config.enable) { | 206 | if (audio_config.enable) { |
| 188 | PLAY_SONG(startup_song); | 207 | PLAY_SONG(startup_song); |
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index 647744a686..a41814d0f8 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h | |||
| @@ -69,7 +69,11 @@ void eeconfig_update_audio_current(void); | |||
| 69 | * @post audio system (and hardware) initialized and ready to play tones | 69 | * @post audio system (and hardware) initialized and ready to play tones |
| 70 | */ | 70 | */ |
| 71 | void audio_init(void); | 71 | void audio_init(void); |
| 72 | void audio_startup(void); | 72 | |
| 73 | /** | ||
| 74 | * \brief Handle various subsystem background tasks. | ||
| 75 | */ | ||
| 76 | void audio_task(void); | ||
| 73 | 77 | ||
| 74 | /** | 78 | /** |
| 75 | * @brief en-/disable audio output, save this choice to the eeprom | 79 | * @brief en-/disable audio output, save this choice to the eeprom |
diff --git a/quantum/keyboard.c b/quantum/keyboard.c index c1a6d444a5..bf4890a51d 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c | |||
| @@ -648,24 +648,8 @@ void quantum_task(void) { | |||
| 648 | if (!is_keyboard_master()) return; | 648 | if (!is_keyboard_master()) return; |
| 649 | #endif | 649 | #endif |
| 650 | 650 | ||
| 651 | #if defined(AUDIO_ENABLE) && defined(AUDIO_INIT_DELAY) | 651 | #ifdef AUDIO_ENABLE |
| 652 | // There are some tasks that need to be run a little bit | 652 | audio_task(); |
| 653 | // after keyboard startup, or else they will not work correctly | ||
| 654 | // because of interaction with the USB device state, which | ||
| 655 | // may still be in flux... | ||
| 656 | // | ||
| 657 | // At the moment the only feature that needs this is the | ||
| 658 | // startup song. | ||
| 659 | static bool delayed_tasks_run = false; | ||
| 660 | static uint16_t delayed_task_timer = 0; | ||
| 661 | if (!delayed_tasks_run) { | ||
| 662 | if (!delayed_task_timer) { | ||
| 663 | delayed_task_timer = timer_read(); | ||
| 664 | } else if (timer_elapsed(delayed_task_timer) > 300) { | ||
| 665 | audio_startup(); | ||
| 666 | delayed_tasks_run = true; | ||
| 667 | } | ||
| 668 | } | ||
| 669 | #endif | 653 | #endif |
| 670 | 654 | ||
| 671 | #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE) | 655 | #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE) |
