Add buffer properties to get the internal format, and the length in bytes, samples, and seconds
The provided buffer lengths correspond to the source offsets, in that the byte length specifies the end of the byte offset (ie, when the buffer is used for a static source, the offset will range between 0 (inclusive) and the byte length (exclusive)). Although an application could use the AL_SIZE, AL_CHANNELS, AL_BITS, and AL_FREQUENCY properties to find the length in samples and seconds, the byte length cannot be reliably calculated this way.
This commit is contained in:
@@ -72,6 +72,7 @@ typedef struct ALbuffer
|
||||
ALsizei size;
|
||||
|
||||
ALsizei Frequency;
|
||||
ALenum Format;
|
||||
enum FmtChannels FmtChannels;
|
||||
enum FmtType FmtType;
|
||||
|
||||
|
||||
@@ -98,6 +98,12 @@ ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffe
|
||||
#define AL_7POINT1_16 0x1211
|
||||
#define AL_7POINT1_32F 0x1212
|
||||
|
||||
/* Buffer attributes */
|
||||
#define AL_INTERNAL_FORMAT 0x2008
|
||||
#define AL_BYTE_LENGTH 0x2009
|
||||
#define AL_SAMPLE_LENGTH 0x200A
|
||||
#define AL_SEC_LENGTH 0x200B
|
||||
|
||||
typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*);
|
||||
typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*);
|
||||
typedef void (AL_APIENTRY*LPALGETBUFFERSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*);
|
||||
|
||||
+36
-1
@@ -828,6 +828,7 @@ AL_API ALvoid AL_APIENTRY alGetBufferf(ALuint buffer, ALenum eParam, ALfloat *pf
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
ALCdevice *device;
|
||||
ALbuffer *pBuffer;
|
||||
|
||||
pContext = GetContextRef();
|
||||
if(!pContext) return;
|
||||
@@ -835,12 +836,20 @@ AL_API ALvoid AL_APIENTRY alGetBufferf(ALuint buffer, ALenum eParam, ALfloat *pf
|
||||
device = pContext->Device;
|
||||
if(!pflValue)
|
||||
alSetError(pContext, AL_INVALID_VALUE);
|
||||
else if(LookupBuffer(device, buffer) == NULL)
|
||||
else if((pBuffer=LookupBuffer(device, buffer)) == NULL)
|
||||
alSetError(pContext, AL_INVALID_NAME);
|
||||
else
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
case AL_SEC_LENGTH:
|
||||
ReadLock(&pBuffer->lock);
|
||||
*pflValue = (pBuffer->size /
|
||||
FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType)) /
|
||||
(ALfloat)pBuffer->Frequency;
|
||||
ReadUnlock(&pBuffer->lock);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(pContext, AL_INVALID_ENUM);
|
||||
break;
|
||||
@@ -883,6 +892,13 @@ AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum eParam, ALfloat* pfl
|
||||
ALCcontext *pContext;
|
||||
ALCdevice *device;
|
||||
|
||||
switch(eParam)
|
||||
{
|
||||
case AL_SEC_LENGTH:
|
||||
alGetBufferf(buffer, eParam, pflValues);
|
||||
return;
|
||||
}
|
||||
|
||||
pContext = GetContextRef();
|
||||
if(!pContext) return;
|
||||
|
||||
@@ -939,6 +955,21 @@ AL_API ALvoid AL_APIENTRY alGetBufferi(ALuint buffer, ALenum eParam, ALint *plVa
|
||||
*plValue = pBuffer->size;
|
||||
break;
|
||||
|
||||
case AL_INTERNAL_FORMAT:
|
||||
*plValue = pBuffer->Format;
|
||||
break;
|
||||
|
||||
case AL_BYTE_LENGTH:
|
||||
*plValue = pBuffer->OriginalSize;
|
||||
break;
|
||||
|
||||
case AL_SAMPLE_LENGTH:
|
||||
ReadLock(&pBuffer->lock);
|
||||
*plValue = pBuffer->size /
|
||||
FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType);
|
||||
ReadUnlock(&pBuffer->lock);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(pContext, AL_INVALID_ENUM);
|
||||
break;
|
||||
@@ -988,6 +1019,9 @@ AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum eParam, ALint* plVal
|
||||
case AL_BITS:
|
||||
case AL_CHANNELS:
|
||||
case AL_SIZE:
|
||||
case AL_INTERNAL_FORMAT:
|
||||
case AL_BYTE_LENGTH:
|
||||
case AL_SAMPLE_LENGTH:
|
||||
alGetBufferi(buffer, eParam, plValues);
|
||||
return;
|
||||
}
|
||||
@@ -2038,6 +2072,7 @@ static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei f
|
||||
ALBuf->Frequency = freq;
|
||||
ALBuf->FmtChannels = DstChannels;
|
||||
ALBuf->FmtType = DstType;
|
||||
ALBuf->Format = NewFormat;
|
||||
|
||||
ALBuf->LoopStart = 0;
|
||||
ALBuf->LoopEnd = (ALsizei)(newsize / NewChannels / NewBytes);
|
||||
|
||||
@@ -190,6 +190,10 @@ static const ALenums enumeration[] = {
|
||||
{ "AL_BITS", AL_BITS },
|
||||
{ "AL_CHANNELS", AL_CHANNELS },
|
||||
{ "AL_SIZE", AL_SIZE },
|
||||
{ "AL_INTERNAL_FORMAT", AL_INTERNAL_FORMAT },
|
||||
{ "AL_BYTE_LENGTH", AL_BYTE_LENGTH },
|
||||
{ "AL_SAMPLE_LENGTH", AL_SAMPLE_LENGTH },
|
||||
{ "AL_SEC_LENGTH", AL_SEC_LENGTH },
|
||||
|
||||
// Buffer States (not supported yet)
|
||||
{ "AL_UNUSED", AL_UNUSED },
|
||||
|
||||
Reference in New Issue
Block a user