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 {
|
2012-01-10 00:41:05 -08:00
|
|
|
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,
|
2012-01-10 00:58:07 -08:00
|
|
|
UserFmtMulaw,
|
|
|
|
UserFmtAlaw,
|
|
|
|
UserFmtIMA4,
|
2014-03-04 22:44:30 -08:00
|
|
|
UserFmtMSADPCM,
|
2010-11-27 15:33:33 -08:00
|
|
|
};
|
2010-12-03 22:33:41 -08:00
|
|
|
enum UserFmtChannels {
|
2012-01-10 00:41:05 -08:00
|
|
|
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) */
|
2010-11-27 15:33:33 -08:00
|
|
|
};
|
|
|
|
|
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-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
|
|
|
};
|
2013-07-23 00:13:15 -07: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)
|
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
|
|
|
|
2013-10-07 05:41:41 -07:00
|
|
|
typedef struct ALbuffer {
|
2010-09-22 17:19:35 -07:00
|
|
|
ALvoid *data;
|
2009-10-22 08:53:59 -07:00
|
|
|
|
2011-10-03 10:07:50 -07:00
|
|
|
ALsizei Frequency;
|
|
|
|
ALenum Format;
|
|
|
|
ALsizei SampleLen;
|
|
|
|
|
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;
|
2011-10-01 19:52:07 -07:00
|
|
|
ALsizei OriginalSize;
|
2014-03-03 17:05:08 -08:00
|
|
|
ALsizei OriginalAlign;
|
2010-05-12 01:36:09 -07:00
|
|
|
|
2010-05-13 02:03:48 -07:00
|
|
|
ALsizei LoopStart;
|
|
|
|
ALsizei LoopEnd;
|
|
|
|
|
Add an extension to alter the block alignment for buffer unpack/pack ops
This is for unpacking (reading, e.g. alBufferData) and packing (writing, e.g.
alGetBufferSamplesSOFT) operations. The alignments are specified in sample
frames, with 0 meaning the default (65 for IMA4, 1 otherwise). IMA4 alignment
must be a multiple of 8, plus 1 (e.g. alignment = n*8 + 1), otherwise an error
will occur during (un)packing. Chenging the block alignment does not affect
already-loaded sample data, only future unpack/pack operations... so for
example, this is perfectly valid:
// Load mono IMA4 data with a block alignment of 1024 bytes, or 2041 sample
// frames.
alBufferi(buffer, AL_UNPACK_BLOCK_ALIGNMENT_SOFT, 2041);
alBufferData(buffer, AL_FORMAT_MONO_IMA4, data, data_len, srate);
alBufferi(buffer, AL_UNPACK_BLOCK_ALIGNMENT_SOFT, 0);
2014-03-04 05:16:45 -08:00
|
|
|
ALsizei UnpackAlign;
|
|
|
|
ALsizei PackAlign;
|
|
|
|
|
2012-04-19 22:14:02 -07:00
|
|
|
/* Number of times buffer was attached to a source (deletion can only occur when 0) */
|
|
|
|
RefCount ref;
|
2009-10-22 08:53:59 -07:00
|
|
|
|
2011-09-11 03:57:40 -07:00
|
|
|
RWLock lock;
|
|
|
|
|
2012-04-19 22:14:02 -07:00
|
|
|
/* Self ID */
|
|
|
|
ALuint id;
|
2007-11-13 18:02:18 -08:00
|
|
|
} ALbuffer;
|
|
|
|
|
2013-11-04 13:51:19 -08:00
|
|
|
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
|