alSource.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #ifndef _AL_SOURCE_H_
  2. #define _AL_SOURCE_H_
  3. #define MAX_SENDS 4
  4. #include "alMain.h"
  5. #include "alu.h"
  6. #include "hrtf.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. struct ALbuffer;
  11. struct ALsource;
  12. typedef struct ALbufferlistitem {
  13. struct ALbuffer *buffer;
  14. struct ALbufferlistitem *volatile next;
  15. struct ALbufferlistitem *volatile prev;
  16. } ALbufferlistitem;
  17. typedef struct ALvoice {
  18. struct ALsource *volatile Source;
  19. /** Method to update mixing parameters. */
  20. ALvoid (*Update)(struct ALvoice *self, const struct ALsource *source, const ALCcontext *context);
  21. /** Current target parameters used for mixing. */
  22. ALint Step;
  23. ALboolean IsHrtf;
  24. ALuint Offset; /* Number of output samples mixed since starting. */
  25. alignas(16) ALfloat PrevSamples[MAX_INPUT_CHANNELS][MAX_PRE_SAMPLES];
  26. BsincState SincState;
  27. DirectParams Direct;
  28. SendParams Send[MAX_SENDS];
  29. } ALvoice;
  30. typedef struct ALsource {
  31. /** Source properties. */
  32. volatile ALfloat Pitch;
  33. volatile ALfloat Gain;
  34. volatile ALfloat OuterGain;
  35. volatile ALfloat MinGain;
  36. volatile ALfloat MaxGain;
  37. volatile ALfloat InnerAngle;
  38. volatile ALfloat OuterAngle;
  39. volatile ALfloat RefDistance;
  40. volatile ALfloat MaxDistance;
  41. volatile ALfloat RollOffFactor;
  42. aluVector Position;
  43. aluVector Velocity;
  44. aluVector Direction;
  45. volatile ALfloat Orientation[2][3];
  46. volatile ALboolean HeadRelative;
  47. volatile ALboolean Looping;
  48. volatile enum DistanceModel DistanceModel;
  49. volatile ALboolean DirectChannels;
  50. volatile ALboolean DryGainHFAuto;
  51. volatile ALboolean WetGainAuto;
  52. volatile ALboolean WetGainHFAuto;
  53. volatile ALfloat OuterGainHF;
  54. volatile ALfloat AirAbsorptionFactor;
  55. volatile ALfloat RoomRolloffFactor;
  56. volatile ALfloat DopplerFactor;
  57. volatile ALfloat Radius;
  58. /**
  59. * Last user-specified offset, and the offset type (bytes, samples, or
  60. * seconds).
  61. */
  62. ALdouble Offset;
  63. ALenum OffsetType;
  64. /** Source type (static, streaming, or undetermined) */
  65. volatile ALint SourceType;
  66. /** Source state (initial, playing, paused, or stopped) */
  67. volatile ALenum state;
  68. ALenum new_state;
  69. /**
  70. * Source offset in samples, relative to the currently playing buffer, NOT
  71. * the whole queue, and the fractional (fixed-point) offset to the next
  72. * sample.
  73. */
  74. ALuint position;
  75. ALuint position_fraction;
  76. /** Source Buffer Queue info. */
  77. ATOMIC(ALbufferlistitem*) queue;
  78. ATOMIC(ALbufferlistitem*) current_buffer;
  79. RWLock queue_lock;
  80. /** Current buffer sample info. */
  81. ALuint NumChannels;
  82. ALuint SampleSize;
  83. /** Direct filter and auxiliary send info. */
  84. struct {
  85. ALfloat Gain;
  86. ALfloat GainHF;
  87. ALfloat HFReference;
  88. ALfloat GainLF;
  89. ALfloat LFReference;
  90. } Direct;
  91. struct {
  92. struct ALeffectslot *Slot;
  93. ALfloat Gain;
  94. ALfloat GainHF;
  95. ALfloat HFReference;
  96. ALfloat GainLF;
  97. ALfloat LFReference;
  98. } Send[MAX_SENDS];
  99. /** Source needs to update its mixing parameters. */
  100. ATOMIC(ALenum) NeedsUpdate;
  101. /** Self ID */
  102. ALuint id;
  103. } ALsource;
  104. inline struct ALsource *LookupSource(ALCcontext *context, ALuint id)
  105. { return (struct ALsource*)LookupUIntMapKey(&context->SourceMap, id); }
  106. inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id)
  107. { return (struct ALsource*)RemoveUIntMapKey(&context->SourceMap, id); }
  108. ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
  109. ALboolean ApplyOffset(ALsource *Source);
  110. ALvoid ReleaseALSources(ALCcontext *Context);
  111. #ifdef __cplusplus
  112. }
  113. #endif
  114. #endif