Remove the Buffer field from the source

This commit is contained in:
Chris Robinson 2011-08-23 09:52:01 -07:00
parent 9f25ad42c1
commit f5195ee4f2
3 changed files with 16 additions and 28 deletions

View File

@ -597,7 +597,7 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
if(Source->lSourceType == AL_STATIC) if(Source->lSourceType == AL_STATIC)
{ {
const ALbuffer *ALBuffer = Source->Buffer; const ALbuffer *ALBuffer = Source->queue->buffer;
const ALubyte *Data = ALBuffer->data; const ALubyte *Data = ALBuffer->data;
ALuint DataSize; ALuint DataSize;
ALuint pos; ALuint pos;
@ -833,7 +833,6 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
Source->BuffersPlayed = BuffersPlayed; Source->BuffersPlayed = BuffersPlayed;
Source->position = DataPosInt; Source->position = DataPosInt;
Source->position_fraction = DataPosFrac; Source->position_fraction = DataPosFrac;
Source->Buffer = BufferListItem->buffer;
Source->HrtfOffset += OutPos; Source->HrtfOffset += OutPos;
if(State == AL_PLAYING) if(State == AL_PLAYING)
{ {

View File

@ -55,8 +55,6 @@ typedef struct ALsource
ALuint position; ALuint position;
ALuint position_fraction; ALuint position_fraction;
struct ALbuffer *Buffer;
ALbufferlistitem *queue; // Linked list of buffers in queue ALbufferlistitem *queue; // Linked list of buffers in queue
ALuint BuffersInQueue; // Number of buffers in queue ALuint BuffersInQueue; // Number of buffers in queue
ALuint BuffersPlayed; // Number of buffers played on this loop ALuint BuffersPlayed; // Number of buffers played on this loop

View File

@ -607,8 +607,6 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
} }
Source->BuffersPlayed = 0; Source->BuffersPlayed = 0;
// Update AL_BUFFER parameter
Source->Buffer = buffer;
Source->NeedsUpdate = AL_TRUE; Source->NeedsUpdate = AL_TRUE;
} }
else else
@ -1078,6 +1076,7 @@ AL_API ALvoid AL_APIENTRY alGetSourcefv(ALuint source, ALenum eParam, ALfloat *p
AL_API ALvoid AL_APIENTRY alGetSourcei(ALuint source, ALenum eParam, ALint *plValue) AL_API ALvoid AL_APIENTRY alGetSourcei(ALuint source, ALenum eParam, ALint *plValue)
{ {
ALbufferlistitem *BufferList;
ALCcontext *pContext; ALCcontext *pContext;
ALsource *Source; ALsource *Source;
ALdouble Offsets[2]; ALdouble Offsets[2];
@ -1121,7 +1120,18 @@ AL_API ALvoid AL_APIENTRY alGetSourcei(ALuint source, ALenum eParam, ALint *plVa
break; break;
case AL_BUFFER: case AL_BUFFER:
*plValue = (Source->Buffer ? Source->Buffer->buffer : 0); BufferList = Source->queue;
if(Source->lSourceType != AL_STATIC)
{
ALuint i = Source->BuffersPlayed;
while(i > 0)
{
BufferList = BufferList->next;
i--;
}
}
*plValue = ((BufferList && BufferList->buffer) ?
BufferList->buffer->buffer : 0);
break; break;
case AL_SOURCE_STATE: case AL_SOURCE_STATE:
@ -1645,11 +1655,7 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
} }
if(Source->queue == NULL) if(Source->queue == NULL)
{
Source->queue = BufferListStart; Source->queue = BufferListStart;
// Update Current Buffer
Source->Buffer = BufferListStart->buffer;
}
else else
{ {
// Find end of queue // Find end of queue
@ -1708,6 +1714,8 @@ AL_API ALvoid AL_APIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALui
{ {
BufferList = Source->queue; BufferList = Source->queue;
Source->queue = BufferList->next; Source->queue = BufferList->next;
Source->BuffersInQueue--;
Source->BuffersPlayed--;
if(BufferList->buffer) if(BufferList->buffer)
{ {
@ -1721,19 +1729,10 @@ AL_API ALvoid AL_APIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALui
// Release memory for buffer list item // Release memory for buffer list item
free(BufferList); free(BufferList);
Source->BuffersInQueue--;
} }
if(Source->queue) if(Source->queue)
Source->queue->prev = NULL; Source->queue->prev = NULL;
if(Source->state != AL_PLAYING)
{
if(Source->queue)
Source->Buffer = Source->queue->buffer;
else
Source->Buffer = NULL;
}
Source->BuffersPlayed -= n;
done: done:
UnlockContext(Context); UnlockContext(Context);
@ -1783,8 +1782,6 @@ static ALvoid InitSourceParams(ALsource *Source)
Source->NeedsUpdate = AL_TRUE; Source->NeedsUpdate = AL_TRUE;
Source->Buffer = NULL;
Source->HrtfMoving = AL_FALSE; Source->HrtfMoving = AL_FALSE;
Source->HrtfCounter = 0; Source->HrtfCounter = 0;
} }
@ -1839,8 +1836,6 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
Source->position = 0; Source->position = 0;
Source->position_fraction = 0; Source->position_fraction = 0;
Source->BuffersPlayed = 0; Source->BuffersPlayed = 0;
Source->Buffer = Source->queue->buffer;
} }
else else
Source->state = AL_PLAYING; Source->state = AL_PLAYING;
@ -1885,8 +1880,6 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
Source->position = 0; Source->position = 0;
Source->position_fraction = 0; Source->position_fraction = 0;
Source->BuffersPlayed = 0; Source->BuffersPlayed = 0;
if(Source->queue)
Source->Buffer = Source->queue->buffer;
Source->HrtfMoving = AL_FALSE; Source->HrtfMoving = AL_FALSE;
Source->HrtfCounter = 0; Source->HrtfCounter = 0;
} }
@ -2050,8 +2043,6 @@ ALboolean ApplyOffset(ALsource *Source)
else if(lTotalBufferSize <= lByteOffset) else if(lTotalBufferSize <= lByteOffset)
{ {
// Offset is within this buffer // Offset is within this buffer
// Set Current Buffer
Source->Buffer = BufferList->buffer;
Source->BuffersPlayed = BuffersPlayed; Source->BuffersPlayed = BuffersPlayed;
// SW Mixer Positions are in Samples // SW Mixer Positions are in Samples