audio_i2s.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Copyright (C) 2023 saybur
  3. * ZuluSCSI™ - Copyright (c) 2023-2025 Rabbit Hole Computing™
  4. *
  5. * ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
  6. *
  7. * https://www.gnu.org/licenses/gpl-3.0.html
  8. * ----
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version. 
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. * GNU General Public License for more details. 
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  21. **/
  22. #pragma once
  23. #ifdef ENABLE_AUDIO_OUTPUT_I2S
  24. extern bool g_audio_enabled;
  25. extern bool g_ode_audio_stopped;
  26. // size of the a circular audio sample buffer, in bytes
  27. // these must be divisible by 1024
  28. #define AUDIO_BUFFER_SIZE 16384
  29. // #define AUDIO_BUFFER_SIZE 8192 // ~46.44ms
  30. // # define AUDIO_BUFFER_SIZE 4096 // reduce memory usage
  31. #define AUDIO_BUFFER_HALF_SIZE AUDIO_BUFFER_SIZE / 2
  32. /**
  33. * Handler for I2S DMA interrupts
  34. */
  35. void ODE_IRQHandler();
  36. /**
  37. * Indicates if the audio subsystem is actively streaming, including if it is
  38. * sending silent data during sample stall events.
  39. *
  40. * \return true if audio streaming is active, false otherwise.
  41. */
  42. bool audio_is_active();
  43. /**
  44. * Initializes the audio subsystem. Should be called only once, toward the end
  45. * of platform_late_init().
  46. */
  47. void audio_setup();
  48. /**
  49. * Called from platform_poll() to fill sample buffer(s) if needed.
  50. */
  51. void audio_poll();
  52. #endif //ENABLE_AUDIO_OUTPUT_I2S