Improve gain/hf/lf packing when processing voice updates
[openal-soft.git] / al / buffer.h
blobad7aeb3593aab95af8a44c63500ab13737aaeafd
1 #ifndef AL_BUFFER_H
2 #define AL_BUFFER_H
4 #include <atomic>
6 #include "AL/al.h"
8 #include "albyte.h"
9 #include "almalloc.h"
10 #include "atomic.h"
11 #include "inprogext.h"
12 #include "vector.h"
15 /* User formats */
16 enum UserFmtType : unsigned char {
17 UserFmtUByte,
18 UserFmtShort,
19 UserFmtFloat,
20 UserFmtDouble,
21 UserFmtMulaw,
22 UserFmtAlaw,
23 UserFmtIMA4,
24 UserFmtMSADPCM,
26 enum UserFmtChannels : unsigned char {
27 UserFmtMono,
28 UserFmtStereo,
29 UserFmtRear,
30 UserFmtQuad,
31 UserFmtX51, /* (WFX order) */
32 UserFmtX61, /* (WFX order) */
33 UserFmtX71, /* (WFX order) */
34 UserFmtBFormat2D, /* WXY */
35 UserFmtBFormat3D, /* WXYZ */
39 /* Storable formats */
40 enum FmtType : unsigned char {
41 FmtUByte = UserFmtUByte,
42 FmtShort = UserFmtShort,
43 FmtFloat = UserFmtFloat,
44 FmtDouble = UserFmtDouble,
45 FmtMulaw = UserFmtMulaw,
46 FmtAlaw = UserFmtAlaw,
48 enum FmtChannels : unsigned char {
49 FmtMono = UserFmtMono,
50 FmtStereo = UserFmtStereo,
51 FmtRear = UserFmtRear,
52 FmtQuad = UserFmtQuad,
53 FmtX51 = UserFmtX51,
54 FmtX61 = UserFmtX61,
55 FmtX71 = UserFmtX71,
56 FmtBFormat2D = UserFmtBFormat2D,
57 FmtBFormat3D = UserFmtBFormat3D,
59 #define MAX_INPUT_CHANNELS (8)
62 ALuint BytesFromFmt(FmtType type);
63 ALuint ChannelsFromFmt(FmtChannels chans);
64 inline ALuint FrameSizeFromFmt(FmtChannels chans, FmtType type)
65 { return ChannelsFromFmt(chans) * BytesFromFmt(type); }
68 struct ALbuffer {
69 al::vector<al::byte,16> mData;
71 ALuint Frequency{0u};
72 ALbitfieldSOFT Access{0u};
73 ALuint SampleLen{0u};
75 FmtChannels mFmtChannels{};
76 FmtType mFmtType{};
78 UserFmtType OriginalType{};
79 ALuint OriginalSize{0};
80 ALuint OriginalAlign{0};
82 ALenum AmbiLayout{AL_FUMA_SOFT};
83 ALenum AmbiScaling{AL_FUMA_SOFT};
85 ALuint LoopStart{0u};
86 ALuint LoopEnd{0u};
88 ALuint UnpackAlign{0};
89 ALuint PackAlign{0};
91 ALbitfieldSOFT MappedAccess{0u};
92 ALsizei MappedOffset{0};
93 ALsizei MappedSize{0};
95 /* Number of times buffer was attached to a source (deletion can only occur when 0) */
96 RefCount ref{0u};
98 /* Self ID */
99 ALuint id{0};
102 #endif