fmod_output.h 6.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* ======================================================================================================== */
  2. /* FMOD Studio - output development header file. Copyright (c), Firelight Technologies Pty, Ltd. 2004-2015. */
  3. /* */
  4. /* Use this header if you are wanting to develop your own output plugin to use with */
  5. /* FMOD's output system. With this header you can make your own output plugin that FMOD */
  6. /* can register and use. See the documentation and examples on how to make a working plugin. */
  7. /* */
  8. /* ======================================================================================================== */
  9. #ifndef _FMOD_OUTPUT_H
  10. #define _FMOD_OUTPUT_H
  11. typedef struct FMOD_OUTPUT_STATE FMOD_OUTPUT_STATE;
  12. /*
  13. Output callbacks
  14. */
  15. typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_GETNUMDRIVERS_CALLBACK) (FMOD_OUTPUT_STATE *output_state, int *numdrivers);
  16. typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_GETDRIVERINFO_CALLBACK) (FMOD_OUTPUT_STATE *output, int id, char *name, int namelen, FMOD_GUID *guid, int *systemrate, FMOD_SPEAKERMODE *speakermode, int *speakermodechannels);
  17. typedef FMOD_RESULT (F_CALLBACK *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, void *extradriverdata);
  18. typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_START_CALLBACK) (FMOD_OUTPUT_STATE *output_state);
  19. typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_STOP_CALLBACK) (FMOD_OUTPUT_STATE *output_state);
  20. typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_CLOSE_CALLBACK) (FMOD_OUTPUT_STATE *output_state);
  21. typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_UPDATE_CALLBACK) (FMOD_OUTPUT_STATE *output_state);
  22. typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_GETHANDLE_CALLBACK) (FMOD_OUTPUT_STATE *output_state, void **handle);
  23. typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_GETPOSITION_CALLBACK) (FMOD_OUTPUT_STATE *output_state, unsigned int *pcm);
  24. typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_LOCK_CALLBACK) (FMOD_OUTPUT_STATE *output_state, unsigned int offset, unsigned int length, void **ptr1, void **ptr2, unsigned int *len1, unsigned int *len2);
  25. typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_UNLOCK_CALLBACK) (FMOD_OUTPUT_STATE *output_state, void *ptr1, void *ptr2, unsigned int len1, unsigned int len2);
  26. typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_READFROMMIXER) (FMOD_OUTPUT_STATE *output_state, void *buffer, unsigned int length); /* This one is called by plugin through FMOD_OUTPUT_STATE, not set by user as a callback. */
  27. /*
  28. [STRUCTURE]
  29. [
  30. [DESCRIPTION]
  31. When creating an output, declare one of these and provide the relevant callbacks and name for FMOD to use when it opens and reads a file of this type.
  32. [REMARKS]
  33. Members marked with [in] mean the variable can be written to. The user can set the value.<br>
  34. Members marked with [out] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
  35. [SEE_ALSO]
  36. FMOD_OUTPUT_STATE
  37. ]
  38. */
  39. typedef struct FMOD_OUTPUT_DESCRIPTION
  40. {
  41. const char *name; /* [in] Name of the output. */
  42. unsigned int version; /* [in] Plugin writer's version number. */
  43. int polling; /* [in] If TRUE (non zero), this tells FMOD to start a thread and call getposition / lock / unlock for feeding data. If 0, the output is probably callback based, so all the plugin needs to do is call readfrommixer to the appropriate pointer. */
  44. FMOD_OUTPUT_GETNUMDRIVERS_CALLBACK getnumdrivers; /* [in] For sound device enumeration. This callback is to give System::getNumDrivers somthing to return. */
  45. FMOD_OUTPUT_GETDRIVERINFO_CALLBACK getdriverinfo; /* [in] For sound device enumeration. This callback is to give System::getDriverName somthing to return. */
  46. FMOD_OUTPUT_INIT_CALLBACK init; /* [in] Initialization function for the output device. This is called from System::init. */
  47. FMOD_OUTPUT_START_CALLBACK start; /* [in] Initialization function for the output device to start accepting audio data from the FMOD software mixer. This is called from System::init. */
  48. FMOD_OUTPUT_STOP_CALLBACK stop; /* [in] Initialization function for the output device to stop accepting audio data from FMOD the software mixer. This is called from System::close. */
  49. FMOD_OUTPUT_CLOSE_CALLBACK close; /* [in] Cleanup / close down function for the output device. This is called from System::close. */
  50. FMOD_OUTPUT_UPDATE_CALLBACK update; /* [in] Update function that is called once a frame by the user. This is called from System::update. */
  51. FMOD_OUTPUT_GETHANDLE_CALLBACK gethandle; /* [in] This is called from System::getOutputHandle. This is just to return a pointer to the internal system device object that the system may be using.*/
  52. FMOD_OUTPUT_GETPOSITION_CALLBACK getposition; /* [in] This is called from the FMOD software mixer thread if 'polling' = true. This returns a position value in samples so that FMOD knows where and when to fill its buffer. */
  53. FMOD_OUTPUT_LOCK_CALLBACK lock; /* [in] This is called from the FMOD software mixer thread if 'polling' = true. This function provides a pointer to data that FMOD can write to when software mixing. */
  54. FMOD_OUTPUT_UNLOCK_CALLBACK unlock; /* [in] This is called from the FMOD software mixer thread if 'polling' = true. This optional function accepts the data that has been mixed and copies it or does whatever it needs to before sending it to the hardware. */
  55. } FMOD_OUTPUT_DESCRIPTION;
  56. /*
  57. [STRUCTURE]
  58. [
  59. [DESCRIPTION]
  60. Output plugin structure that is passed into each callback.
  61. [REMARKS]
  62. Members marked with [in] mean the variable can be written to. The user can set the value.<br>
  63. Members marked with [out] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
  64. [SEE_ALSO]
  65. FMOD_OUTPUT_DESCRIPTION
  66. ]
  67. */
  68. struct FMOD_OUTPUT_STATE
  69. {
  70. void *plugindata; /* [in] Plugin writer created data the output author wants to attach to this object. */
  71. FMOD_OUTPUT_READFROMMIXER readfrommixer; /* [out] Function to update mixer and write the result to the provided pointer. Used from callback based output only. Polling based output uses lock/unlock/getposition. */
  72. };
  73. #endif