Prepare the new driver in a local variable
[openal-soft.git] / OpenAL32 / Include / alBuffer.h
blobb13e1231a2d0a0155e9e59fc1b5f503e58b5884c
1 #ifndef _AL_BUFFER_H_
2 #define _AL_BUFFER_H_
4 #include "alMain.h"
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
10 /* User formats */
11 enum UserFmtType {
12 UserFmtByte = AL_BYTE_SOFT,
13 UserFmtUByte = AL_UNSIGNED_BYTE_SOFT,
14 UserFmtShort = AL_SHORT_SOFT,
15 UserFmtUShort = AL_UNSIGNED_SHORT_SOFT,
16 UserFmtInt = AL_INT_SOFT,
17 UserFmtUInt = AL_UNSIGNED_INT_SOFT,
18 UserFmtFloat = AL_FLOAT_SOFT,
19 UserFmtDouble = AL_DOUBLE_SOFT,
20 UserFmtMulaw = AL_MULAW_SOFT,
21 UserFmtAlaw = 0x10000000,
22 UserFmtIMA4,
23 UserFmtMSADPCM,
25 enum UserFmtChannels {
26 UserFmtMono = AL_MONO_SOFT,
27 UserFmtStereo = AL_STEREO_SOFT,
28 UserFmtRear = AL_REAR_SOFT,
29 UserFmtQuad = AL_QUAD_SOFT,
30 UserFmtX51 = AL_5POINT1_SOFT, /* (WFX order) */
31 UserFmtX61 = AL_6POINT1_SOFT, /* (WFX order) */
32 UserFmtX71 = AL_7POINT1_SOFT, /* (WFX order) */
33 UserFmtBFormat2D = AL_BFORMAT2D_SOFT, /* WXY */
34 UserFmtBFormat3D = AL_BFORMAT3D_SOFT, /* WXYZ */
37 ALsizei BytesFromUserFmt(enum UserFmtType type);
38 ALsizei ChannelsFromUserFmt(enum UserFmtChannels chans);
39 inline ALsizei FrameSizeFromUserFmt(enum UserFmtChannels chans, enum UserFmtType type)
41 return ChannelsFromUserFmt(chans) * BytesFromUserFmt(type);
45 /* Storable formats */
46 enum FmtType {
47 FmtByte = UserFmtByte,
48 FmtShort = UserFmtShort,
49 FmtFloat = UserFmtFloat,
51 enum FmtChannels {
52 FmtMono = UserFmtMono,
53 FmtStereo = UserFmtStereo,
54 FmtRear = UserFmtRear,
55 FmtQuad = UserFmtQuad,
56 FmtX51 = UserFmtX51,
57 FmtX61 = UserFmtX61,
58 FmtX71 = UserFmtX71,
59 FmtBFormat2D = UserFmtBFormat2D,
60 FmtBFormat3D = UserFmtBFormat3D,
62 #define MAX_INPUT_CHANNELS (8)
64 ALsizei BytesFromFmt(enum FmtType type);
65 ALsizei ChannelsFromFmt(enum FmtChannels chans);
66 inline ALsizei FrameSizeFromFmt(enum FmtChannels chans, enum FmtType type)
68 return ChannelsFromFmt(chans) * BytesFromFmt(type);
72 typedef struct ALbuffer {
73 ALvoid *data;
75 ALsizei Frequency;
76 ALenum Format;
77 ALsizei SampleLen;
79 enum FmtChannels FmtChannels;
80 enum FmtType FmtType;
81 ALuint BytesAlloc;
83 enum UserFmtChannels OriginalChannels;
84 enum UserFmtType OriginalType;
85 ALsizei OriginalSize;
86 ALsizei OriginalAlign;
88 ALsizei LoopStart;
89 ALsizei LoopEnd;
91 ATOMIC(ALsizei) UnpackAlign;
92 ATOMIC(ALsizei) PackAlign;
94 /* Number of times buffer was attached to a source (deletion can only occur when 0) */
95 RefCount ref;
97 RWLock lock;
99 /* Self ID */
100 ALuint id;
101 } ALbuffer;
103 ALbuffer *NewBuffer(ALCcontext *context);
104 void DeleteBuffer(ALCdevice *device, ALbuffer *buffer);
106 ALenum LoadData(ALbuffer *buffer, ALuint freq, ALenum NewFormat, ALsizei frames, enum UserFmtChannels SrcChannels, enum UserFmtType SrcType, const ALvoid *data, ALsizei align, ALboolean storesrc);
108 inline void LockBuffersRead(ALCdevice *device)
109 { LockUIntMapRead(&device->BufferMap); }
110 inline void UnlockBuffersRead(ALCdevice *device)
111 { UnlockUIntMapRead(&device->BufferMap); }
112 inline void LockBuffersWrite(ALCdevice *device)
113 { LockUIntMapWrite(&device->BufferMap); }
114 inline void UnlockBuffersWrite(ALCdevice *device)
115 { UnlockUIntMapWrite(&device->BufferMap); }
117 inline struct ALbuffer *LookupBuffer(ALCdevice *device, ALuint id)
118 { return (struct ALbuffer*)LookupUIntMapKeyNoLock(&device->BufferMap, id); }
119 inline struct ALbuffer *RemoveBuffer(ALCdevice *device, ALuint id)
120 { return (struct ALbuffer*)RemoveUIntMapKeyNoLock(&device->BufferMap, id); }
122 ALvoid ReleaseALBuffers(ALCdevice *device);
124 #ifdef __cplusplus
126 #endif
128 #endif