🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
2.8 KiB

  1. #ifndef _AL_SOURCE_H_
  2. #define _AL_SOURCE_H_
  3. #include <array>
  4. #include "alMain.h"
  5. #include "alu.h"
  6. #include "hrtf.h"
  7. #include "almalloc.h"
  8. #include "atomic.h"
  9. #define DEFAULT_SENDS 2
  10. struct ALbuffer;
  11. struct ALsource;
  12. struct ALeffectslot;
  13. struct ALbufferlistitem {
  14. std::atomic<ALbufferlistitem*> next;
  15. ALsizei max_samples;
  16. ALsizei num_buffers;
  17. ALbuffer *buffers[];
  18. static constexpr size_t Sizeof(size_t num_buffers) noexcept
  19. {
  20. return maxz(offsetof(ALbufferlistitem, buffers) + sizeof(ALbuffer*)*num_buffers,
  21. sizeof(ALbufferlistitem));
  22. }
  23. };
  24. struct ALsource {
  25. /** Source properties. */
  26. ALfloat Pitch;
  27. ALfloat Gain;
  28. ALfloat OuterGain;
  29. ALfloat MinGain;
  30. ALfloat MaxGain;
  31. ALfloat InnerAngle;
  32. ALfloat OuterAngle;
  33. ALfloat RefDistance;
  34. ALfloat MaxDistance;
  35. ALfloat RolloffFactor;
  36. std::array<ALfloat,3> Position;
  37. std::array<ALfloat,3> Velocity;
  38. std::array<ALfloat,3> Direction;
  39. std::array<ALfloat,3> OrientAt;
  40. std::array<ALfloat,3> OrientUp;
  41. ALboolean HeadRelative;
  42. ALboolean Looping;
  43. DistanceModel mDistanceModel;
  44. Resampler mResampler;
  45. ALboolean DirectChannels;
  46. SpatializeMode mSpatialize;
  47. ALboolean DryGainHFAuto;
  48. ALboolean WetGainAuto;
  49. ALboolean WetGainHFAuto;
  50. ALfloat OuterGainHF;
  51. ALfloat AirAbsorptionFactor;
  52. ALfloat RoomRolloffFactor;
  53. ALfloat DopplerFactor;
  54. /* NOTE: Stereo pan angles are specified in radians, counter-clockwise
  55. * rather than clockwise.
  56. */
  57. std::array<ALfloat,2> StereoPan;
  58. ALfloat Radius;
  59. /** Direct filter and auxiliary send info. */
  60. struct {
  61. ALfloat Gain;
  62. ALfloat GainHF;
  63. ALfloat HFReference;
  64. ALfloat GainLF;
  65. ALfloat LFReference;
  66. } Direct;
  67. struct SendData {
  68. ALeffectslot *Slot;
  69. ALfloat Gain;
  70. ALfloat GainHF;
  71. ALfloat HFReference;
  72. ALfloat GainLF;
  73. ALfloat LFReference;
  74. };
  75. al::vector<SendData> Send;
  76. /**
  77. * Last user-specified offset, and the offset type (bytes, samples, or
  78. * seconds).
  79. */
  80. ALdouble Offset;
  81. ALenum OffsetType;
  82. /** Source type (static, streaming, or undetermined) */
  83. ALint SourceType;
  84. /** Source state (initial, playing, paused, or stopped) */
  85. ALenum state;
  86. /** Source Buffer Queue head. */
  87. ALbufferlistitem *queue;
  88. std::atomic_flag PropsClean;
  89. /* Index into the context's Voices array. Lazily updated, only checked and
  90. * reset when looking up the voice.
  91. */
  92. ALint VoiceIdx;
  93. /** Self ID */
  94. ALuint id;
  95. ALsource(ALsizei num_sends);
  96. ~ALsource();
  97. ALsource(const ALsource&) = delete;
  98. ALsource& operator=(const ALsource&) = delete;
  99. };
  100. void UpdateAllSourceProps(ALCcontext *context);
  101. #endif