Avoid looking in the buffer queue to find the frame size

This commit is contained in:
Chris Robinson 2011-05-18 17:02:18 -07:00
parent 35c38e0b5e
commit c00b2f9254
3 changed files with 4 additions and 15 deletions

View File

@ -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;

View File

@ -87,6 +87,7 @@ typedef struct ALsource
ALint lSourceType;
ALuint NumChannels;
ALuint SampleSize;
/* HRTF info */
ALfloat HrtfHistory[MAXCHANNELS][HRTF_LENGTH];

View File

@ -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