aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALu.c8
-rw-r--r--OpenAL32/Include/alBuffer.h11
-rw-r--r--OpenAL32/alBuffer.c18
-rw-r--r--OpenAL32/alSource.c8
4 files changed, 17 insertions, 28 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index a782ac16..2eb8d182 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -957,7 +957,8 @@ another_source:
ALbuffer *NextBuf = BufferListItem->next->buffer;
if(NextBuf && NextBuf->data)
{
- ALuint ulExtraSamples = min(NextBuf->size, (ALint)(ALBuffer->padding*Channels*Bytes));
+ ALint ulExtraSamples = BUFFER_PADDING*Channels*Bytes;
+ ulExtraSamples = min(NextBuf->size, ulExtraSamples);
memcpy(&Data[DataSize*Channels], NextBuf->data, ulExtraSamples);
}
}
@@ -966,12 +967,13 @@ another_source:
ALbuffer *NextBuf = ALSource->queue->buffer;
if(NextBuf && NextBuf->data)
{
- ALuint ulExtraSamples = min(NextBuf->size, (ALint)(ALBuffer->padding*Channels*Bytes));
+ ALint ulExtraSamples = BUFFER_PADDING*Channels*Bytes;
+ ulExtraSamples = min(NextBuf->size, ulExtraSamples);
memcpy(&Data[DataSize*Channels], NextBuf->data, ulExtraSamples);
}
}
else
- memset(&Data[DataSize*Channels], 0, (ALBuffer->padding*Channels*Bytes));
+ memset(&Data[DataSize*Channels], 0, (BUFFER_PADDING*Channels*Bytes));
/* Compute the gain steps for each output channel */
for(i = 0;i < OUTPUTCHANNELS;i++)
diff --git a/OpenAL32/Include/alBuffer.h b/OpenAL32/Include/alBuffer.h
index b7d36642..c35caf3d 100644
--- a/OpenAL32/Include/alBuffer.h
+++ b/OpenAL32/Include/alBuffer.h
@@ -7,21 +7,16 @@
extern "C" {
#endif
-#define UNUSED 0
-#define PENDING 1
-#define PROCESSED 2
+#define BUFFER_PADDING 2
typedef struct ALbuffer
{
- ALenum format;
- ALenum eOriginalFormat;
-
ALshort *data;
ALsizei size;
+ ALenum format;
+ ALenum eOriginalFormat;
ALsizei frequency;
- ALsizei padding;
- ALenum state;
ALuint refcount; // Number of sources using this buffer (deletion can only occur when this is 0)
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c
index 2ebf42b0..66d6cee4 100644
--- a/OpenAL32/alBuffer.c
+++ b/OpenAL32/alBuffer.c
@@ -108,7 +108,6 @@ ALAPI ALvoid ALAPIENTRY alGenBuffers(ALsizei n,ALuint *puiBuffers)
puiBuffers[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
(*list)->buffer = puiBuffers[i];
- (*list)->state = UNUSED;
device->BufferCount++;
i++;
@@ -263,7 +262,6 @@ ALAPI ALboolean ALAPIENTRY alIsBuffer(ALuint uiBuffer)
ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *data,ALsizei size,ALsizei freq)
{
ALCcontext *Context;
- ALsizei padding = 2;
ALbuffer *ALBuf;
ALvoid *temp;
@@ -326,19 +324,18 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d
size *= 2;
// Samples are converted to 16 bit here
- temp = realloc(ALBuf->data, (padding*NewChannels + size) * sizeof(ALshort));
+ temp = realloc(ALBuf->data, (BUFFER_PADDING*NewChannels + size) * sizeof(ALshort));
if(temp)
{
ALBuf->data = temp;
ConvertDataRear(ALBuf->data, data, OrigBytes, size);
- memset(&(ALBuf->data[size]), 0, padding*NewChannels*sizeof(ALshort));
+ memset(&(ALBuf->data[size]), 0, BUFFER_PADDING*NewChannels*sizeof(ALshort));
ALBuf->format = NewFormat;
ALBuf->eOriginalFormat = format;
ALBuf->size = size*sizeof(ALshort);
ALBuf->frequency = freq;
- ALBuf->padding = padding;
}
else
alSetError(AL_OUT_OF_MEMORY);
@@ -387,19 +384,18 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d
size *= 65;
// Allocate extra padding samples
- temp = realloc(ALBuf->data, (padding*OrigChans + size)*sizeof(ALshort));
+ temp = realloc(ALBuf->data, (BUFFER_PADDING*OrigChans + size)*sizeof(ALshort));
if(temp)
{
ALBuf->data = temp;
ConvertDataIMA4(ALBuf->data, data, OrigChans, size/65);
- memset(&(ALBuf->data[size]), 0, padding*sizeof(ALshort)*OrigChans);
+ memset(&(ALBuf->data[size]), 0, BUFFER_PADDING*sizeof(ALshort)*OrigChans);
ALBuf->format = ((OrigChans==1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16);
ALBuf->eOriginalFormat = format;
ALBuf->size = size*sizeof(ALshort);
ALBuf->frequency = freq;
- ALBuf->padding = padding;
}
else
alSetError(AL_OUT_OF_MEMORY);
@@ -942,7 +938,6 @@ static void LoadData(ALbuffer *ALBuf, const ALubyte *data, ALsizei size, ALuint
ALuint NewChannels = aluChannelsFromFormat(NewFormat);
ALuint OrigBytes = aluBytesFromFormat(OrigFormat);
ALuint OrigChannels = aluChannelsFromFormat(OrigFormat);
- ALsizei padding = 2;
ALvoid *temp;
assert(aluBytesFromFormat(NewFormat) == 2);
@@ -956,19 +951,18 @@ static void LoadData(ALbuffer *ALBuf, const ALubyte *data, ALsizei size, ALuint
// Samples are converted to 16 bit here
size /= OrigBytes;
- temp = realloc(ALBuf->data, (padding*NewChannels + size) * sizeof(ALshort));
+ temp = realloc(ALBuf->data, (BUFFER_PADDING*NewChannels + size) * sizeof(ALshort));
if(temp)
{
ALBuf->data = temp;
ConvertData(ALBuf->data, data, OrigBytes, size);
- memset(&(ALBuf->data[size]), 0, padding*NewChannels*sizeof(ALshort));
+ memset(&(ALBuf->data[size]), 0, BUFFER_PADDING*NewChannels*sizeof(ALshort));
ALBuf->format = NewFormat;
ALBuf->eOriginalFormat = OrigFormat;
ALBuf->size = size*sizeof(ALshort);
ALBuf->frequency = freq;
- ALBuf->padding = padding;
}
else
alSetError(AL_OUT_OF_MEMORY);
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index b606d9fd..2e725081 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -530,7 +530,7 @@ ALAPI ALvoid ALAPIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
// Add the buffer to the queue (as long as it is NOT the NULL buffer)
if(lValue != 0)
{
- buffer = (ALbuffer*)(ALTHUNK_LOOKUPENTRY(lValue));
+ buffer = (ALbuffer*)ALTHUNK_LOOKUPENTRY(lValue);
// Source is now in STATIC mode
pSource->lSourceType = AL_STATIC;
@@ -1586,8 +1586,7 @@ ALAPI ALvoid ALAPIENTRY alSourceQueueBuffers( ALuint source, ALsizei n, const AL
// Change Source Type
ALSource->lSourceType = AL_STREAMING;
- if(buffers[0])
- buffer = (ALbuffer*)ALTHUNK_LOOKUPENTRY(buffers[0]);
+ buffer = (ALbuffer*)ALTHUNK_LOOKUPENTRY(buffers[0]);
// All buffers are valid - so add them to the list
ALBufferListStart = malloc(sizeof(ALbufferlistitem));
@@ -1601,8 +1600,7 @@ ALAPI ALvoid ALAPIENTRY alSourceQueueBuffers( ALuint source, ALsizei n, const AL
for(i = 1; i < n; i++)
{
- if(buffers[i])
- buffer = (ALbuffer*)ALTHUNK_LOOKUPENTRY(buffers[i]);
+ buffer = (ALbuffer*)ALTHUNK_LOOKUPENTRY(buffers[i]);
ALBufferList->next = malloc(sizeof(ALbufferlistitem));
ALBufferList->next->buffer = buffer;