fmod_output.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* ======================================================================================== */
  2. /* FMOD Core API - output development header file. */
  3. /* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2024. */
  4. /* */
  5. /* Use this header if you are wanting to develop your own output plugin to use with */
  6. /* FMOD's output system. With this header you can make your own output plugin that FMOD */
  7. /* can register and use. See the documentation and examples on how to make a working */
  8. /* plugin. */
  9. /* */
  10. /* For more detail visit: */
  11. /* https://fmod.com/docs/2.03/api/plugin-api-output.html */
  12. /* ======================================================================================== */
  13. #ifndef _FMOD_OUTPUT_H
  14. #define _FMOD_OUTPUT_H
  15. typedef struct FMOD_OUTPUT_STATE FMOD_OUTPUT_STATE;
  16. typedef struct FMOD_OUTPUT_OBJECT3DINFO FMOD_OUTPUT_OBJECT3DINFO;
  17. /*
  18. Output constants
  19. */
  20. #define FMOD_OUTPUT_PLUGIN_VERSION 5
  21. typedef unsigned int FMOD_OUTPUT_METHOD;
  22. #define FMOD_OUTPUT_METHOD_MIX_DIRECT 0
  23. #define FMOD_OUTPUT_METHOD_MIX_BUFFERED 1
  24. /*
  25. Output callbacks
  26. */
  27. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_GETNUMDRIVERS_CALLBACK) (FMOD_OUTPUT_STATE *output_state, int *numdrivers);
  28. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_GETDRIVERINFO_CALLBACK) (FMOD_OUTPUT_STATE *output_state, int id, char *name, int namelen, FMOD_GUID *guid, int *systemrate, FMOD_SPEAKERMODE *speakermode, int *speakermodechannels);
  29. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_INIT_CALLBACK) (FMOD_OUTPUT_STATE *output_state, int selecteddriver, FMOD_INITFLAGS flags, int *outputrate, FMOD_SPEAKERMODE *speakermode, int *speakermodechannels, FMOD_SOUND_FORMAT *outputformat, int dspbufferlength, int *dspnumbuffers, int *dspnumadditionalbuffers, void *extradriverdata);
  30. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_START_CALLBACK) (FMOD_OUTPUT_STATE *output_state);
  31. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_STOP_CALLBACK) (FMOD_OUTPUT_STATE *output_state);
  32. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_CLOSE_CALLBACK) (FMOD_OUTPUT_STATE *output_state);
  33. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_UPDATE_CALLBACK) (FMOD_OUTPUT_STATE *output_state);
  34. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_GETHANDLE_CALLBACK) (FMOD_OUTPUT_STATE *output_state, void **handle);
  35. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_MIXER_CALLBACK) (FMOD_OUTPUT_STATE *output_state);
  36. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_OBJECT3DGETINFO_CALLBACK) (FMOD_OUTPUT_STATE *output_state, int *maxhardwareobjects);
  37. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_OBJECT3DALLOC_CALLBACK) (FMOD_OUTPUT_STATE *output_state, void **object3d);
  38. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_OBJECT3DFREE_CALLBACK) (FMOD_OUTPUT_STATE *output_state, void *object3d);
  39. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_OBJECT3DUPDATE_CALLBACK) (FMOD_OUTPUT_STATE *output_state, void *object3d, const FMOD_OUTPUT_OBJECT3DINFO *info);
  40. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_OPENPORT_CALLBACK) (FMOD_OUTPUT_STATE *output_state, FMOD_PORT_TYPE portType, FMOD_PORT_INDEX portIndex, int *portId, int *portRate, int *portChannels, FMOD_SOUND_FORMAT *portFormat);
  41. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_CLOSEPORT_CALLBACK) (FMOD_OUTPUT_STATE *output_state, int portId);
  42. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_DEVICELISTCHANGED_CALLBACK)(FMOD_OUTPUT_STATE *output_state);
  43. /*
  44. Output functions
  45. */
  46. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_READFROMMIXER_FUNC) (FMOD_OUTPUT_STATE *output_state, void *buffer, unsigned int length);
  47. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_COPYPORT_FUNC) (FMOD_OUTPUT_STATE *output_state, int portId, void *buffer, unsigned int length);
  48. typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_REQUESTRESET_FUNC) (FMOD_OUTPUT_STATE *output_state);
  49. typedef void * (F_CALL *FMOD_OUTPUT_ALLOC_FUNC) (unsigned int size, unsigned int align, const char *file, int line);
  50. typedef void (F_CALL *FMOD_OUTPUT_FREE_FUNC) (void *ptr, const char *file, int line);
  51. typedef void (F_CALL *FMOD_OUTPUT_LOG_FUNC) (FMOD_DEBUG_FLAGS level, const char *file, int line, const char *function, const char *string, ...);
  52. /*
  53. Output structures
  54. */
  55. typedef struct FMOD_OUTPUT_DESCRIPTION
  56. {
  57. unsigned int apiversion;
  58. const char *name;
  59. unsigned int version;
  60. FMOD_OUTPUT_METHOD method;
  61. FMOD_OUTPUT_GETNUMDRIVERS_CALLBACK getnumdrivers;
  62. FMOD_OUTPUT_GETDRIVERINFO_CALLBACK getdriverinfo;
  63. FMOD_OUTPUT_INIT_CALLBACK init;
  64. FMOD_OUTPUT_START_CALLBACK start;
  65. FMOD_OUTPUT_STOP_CALLBACK stop;
  66. FMOD_OUTPUT_CLOSE_CALLBACK close;
  67. FMOD_OUTPUT_UPDATE_CALLBACK update;
  68. FMOD_OUTPUT_GETHANDLE_CALLBACK gethandle;
  69. FMOD_OUTPUT_MIXER_CALLBACK mixer;
  70. FMOD_OUTPUT_OBJECT3DGETINFO_CALLBACK object3dgetinfo;
  71. FMOD_OUTPUT_OBJECT3DALLOC_CALLBACK object3dalloc;
  72. FMOD_OUTPUT_OBJECT3DFREE_CALLBACK object3dfree;
  73. FMOD_OUTPUT_OBJECT3DUPDATE_CALLBACK object3dupdate;
  74. FMOD_OUTPUT_OPENPORT_CALLBACK openport;
  75. FMOD_OUTPUT_CLOSEPORT_CALLBACK closeport;
  76. FMOD_OUTPUT_DEVICELISTCHANGED_CALLBACK devicelistchanged;
  77. } FMOD_OUTPUT_DESCRIPTION;
  78. struct FMOD_OUTPUT_STATE
  79. {
  80. void *plugindata;
  81. FMOD_OUTPUT_READFROMMIXER_FUNC readfrommixer;
  82. FMOD_OUTPUT_ALLOC_FUNC alloc;
  83. FMOD_OUTPUT_FREE_FUNC free;
  84. FMOD_OUTPUT_LOG_FUNC log;
  85. FMOD_OUTPUT_COPYPORT_FUNC copyport;
  86. FMOD_OUTPUT_REQUESTRESET_FUNC requestreset;
  87. };
  88. struct FMOD_OUTPUT_OBJECT3DINFO
  89. {
  90. float *buffer;
  91. unsigned int bufferlength;
  92. FMOD_VECTOR position;
  93. float gain;
  94. float spread;
  95. float priority;
  96. };
  97. /*
  98. Output macros
  99. */
  100. #define FMOD_OUTPUT_READFROMMIXER(_state, _buffer, _length) \
  101. (_state)->readfrommixer(_state, _buffer, _length)
  102. #define FMOD_OUTPUT_ALLOC(_state, _size, _align) \
  103. (_state)->alloc(_size, _align, __FILE__, __LINE__)
  104. #define FMOD_OUTPUT_FREE(_state, _ptr) \
  105. (_state)->free(_ptr, __FILE__, __LINE__)
  106. #define FMOD_OUTPUT_LOG(_state, _level, _location, _format, ...) \
  107. (_state)->log(_level, __FILE__, __LINE__, _location, _format, ##__VA_ARGS__)
  108. #define FMOD_OUTPUT_COPYPORT(_state, _id, _buffer, _length) \
  109. (_state)->copyport(_state, _id, _buffer, _length)
  110. #define FMOD_OUTPUT_REQUESTRESET(_state) \
  111. (_state)->requestreset(_state)
  112. #endif /* _FMOD_OUTPUT_H */