Remove unneeded bufferlistitem properties
This commit is contained in:
parent
bbccf76b45
commit
1665595138
24
Alc/ALu.c
24
Alc/ALu.c
@ -1130,11 +1130,7 @@ another_source:
|
|||||||
{
|
{
|
||||||
BufferListItem = ALSource->queue;
|
BufferListItem = ALSource->queue;
|
||||||
for(i = 0;i <= ALSource->BuffersPlayed && BufferListItem;i++)
|
for(i = 0;i <= ALSource->BuffersPlayed && BufferListItem;i++)
|
||||||
{
|
|
||||||
if(!Looping)
|
|
||||||
BufferListItem->bufferstate = PROCESSED;
|
|
||||||
BufferListItem = BufferListItem->next;
|
BufferListItem = BufferListItem->next;
|
||||||
}
|
|
||||||
if(BufferListItem)
|
if(BufferListItem)
|
||||||
ALSource->Buffer = BufferListItem->buffer;
|
ALSource->Buffer = BufferListItem->buffer;
|
||||||
ALSource->position = DataPosInt-DataSize;
|
ALSource->position = DataPosInt-DataSize;
|
||||||
@ -1148,12 +1144,6 @@ another_source:
|
|||||||
/* alSourceStop */
|
/* alSourceStop */
|
||||||
ALSource->state = AL_STOPPED;
|
ALSource->state = AL_STOPPED;
|
||||||
ALSource->BuffersPlayed = ALSource->BuffersInQueue;
|
ALSource->BuffersPlayed = ALSource->BuffersInQueue;
|
||||||
BufferListItem = ALSource->queue;
|
|
||||||
while(BufferListItem != NULL)
|
|
||||||
{
|
|
||||||
BufferListItem->bufferstate = PROCESSED;
|
|
||||||
BufferListItem = BufferListItem->next;
|
|
||||||
}
|
|
||||||
ALSource->position = 0;
|
ALSource->position = 0;
|
||||||
ALSource->position_fraction = 0;
|
ALSource->position_fraction = 0;
|
||||||
}
|
}
|
||||||
@ -1163,12 +1153,6 @@ another_source:
|
|||||||
/* alSourcePlay */
|
/* alSourcePlay */
|
||||||
ALSource->state = AL_PLAYING;
|
ALSource->state = AL_PLAYING;
|
||||||
ALSource->BuffersPlayed = 0;
|
ALSource->BuffersPlayed = 0;
|
||||||
BufferListItem = ALSource->queue;
|
|
||||||
while(BufferListItem != NULL)
|
|
||||||
{
|
|
||||||
BufferListItem->bufferstate = PENDING;
|
|
||||||
BufferListItem = BufferListItem->next;
|
|
||||||
}
|
|
||||||
ALSource->Buffer = ALSource->queue->buffer;
|
ALSource->Buffer = ALSource->queue->buffer;
|
||||||
|
|
||||||
if(ALSource->BuffersInQueue == 1)
|
if(ALSource->BuffersInQueue == 1)
|
||||||
@ -1387,16 +1371,8 @@ ALvoid aluHandleDisconnect(ALCdevice *device)
|
|||||||
{
|
{
|
||||||
if(source->state == AL_PLAYING)
|
if(source->state == AL_PLAYING)
|
||||||
{
|
{
|
||||||
ALbufferlistitem *BufferListItem;
|
|
||||||
|
|
||||||
source->state = AL_STOPPED;
|
source->state = AL_STOPPED;
|
||||||
source->BuffersPlayed = source->BuffersInQueue;
|
source->BuffersPlayed = source->BuffersInQueue;
|
||||||
BufferListItem = source->queue;
|
|
||||||
while(BufferListItem != NULL)
|
|
||||||
{
|
|
||||||
BufferListItem->bufferstate = PROCESSED;
|
|
||||||
BufferListItem = BufferListItem->next;
|
|
||||||
}
|
|
||||||
source->position = 0;
|
source->position = 0;
|
||||||
source->position_fraction = 0;
|
source->position_fraction = 0;
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,6 @@ extern "C" {
|
|||||||
typedef struct ALbufferlistitem
|
typedef struct ALbufferlistitem
|
||||||
{
|
{
|
||||||
struct ALbuffer *buffer;
|
struct ALbuffer *buffer;
|
||||||
ALuint bufferstate;
|
|
||||||
ALuint flag;
|
|
||||||
struct ALbufferlistitem *next;
|
struct ALbufferlistitem *next;
|
||||||
} ALbufferlistitem;
|
} ALbufferlistitem;
|
||||||
|
|
||||||
|
@ -462,7 +462,6 @@ ALAPI ALvoid ALAPIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
|
|||||||
ALCcontext *pContext;
|
ALCcontext *pContext;
|
||||||
ALsource *pSource;
|
ALsource *pSource;
|
||||||
ALbufferlistitem *pALBufferListItem;
|
ALbufferlistitem *pALBufferListItem;
|
||||||
ALuint i;
|
|
||||||
|
|
||||||
pContext = GetContextSuspended();
|
pContext = GetContextSuspended();
|
||||||
if(!pContext) return;
|
if(!pContext) return;
|
||||||
@ -502,19 +501,7 @@ ALAPI ALvoid ALAPIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
|
|||||||
|
|
||||||
case AL_LOOPING:
|
case AL_LOOPING:
|
||||||
if(lValue == AL_FALSE || lValue == AL_TRUE)
|
if(lValue == AL_FALSE || lValue == AL_TRUE)
|
||||||
{
|
|
||||||
pSource->bLooping = (ALboolean)lValue;
|
pSource->bLooping = (ALboolean)lValue;
|
||||||
|
|
||||||
pALBufferListItem = pSource->queue;
|
|
||||||
for(i = 0;pALBufferListItem != NULL;i++)
|
|
||||||
{
|
|
||||||
if(lValue == AL_FALSE && i <= pSource->BuffersPlayed)
|
|
||||||
pALBufferListItem->bufferstate = PROCESSED;
|
|
||||||
else
|
|
||||||
pALBufferListItem->bufferstate = PENDING;
|
|
||||||
pALBufferListItem = pALBufferListItem->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
alSetError(AL_INVALID_VALUE);
|
alSetError(AL_INVALID_VALUE);
|
||||||
break;
|
break;
|
||||||
@ -551,8 +538,6 @@ ALAPI ALvoid ALAPIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
|
|||||||
// Add the selected buffer to the queue
|
// Add the selected buffer to the queue
|
||||||
pALBufferListItem = malloc(sizeof(ALbufferlistitem));
|
pALBufferListItem = malloc(sizeof(ALbufferlistitem));
|
||||||
pALBufferListItem->buffer = buffer;
|
pALBufferListItem->buffer = buffer;
|
||||||
pALBufferListItem->bufferstate = PENDING;
|
|
||||||
pALBufferListItem->flag = 0;
|
|
||||||
pALBufferListItem->next = NULL;
|
pALBufferListItem->next = NULL;
|
||||||
|
|
||||||
pSource->queue = pALBufferListItem;
|
pSource->queue = pALBufferListItem;
|
||||||
@ -1329,14 +1314,6 @@ ALAPI ALvoid ALAPIENTRY alSourcePlayv(ALsizei n, const ALuint *pSourceList)
|
|||||||
pSource->BuffersPlayed = 0;
|
pSource->BuffersPlayed = 0;
|
||||||
|
|
||||||
pSource->Buffer = pSource->queue->buffer;
|
pSource->Buffer = pSource->queue->buffer;
|
||||||
|
|
||||||
// Make sure all the Buffers in the queue are marked as PENDING
|
|
||||||
ALBufferList = pSource->queue;
|
|
||||||
while(ALBufferList)
|
|
||||||
{
|
|
||||||
ALBufferList->bufferstate = PENDING;
|
|
||||||
ALBufferList = ALBufferList->next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pSource->state = AL_PLAYING;
|
pSource->state = AL_PLAYING;
|
||||||
@ -1356,28 +1333,12 @@ ALAPI ALvoid ALAPIENTRY alSourcePlayv(ALsizei n, const ALuint *pSourceList)
|
|||||||
{
|
{
|
||||||
pSource->state = AL_STOPPED;
|
pSource->state = AL_STOPPED;
|
||||||
pSource->BuffersPlayed = pSource->BuffersInQueue;
|
pSource->BuffersPlayed = pSource->BuffersInQueue;
|
||||||
ALBufferList = pSource->queue;
|
|
||||||
while(ALBufferList != NULL)
|
|
||||||
{
|
|
||||||
ALBufferList->bufferstate = PROCESSED;
|
|
||||||
ALBufferList = ALBufferList->next;
|
|
||||||
}
|
|
||||||
pSource->position = 0;
|
pSource->position = 0;
|
||||||
pSource->position_fraction = 0;
|
pSource->position_fraction = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
// If there is a queue (must all be NULL or Zero length Buffers) mark them all as processed
|
|
||||||
ALBufferList = pSource->queue;
|
|
||||||
while(ALBufferList)
|
|
||||||
{
|
|
||||||
ALBufferList->bufferstate = PROCESSED;
|
|
||||||
ALBufferList = ALBufferList->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
pSource->BuffersPlayed = pSource->BuffersInQueue;
|
pSource->BuffersPlayed = pSource->BuffersInQueue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1449,7 +1410,6 @@ ALAPI ALvoid ALAPIENTRY alSourceStopv(ALsizei n, const ALuint *sources)
|
|||||||
ALCcontext *Context;
|
ALCcontext *Context;
|
||||||
ALsource *Source;
|
ALsource *Source;
|
||||||
ALsizei i;
|
ALsizei i;
|
||||||
ALbufferlistitem *ALBufferListItem;
|
|
||||||
ALboolean bSourcesValid = AL_TRUE;
|
ALboolean bSourcesValid = AL_TRUE;
|
||||||
|
|
||||||
Context = GetContextSuspended();
|
Context = GetContextSuspended();
|
||||||
@ -1477,12 +1437,6 @@ ALAPI ALvoid ALAPIENTRY alSourceStopv(ALsizei n, const ALuint *sources)
|
|||||||
{
|
{
|
||||||
Source->state = AL_STOPPED;
|
Source->state = AL_STOPPED;
|
||||||
Source->BuffersPlayed = Source->BuffersInQueue;
|
Source->BuffersPlayed = Source->BuffersInQueue;
|
||||||
ALBufferListItem = Source->queue;
|
|
||||||
while(ALBufferListItem != NULL)
|
|
||||||
{
|
|
||||||
ALBufferListItem->bufferstate = PROCESSED;
|
|
||||||
ALBufferListItem = ALBufferListItem->next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Source->lOffset = 0;
|
Source->lOffset = 0;
|
||||||
}
|
}
|
||||||
@ -1508,7 +1462,6 @@ ALAPI ALvoid ALAPIENTRY alSourceRewindv(ALsizei n, const ALuint *sources)
|
|||||||
ALCcontext *Context;
|
ALCcontext *Context;
|
||||||
ALsource *Source;
|
ALsource *Source;
|
||||||
ALsizei i;
|
ALsizei i;
|
||||||
ALbufferlistitem *ALBufferListItem;
|
|
||||||
ALboolean bSourcesValid = AL_TRUE;
|
ALboolean bSourcesValid = AL_TRUE;
|
||||||
|
|
||||||
Context = GetContextSuspended();
|
Context = GetContextSuspended();
|
||||||
@ -1538,12 +1491,6 @@ ALAPI ALvoid ALAPIENTRY alSourceRewindv(ALsizei n, const ALuint *sources)
|
|||||||
Source->position = 0;
|
Source->position = 0;
|
||||||
Source->position_fraction = 0;
|
Source->position_fraction = 0;
|
||||||
Source->BuffersPlayed = 0;
|
Source->BuffersPlayed = 0;
|
||||||
ALBufferListItem = Source->queue;
|
|
||||||
while(ALBufferListItem != NULL)
|
|
||||||
{
|
|
||||||
ALBufferListItem->bufferstate = PENDING;
|
|
||||||
ALBufferListItem = ALBufferListItem->next;
|
|
||||||
}
|
|
||||||
if(Source->queue)
|
if(Source->queue)
|
||||||
Source->Buffer = Source->queue->buffer;
|
Source->Buffer = Source->queue->buffer;
|
||||||
}
|
}
|
||||||
@ -1645,8 +1592,6 @@ ALAPI ALvoid ALAPIENTRY alSourceQueueBuffers( ALuint source, ALsizei n, const AL
|
|||||||
// All buffers are valid - so add them to the list
|
// All buffers are valid - so add them to the list
|
||||||
ALBufferListStart = malloc(sizeof(ALbufferlistitem));
|
ALBufferListStart = malloc(sizeof(ALbufferlistitem));
|
||||||
ALBufferListStart->buffer = buffer;
|
ALBufferListStart->buffer = buffer;
|
||||||
ALBufferListStart->bufferstate = PENDING;
|
|
||||||
ALBufferListStart->flag = 0;
|
|
||||||
ALBufferListStart->next = NULL;
|
ALBufferListStart->next = NULL;
|
||||||
|
|
||||||
// Increment reference counter for buffer
|
// Increment reference counter for buffer
|
||||||
@ -1661,8 +1606,6 @@ ALAPI ALvoid ALAPIENTRY alSourceQueueBuffers( ALuint source, ALsizei n, const AL
|
|||||||
|
|
||||||
ALBufferList->next = malloc(sizeof(ALbufferlistitem));
|
ALBufferList->next = malloc(sizeof(ALbufferlistitem));
|
||||||
ALBufferList->next->buffer = buffer;
|
ALBufferList->next->buffer = buffer;
|
||||||
ALBufferList->next->bufferstate = PENDING;
|
|
||||||
ALBufferList->next->flag = 0;
|
|
||||||
ALBufferList->next->next = NULL;
|
ALBufferList->next->next = NULL;
|
||||||
|
|
||||||
// Increment reference counter for buffer
|
// Increment reference counter for buffer
|
||||||
@ -1729,23 +1672,8 @@ ALAPI ALvoid ALAPIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALuint
|
|||||||
{
|
{
|
||||||
ALSource = (ALsource*)ALTHUNK_LOOKUPENTRY(source);
|
ALSource = (ALsource*)ALTHUNK_LOOKUPENTRY(source);
|
||||||
|
|
||||||
// Check that all 'n' buffers have been processed
|
|
||||||
ALBufferList = ALSource->queue;
|
|
||||||
for(i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
if(ALBufferList != NULL && ALBufferList->bufferstate == PROCESSED)
|
|
||||||
{
|
|
||||||
ALBufferList = ALBufferList->next;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bBuffersProcessed = AL_FALSE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If all 'n' buffers have been processed, remove them from the queue
|
// If all 'n' buffers have been processed, remove them from the queue
|
||||||
if(bBuffersProcessed)
|
if(!ALSource->bLooping && (ALuint)n <= ALSource->BuffersPlayed)
|
||||||
{
|
{
|
||||||
for(i = 0; i < n; i++)
|
for(i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
@ -1771,10 +1699,7 @@ ALAPI ALvoid ALAPIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALuint
|
|||||||
ALSource->Buffer = NULL;
|
ALSource->Buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ALuint)n > ALSource->BuffersPlayed)
|
ALSource->BuffersPlayed -= n;
|
||||||
ALSource->BuffersPlayed = 0;
|
|
||||||
else
|
|
||||||
ALSource->BuffersPlayed -= n;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1848,6 +1773,7 @@ static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOf
|
|||||||
ALenum eOriginalFormat;
|
ALenum eOriginalFormat;
|
||||||
ALboolean bReturn = AL_TRUE;
|
ALboolean bReturn = AL_TRUE;
|
||||||
ALint lTotalBufferDataSize;
|
ALint lTotalBufferDataSize;
|
||||||
|
ALuint i;
|
||||||
|
|
||||||
if((pSource->state == AL_PLAYING || pSource->state == AL_PAUSED) && pSource->Buffer)
|
if((pSource->state == AL_PLAYING || pSource->state == AL_PAUSED) && pSource->Buffer)
|
||||||
{
|
{
|
||||||
@ -1861,7 +1787,7 @@ static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOf
|
|||||||
readPos = pSource->position * lChannels * 2; // NOTE : This is the byte offset into the *current* buffer
|
readPos = pSource->position * lChannels * 2; // NOTE : This is the byte offset into the *current* buffer
|
||||||
// Add byte length of any processed buffers in the queue
|
// Add byte length of any processed buffers in the queue
|
||||||
pBufferList = pSource->queue;
|
pBufferList = pSource->queue;
|
||||||
while(pBufferList && pBufferList->bufferstate == PROCESSED)
|
for(i = 0;i < pSource->BuffersPlayed && pBufferList;i++)
|
||||||
{
|
{
|
||||||
readPos += pBufferList->buffer->size;
|
readPos += pBufferList->buffer->size;
|
||||||
pBufferList = pBufferList->next;
|
pBufferList = pBufferList->next;
|
||||||
@ -2001,18 +1927,12 @@ static void ApplyOffset(ALsource *pSource, ALboolean bUpdateContext)
|
|||||||
|
|
||||||
if ((lTotalBufferSize + lBufferSize) <= lByteOffset)
|
if ((lTotalBufferSize + lBufferSize) <= lByteOffset)
|
||||||
{
|
{
|
||||||
// Offset is past this buffer so increment BuffersPlayed and if the Source is NOT looping
|
// Offset is past this buffer so increment BuffersPlayed
|
||||||
// update the state to PROCESSED
|
|
||||||
pSource->BuffersPlayed++;
|
pSource->BuffersPlayed++;
|
||||||
|
|
||||||
if (!pSource->bLooping)
|
|
||||||
pBufferList->bufferstate = PROCESSED;
|
|
||||||
}
|
}
|
||||||
else if (lTotalBufferSize <= lByteOffset)
|
else if (lTotalBufferSize <= lByteOffset)
|
||||||
{
|
{
|
||||||
// Offset is within this buffer
|
// Offset is within this buffer
|
||||||
pBufferList->bufferstate = PENDING;
|
|
||||||
|
|
||||||
// Set Current Buffer
|
// Set Current Buffer
|
||||||
pSource->Buffer = pBufferList->buffer;
|
pSource->Buffer = pBufferList->buffer;
|
||||||
|
|
||||||
@ -2021,11 +1941,6 @@ static void ApplyOffset(ALsource *pSource, ALboolean bUpdateContext)
|
|||||||
aluBytesFromFormat(pBuffer->format) /
|
aluBytesFromFormat(pBuffer->format) /
|
||||||
aluChannelsFromFormat(pBuffer->format);
|
aluChannelsFromFormat(pBuffer->format);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Offset is before this buffer, so mark as pending
|
|
||||||
pBufferList->bufferstate = PENDING;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increment the TotalBufferSize
|
// Increment the TotalBufferSize
|
||||||
lTotalBufferSize += lBufferSize;
|
lTotalBufferSize += lBufferSize;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user