129 lines
3.4 KiB
C
Raw Normal View History

2007-11-13 18:02:18 -08:00
#ifndef _AL_BUFFER_H_
#define _AL_BUFFER_H_
2012-09-14 02:42:36 -07:00
#include "alMain.h"
2007-11-13 18:02:18 -08:00
#ifdef __cplusplus
extern "C" {
#endif
2011-05-05 22:36:26 -07:00
/* User formats */
2010-12-03 22:33:41 -08:00
enum UserFmtType {
UserFmtByte = AL_BYTE_SOFT,
UserFmtUByte = AL_UNSIGNED_BYTE_SOFT,
UserFmtShort = AL_SHORT_SOFT,
UserFmtUShort = AL_UNSIGNED_SHORT_SOFT,
UserFmtInt = AL_INT_SOFT,
UserFmtUInt = AL_UNSIGNED_INT_SOFT,
UserFmtFloat = AL_FLOAT_SOFT,
UserFmtDouble = AL_DOUBLE_SOFT,
UserFmtMulaw = 0x10000000,
UserFmtAlaw,
UserFmtIMA4,
UserFmtMSADPCM,
};
2010-12-03 22:33:41 -08:00
enum UserFmtChannels {
UserFmtMono = AL_MONO_SOFT,
UserFmtStereo = AL_STEREO_SOFT,
UserFmtRear = AL_REAR_SOFT,
UserFmtQuad = AL_QUAD_SOFT,
UserFmtX51 = AL_5POINT1_SOFT, /* (WFX order) */
UserFmtX61 = AL_6POINT1_SOFT, /* (WFX order) */
UserFmtX71 = AL_7POINT1_SOFT, /* (WFX order) */
UserFmtBFormat2D = 0x20000000, /* WXY */
UserFmtBFormat3D, /* WXYZ */
};
2017-01-18 07:13:23 -08:00
ALsizei BytesFromUserFmt(enum UserFmtType type);
ALsizei ChannelsFromUserFmt(enum UserFmtChannels chans);
inline ALsizei FrameSizeFromUserFmt(enum UserFmtChannels chans, enum UserFmtType type)
{
2010-12-03 22:33:41 -08:00
return ChannelsFromUserFmt(chans) * BytesFromUserFmt(type);
}
/* Storable formats */
2010-11-26 23:42:30 -08:00
enum FmtType {
FmtUByte = UserFmtUByte,
2010-12-03 22:33:41 -08:00
FmtShort = UserFmtShort,
FmtFloat = UserFmtFloat,
FmtMulaw = UserFmtMulaw,
FmtAlaw = UserFmtAlaw,
2010-11-26 23:42:30 -08:00
};
enum FmtChannels {
FmtMono = UserFmtMono,
2010-12-03 22:33:41 -08:00
FmtStereo = UserFmtStereo,
FmtRear = UserFmtRear,
FmtQuad = UserFmtQuad,
FmtX51 = UserFmtX51,
FmtX61 = UserFmtX61,
FmtX71 = UserFmtX71,
FmtBFormat2D = UserFmtBFormat2D,
FmtBFormat3D = UserFmtBFormat3D,
2010-11-26 23:42:30 -08:00
};
#define MAX_INPUT_CHANNELS (8)
2010-11-26 23:42:30 -08:00
2017-01-18 07:13:23 -08:00
ALsizei BytesFromFmt(enum FmtType type);
ALsizei ChannelsFromFmt(enum FmtChannels chans);
inline ALsizei FrameSizeFromFmt(enum FmtChannels chans, enum FmtType type)
{
return ChannelsFromFmt(chans) * BytesFromFmt(type);
}
2010-11-26 23:42:30 -08:00
typedef struct ALbuffer {
ALvoid *data;
ALsizei Frequency;
ALenum Format;
ALsizei SampleLen;
enum FmtChannels FmtChannels;
enum FmtType FmtType;
ALuint BytesAlloc;
2010-12-03 22:33:41 -08:00
enum UserFmtChannels OriginalChannels;
enum UserFmtType OriginalType;
ALsizei OriginalSize;
ALsizei OriginalAlign;
2017-01-18 07:13:23 -08:00
ALsizei LoopStart;
ALsizei LoopEnd;
ATOMIC(ALsizei) UnpackAlign;
ATOMIC(ALsizei) PackAlign;
/* Number of times buffer was attached to a source (deletion can only occur when 0) */
RefCount ref;
RWLock lock;
/* Self ID */
ALuint id;
2007-11-13 18:02:18 -08:00
} ALbuffer;
ALbuffer *NewBuffer(ALCcontext *context);
2014-06-30 00:10:40 -07:00
void DeleteBuffer(ALCdevice *device, ALbuffer *buffer);
inline void LockBuffersRead(ALCdevice *device)
{ LockUIntMapRead(&device->BufferMap); }
inline void UnlockBuffersRead(ALCdevice *device)
{ UnlockUIntMapRead(&device->BufferMap); }
inline void LockBuffersWrite(ALCdevice *device)
{ LockUIntMapWrite(&device->BufferMap); }
inline void UnlockBuffersWrite(ALCdevice *device)
{ UnlockUIntMapWrite(&device->BufferMap); }
inline struct ALbuffer *LookupBuffer(ALCdevice *device, ALuint id)
{ return (struct ALbuffer*)LookupUIntMapKeyNoLock(&device->BufferMap, id); }
inline struct ALbuffer *RemoveBuffer(ALCdevice *device, ALuint id)
{ return (struct ALbuffer*)RemoveUIntMapKeyNoLock(&device->BufferMap, id); }
2009-08-15 09:14:08 -07:00
ALvoid ReleaseALBuffers(ALCdevice *device);
2007-11-13 18:02:18 -08:00
#ifdef __cplusplus
}
#endif
#endif