audio-io.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #pragma once
  15. #include "../util/c99defs.h"
  16. #include "media-io.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /*
  21. * Base audio output component. Use this to create an audio output track
  22. * for the media.
  23. */
  24. struct audio_output;
  25. typedef struct audio_output *audio_t;
  26. enum audio_type {
  27. AUDIO_FORMAT_UNKNOWN,
  28. AUDIO_FORMAT_8BIT,
  29. AUDIO_FORMAT_16BIT,
  30. AUDIO_FORMAT_24BIT,
  31. AUDIO_FORMAT_32BIT,
  32. AUDIO_FORMAT_FLOAT,
  33. };
  34. enum speaker_setup {
  35. SPEAKERS_UNKNOWN,
  36. SPEAKERS_MONO,
  37. SPEAKERS_STEREO,
  38. SPEAKERS_2POINT1,
  39. SPEAKERS_QUAD,
  40. SPEAKERS_4POINT1,
  41. SPEAKERS_5POINT1,
  42. SPEAKERS_5POINT1_SURROUND,
  43. SPEAKERS_7POINT1,
  44. SPEAKERS_7POINT1_SURROUND,
  45. SPEAKERS_SURROUND,
  46. };
  47. struct audio_data {
  48. void *data;
  49. uint32_t frames;
  50. uint32_t speakers;
  51. uint32_t samples_per_sec;
  52. enum audio_type type;
  53. uint64_t timestamp;
  54. };
  55. struct audio_info {
  56. const char *name;
  57. const char *format;
  58. uint32_t channels;
  59. uint32_t samples_per_sec;
  60. enum audio_type type;
  61. enum speaker_setup speakers;
  62. };
  63. #define AUDIO_OUTPUT_SUCCESS 0
  64. #define AUDIO_OUTPUT_INVALIDPARAM -1
  65. #define AUDIO_OUTPUT_FAIL -2
  66. EXPORT int audio_output_open(audio_t *audio, media_t media,
  67. struct audio_info *info);
  68. EXPORT void audio_output_data(audio_t audio, struct audio_data *data);
  69. EXPORT void audio_output_close(audio_t audio);
  70. #ifdef __cplusplus
  71. }
  72. #endif