112 lines
2.7 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,
UserFmtByte3 = AL_BYTE3_SOFT,
UserFmtUByte3 = AL_UNSIGNED_BYTE3_SOFT,
UserFmtMulaw,
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) */
};
2014-05-23 10:00:58 -07:00
ALuint BytesFromUserFmt(enum UserFmtType type) DECL_CONST;
ALuint ChannelsFromUserFmt(enum UserFmtChannels chans) DECL_CONST;
2013-11-04 12:12:31 -08:00
inline ALuint 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 {
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 {
FmtMono = UserFmtMono,
2010-12-03 22:33:41 -08:00
FmtStereo = UserFmtStereo,
FmtRear = UserFmtRear,
FmtQuad = UserFmtQuad,
FmtX51 = UserFmtX51,
FmtX61 = UserFmtX61,
FmtX71 = UserFmtX71,
2010-11-26 23:42:30 -08:00
};
#define MAX_INPUT_CHANNELS (8)
2010-11-26 23:42:30 -08:00
2014-05-23 10:00:58 -07:00
ALuint BytesFromFmt(enum FmtType type) DECL_CONST;
ALuint ChannelsFromFmt(enum FmtChannels chans) DECL_CONST;
2013-11-04 12:12:31 -08:00
inline ALuint 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;
2010-12-03 22:33:41 -08:00
enum UserFmtChannels OriginalChannels;
enum UserFmtType OriginalType;
ALsizei OriginalSize;
ALsizei OriginalAlign;
ALsizei LoopStart;
ALsizei LoopEnd;
ALsizei UnpackAlign;
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;
inline struct ALbuffer *LookupBuffer(ALCdevice *device, ALuint id)
{ return (struct ALbuffer*)LookupUIntMapKey(&device->BufferMap, id); }
inline struct ALbuffer *RemoveBuffer(ALCdevice *device, ALuint id)
{ return (struct ALbuffer*)RemoveUIntMapKey(&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