audio-io.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #ifndef AUDIO_IO_H
  15. #define AUDIO_IO_H
  16. #include "../util/c99defs.h"
  17. #include "media-io.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /*
  22. * Base audio output component. Use this to create an audio output track
  23. * for the media.
  24. */
  25. struct audio_output;
  26. typedef struct audio_output *audio_t;
  27. enum audio_type {
  28. AUDIO_FORMAT_UNKNOWN,
  29. AUDIO_FORMAT_8BIT,
  30. AUDIO_FORMAT_16BIT,
  31. AUDIO_FORMAT_24BIT,
  32. AUDIO_FORMAT_32BIT,
  33. AUDIO_FORMAT_FLOAT,
  34. };
  35. enum speaker_setup {
  36. SPEAKERS_UNKNOWN,
  37. SPEAKERS_MONO,
  38. SPEAKERS_STEREO,
  39. SPEAKERS_2POINT1,
  40. SPEAKERS_QUAD,
  41. SPEAKERS_4POINT1,
  42. SPEAKERS_5POINT1,
  43. SPEAKERS_5POINT1_SURROUND,
  44. SPEAKERS_7POINT1,
  45. SPEAKERS_7POINT1_SURROUND,
  46. SPEAKERS_SURROUND,
  47. };
  48. struct audio_data {
  49. void *data;
  50. uint32_t frames;
  51. uint32_t speakers;
  52. uint32_t samples_per_sec;
  53. enum audio_type type;
  54. uint64_t timestamp;
  55. };
  56. struct audio_info {
  57. const char *name;
  58. const char *format;
  59. uint32_t channels;
  60. uint32_t samples_per_sec;
  61. enum audio_type type;
  62. enum speaker_setup speakers;
  63. };
  64. #define AUDIO_OUTPUT_SUCCESS 0
  65. #define AUDIO_OUTPUT_INVALIDPARAM -1
  66. #define AUDIO_OUTPUT_FAIL -2
  67. EXPORT int audio_output_open(audio_t *audio, media_t media,
  68. struct audio_info *info);
  69. EXPORT void audio_output_data(audio_t audio, struct audio_data *data);
  70. EXPORT void audio_output_close(audio_t audio);
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif