ifc_audioout.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include "foundation/dispatch.h"
  3. #include "foundation/error.h"
  4. #include "audio/parameters.h"
  5. class NOVTABLE ifc_audioout : public Wasabi2::Dispatchable
  6. {
  7. protected:
  8. ifc_audioout() : Dispatchable(DISPATCHABLE_VERSION) {}
  9. ~ifc_audioout() {}
  10. public:
  11. enum
  12. {
  13. CHANNEL_LAYOUT_MICROSOFT = 0x0, // microsoft channel order - http://www.microsoft.com/whdc/device/audio/multichaud.mspx#E4C
  14. CHANNEL_LAYOUT_MPEG = 0x1,
  15. };
  16. enum
  17. {
  18. EXTENDED_FLAG_APPLY_GAIN=0x1, /* apply the gain value specified in Parameters::gain */
  19. EXTENDED_FLAG_REPLAYGAIN=0x2, /* pass if you tried to figure out ReplayGain on your own. otherwise the Audio Output object will apply the default gain */
  20. EXTENDED_FLAG_GAIN_MASK=EXTENDED_FLAG_APPLY_GAIN|EXTENDED_FLAG_REPLAYGAIN, /* a mask to check whether or not the gain value is valid */
  21. /* so that you can check if a flag was set that you don't understand */
  22. EXTENDED_FLAG_VALID_MASK=EXTENDED_FLAG_APPLY_GAIN|EXTENDED_FLAG_REPLAYGAIN,
  23. };
  24. struct Parameters
  25. {
  26. size_t sizeof_parameters;
  27. nsaudio::Parameters audio;
  28. /* anything after this needs sizeof_parameters to be large enough
  29. AND a flag set in extended_fields_flags
  30. if there's no flag for the field, it's because a default value of 0 can be assumed */
  31. unsigned int extended_fields_flags; // set these if you use any of the following fields. see comment above
  32. double gain; // additional gain specified by client. usually used for replaygain (so it can be combined with EQ pre-amp or float/pcm conversion)
  33. size_t frames_trim_start; // number of frames to trim from the start
  34. size_t frames_trim_end; // number of frames to trim from the start
  35. };
  36. int Output(const void *data, size_t data_size) { return AudioOutput_Output(data, data_size); }
  37. // returns number of bytes that you can write
  38. size_t CanWrite() { return AudioOutput_CanWrite(); }
  39. void Flush(double seconds) { AudioOutput_Flush(seconds); }
  40. void Pause(int state) { AudioOutput_Pause(state); }
  41. /* called by the input plugin when no more output will be sent */
  42. void Done() { AudioOutput_Done(); }
  43. /* called by the input plugin when playback was forcefully stopped */
  44. void Stop() { AudioOutput_Stop(); }
  45. /* returns the latency in seconds (how many seconds until samples you're about to write show up at the audio output */
  46. double Latency() { return AudioOutput_Latency(); }
  47. /* only valid after a call to Done(). Returns NErr_True if there is still data in the buffer, NErr_False otherwise */
  48. int Playing() { return AudioOutput_Playing(); }
  49. protected:
  50. virtual int WASABICALL AudioOutput_Output(const void *data, size_t data_size)=0;
  51. virtual size_t WASABICALL AudioOutput_CanWrite()=0; // returns number of bytes that you can write
  52. virtual void WASABICALL AudioOutput_Flush(double seconds)=0;
  53. virtual void WASABICALL AudioOutput_Pause(int state)=0;
  54. /* called by the input plugin when no more output will be sent */
  55. virtual void WASABICALL AudioOutput_Done()=0;
  56. /* called by the input plugin when playback was forcefully stopped */
  57. virtual void WASABICALL AudioOutput_Stop()=0;
  58. virtual double WASABICALL AudioOutput_Latency()=0;
  59. virtual int WASABICALL AudioOutput_Playing()=0;
  60. enum
  61. {
  62. DISPATCHABLE_VERSION,
  63. };
  64. };