summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-05-18 17:02:18 -0700
committerChris Robinson <[email protected]>2011-05-18 17:02:18 -0700
commitc00b2f92542f232cc6d8da90dcdcc562ee04e3ff (patch)
treed820f0b5e063026ec9018905ebb266d86e8f4d58
parent35c38e0b5eb84932bdac2cff4908709064867852 (diff)
Avoid looking in the buffer queue to find the frame size
-rw-r--r--Alc/mixer.c16
-rw-r--r--OpenAL32/Include/alSource.h1
-rw-r--r--OpenAL32/alSource.c2
3 files changed, 4 insertions, 15 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c
index e427362c..61dfe00b 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -446,21 +446,7 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
Looping = Source->bLooping;
increment = Source->Params.Step;
Resampler = Source->Resampler;
-
- /* Get buffer info */
- FrameSize = 0;
- BufferListItem = Source->queue;
- for(i = 0;i < Source->BuffersInQueue;i++)
- {
- const ALbuffer *ALBuffer;
- if((ALBuffer=BufferListItem->buffer) != NULL)
- {
- FrameSize = FrameSizeFromFmt(ALBuffer->FmtChannels,
- ALBuffer->FmtType);
- break;
- }
- BufferListItem = BufferListItem->next;
- }
+ FrameSize = Source->NumChannels * Source->SampleSize;
/* Get current buffer queue item */
BufferListItem = Source->queue;
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h
index 806019e0..53d7f53c 100644
--- a/OpenAL32/Include/alSource.h
+++ b/OpenAL32/Include/alSource.h
@@ -87,6 +87,7 @@ typedef struct ALsource
ALint lSourceType;
ALuint NumChannels;
+ ALuint SampleSize;
/* HRTF info */
ALfloat HrtfHistory[MAXCHANNELS][HRTF_LENGTH];
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 11f472c2..6c6bf44b 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -567,6 +567,7 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
Source->BuffersInQueue = 1;
Source->NumChannels = ChannelsFromFmt(buffer->FmtChannels);
+ Source->SampleSize = BytesFromFmt(buffer->FmtType);
if(buffer->FmtChannels == FmtMono)
Source->Update = CalcSourceParams;
else
@@ -1613,6 +1614,7 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
BufferFmt = buffer;
Source->NumChannels = ChannelsFromFmt(buffer->FmtChannels);
+ Source->SampleSize = BytesFromFmt(buffer->FmtType);
if(buffer->FmtChannels == FmtMono)
Source->Update = CalcSourceParams;
else