2007-11-13 18:02:18 -08:00
|
|
|
#ifndef _AL_BUFFER_H_
|
|
|
|
#define _AL_BUFFER_H_
|
|
|
|
|
|
|
|
#include "AL/al.h"
|
|
|
|
|
|
|
|
#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 {
|
2011-03-16 05:47:07 -07:00
|
|
|
UserFmtByte = AL_BYTE,
|
|
|
|
UserFmtUByte = AL_UNSIGNED_BYTE,
|
|
|
|
UserFmtShort = AL_SHORT,
|
|
|
|
UserFmtUShort = AL_UNSIGNED_SHORT,
|
|
|
|
UserFmtInt = AL_INT,
|
|
|
|
UserFmtUInt = AL_UNSIGNED_INT,
|
|
|
|
UserFmtFloat = AL_FLOAT,
|
|
|
|
UserFmtDouble = AL_DOUBLE,
|
|
|
|
UserFmtMulaw = AL_MULAW,
|
2011-04-26 18:17:50 -07:00
|
|
|
UserFmtIMA4 = AL_IMA4,
|
|
|
|
UserFmtByte3 = AL_BYTE3,
|
|
|
|
UserFmtUByte3 = AL_UNSIGNED_BYTE3,
|
2010-11-27 15:33:33 -08:00
|
|
|
};
|
2010-12-03 22:33:41 -08:00
|
|
|
enum UserFmtChannels {
|
2011-03-16 05:47:07 -07:00
|
|
|
UserFmtMono = AL_MONO,
|
|
|
|
UserFmtStereo = AL_STEREO,
|
|
|
|
UserFmtRear = AL_REAR,
|
|
|
|
UserFmtQuad = AL_QUAD,
|
|
|
|
UserFmtX51 = AL_5POINT1, /* (WFX order) */
|
|
|
|
UserFmtX61 = AL_6POINT1, /* (WFX order) */
|
|
|
|
UserFmtX71 = AL_7POINT1 /* (WFX order) */
|
2010-11-27 15:33:33 -08:00
|
|
|
};
|
|
|
|
|
2010-12-03 22:33:41 -08:00
|
|
|
ALboolean DecomposeUserFormat(ALenum format, enum UserFmtChannels *chans,
|
|
|
|
enum UserFmtType *type);
|
|
|
|
ALuint BytesFromUserFmt(enum UserFmtType type);
|
|
|
|
ALuint ChannelsFromUserFmt(enum UserFmtChannels chans);
|
|
|
|
static __inline ALuint FrameSizeFromUserFmt(enum UserFmtChannels chans,
|
|
|
|
enum UserFmtType type)
|
2010-11-28 12:53:35 -08:00
|
|
|
{
|
2010-12-03 22:33:41 -08:00
|
|
|
return ChannelsFromUserFmt(chans) * BytesFromUserFmt(type);
|
2010-11-28 12:53:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-27 15:33:33 -08:00
|
|
|
/* Storable formats */
|
2010-11-26 23:42:30 -08:00
|
|
|
enum FmtType {
|
2011-05-05 18:54:10 -07:00
|
|
|
FmtByte = UserFmtByte,
|
2010-12-03 22:33:41 -08:00
|
|
|
FmtShort = UserFmtShort,
|
|
|
|
FmtFloat = UserFmtFloat,
|
2010-11-26 23:42:30 -08:00
|
|
|
};
|
|
|
|
enum FmtChannels {
|
2011-03-16 05:47:07 -07:00
|
|
|
FmtMono = UserFmtMono,
|
2010-12-03 22:33:41 -08:00
|
|
|
FmtStereo = UserFmtStereo,
|
2011-03-16 05:47:07 -07:00
|
|
|
FmtRear = UserFmtRear,
|
|
|
|
FmtQuad = UserFmtQuad,
|
|
|
|
FmtX51 = UserFmtX51,
|
|
|
|
FmtX61 = UserFmtX61,
|
|
|
|
FmtX71 = UserFmtX71,
|
2010-11-26 23:42:30 -08:00
|
|
|
};
|
|
|
|
|
2010-11-29 20:34:33 -08:00
|
|
|
ALboolean DecomposeFormat(ALenum format, enum FmtChannels *chans, enum FmtType *type);
|
2010-11-29 15:01:27 -08:00
|
|
|
ALuint BytesFromFmt(enum FmtType type);
|
|
|
|
ALuint ChannelsFromFmt(enum FmtChannels chans);
|
2010-11-29 19:48:18 -08:00
|
|
|
static __inline ALuint FrameSizeFromFmt(enum FmtChannels chans, enum FmtType type)
|
2010-11-28 12:53:35 -08:00
|
|
|
{
|
2010-11-29 19:48:18 -08:00
|
|
|
return ChannelsFromFmt(chans) * BytesFromFmt(type);
|
2010-11-28 12:53:35 -08:00
|
|
|
}
|
|
|
|
|
2010-11-26 23:42:30 -08:00
|
|
|
|
2009-08-15 09:14:08 -07:00
|
|
|
typedef struct ALbuffer
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2010-09-22 17:19:35 -07:00
|
|
|
ALvoid *data;
|
2007-11-13 18:02:18 -08:00
|
|
|
ALsizei size;
|
2009-10-22 08:53:59 -07:00
|
|
|
|
2010-11-28 13:08:51 -08:00
|
|
|
ALsizei Frequency;
|
2010-11-28 12:53:35 -08:00
|
|
|
enum FmtChannels FmtChannels;
|
2010-11-29 15:19:39 -08:00
|
|
|
enum FmtType FmtType;
|
2009-10-22 08:53:59 -07:00
|
|
|
|
2010-12-03 22:33:41 -08:00
|
|
|
enum UserFmtChannels OriginalChannels;
|
|
|
|
enum UserFmtType OriginalType;
|
2010-11-29 19:27:33 -08:00
|
|
|
ALsizei OriginalSize;
|
|
|
|
ALsizei OriginalAlign;
|
2010-05-12 01:36:09 -07:00
|
|
|
|
2010-05-13 02:03:48 -07:00
|
|
|
ALsizei LoopStart;
|
|
|
|
ALsizei LoopEnd;
|
|
|
|
|
2011-08-29 23:05:47 -07:00
|
|
|
RefCount ref; // Number of sources using this buffer (deletion can only occur when this is 0)
|
2009-10-22 08:53:59 -07:00
|
|
|
|
2011-09-11 03:57:40 -07:00
|
|
|
RWLock lock;
|
|
|
|
|
2009-10-22 08:53:59 -07:00
|
|
|
// Index to itself
|
|
|
|
ALuint buffer;
|
2007-11-13 18:02:18 -08:00
|
|
|
} ALbuffer;
|
|
|
|
|
2009-08-15 09:14:08 -07:00
|
|
|
ALvoid ReleaseALBuffers(ALCdevice *device);
|
2007-11-13 18:02:18 -08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|