ZuluSCSI_audio.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * ZuluSCSI™ - Copyright (c) 2022 Rabbit Hole Computing™
  3. *
  4. * ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
  5. *
  6. * https://www.gnu.org/licenses/gpl-3.0.html
  7. * ----
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version. 
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. * GNU General Public License for more details. 
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  20. **/
  21. #pragma once
  22. #include <stdint.h>
  23. #include "ImageBackingStore.h"
  24. /*
  25. * Status codes for audio playback, matching the SCSI 'audio status codes'.
  26. *
  27. * The first two are for a live condition and will be returned repeatedly. The
  28. * following two reflect a historical condition and are only returned once.
  29. */
  30. enum audio_status_code {
  31. ASC_PLAYING = 0x11,
  32. ASC_PAUSED = 0x12,
  33. ASC_COMPLETED = 0x13,
  34. ASC_ERRORED = 0x14,
  35. ASC_NO_STATUS = 0x15
  36. };
  37. /**
  38. * Indicates whether there is an active playback event for a given target.
  39. *
  40. * Note: this does not consider pause/resume events: even if audio is paused
  41. * this will indicate playback is in progress.
  42. *
  43. * \param owner The SCSI ID to check.
  44. * \return True if playback in progress, false if playback idle.
  45. */
  46. bool audio_is_playing(uint8_t id);
  47. /**
  48. * Begins audio playback for a file.
  49. *
  50. * \param owner The SCSI ID that initiated this playback operation.
  51. * \param img Pointer to the image containing PCM samples to play.
  52. * \param start Byte offset within file where playback will begin, inclusive.
  53. * \param end Byte offset within file where playback will end, exclusive.
  54. * \param swap If false, little-endian sample order, otherwise big-endian.
  55. * \return True if successful, false otherwise.
  56. */
  57. bool audio_play(uint8_t owner, ImageBackingStore* img, uint64_t start, uint64_t end, bool swap);
  58. /**
  59. * Pauses audio playback. This may be delayed slightly to allow sample buffers
  60. * to purge.
  61. *
  62. * \param id The SCSI ID to pause audio playback on.
  63. * \param pause If true, pause, otherwise resume.
  64. * \return True if operation changed audio output, false if no change.
  65. */
  66. bool audio_set_paused(uint8_t id, bool pause);
  67. /**
  68. * Stops audio playback.
  69. *
  70. * \param id The SCSI ID to stop audio playback on.
  71. */
  72. void audio_stop(uint8_t id);
  73. /**
  74. * Provides SCSI 'audio status code' for the given target. Depending on the
  75. * code this operation may produce side-effects, see the enum for details.
  76. *
  77. * \param id The SCSI ID to provide status codes for.
  78. * \return The matching audio status code.
  79. */
  80. audio_status_code audio_get_status_code(uint8_t id);