aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-04-23 07:23:38 -0700
committerChris Robinson <[email protected]>2010-04-23 07:23:38 -0700
commit52663e8a44471570a9b2519e163e3252fc2f65bf (patch)
tree28cae18958d18debe0e0e6051ca3414e0d71e905 /OpenAL32
parent8646647b3ec4c8c0853f28c6cd178766188da1f6 (diff)
Combine two loops into one
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/alSource.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 969c49d1..a073b8a4 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -1795,28 +1795,23 @@ static ALvoid GetSourceOffset(ALsource *Source, ALenum name, ALfloat *offset, AL
// Get Current BytesPlayed (NOTE : This is the byte offset into the *current* buffer)
readPos = Source->position * Channels * Bytes;
// Add byte length of any processed buffers in the queue
+ TotalBufferDataSize = 0;
BufferList = Source->queue;
- for(i = 0;i < Source->BuffersPlayed && BufferList;i++)
+ for(i = 0;BufferList;i++)
{
if(BufferList->buffer)
- readPos += BufferList->buffer->size;
+ {
+ if(i < Source->BuffersPlayed)
+ readPos += BufferList->buffer->size;
+ TotalBufferDataSize += BufferList->buffer->size;
+ }
BufferList = BufferList->next;
}
-
if(Source->state == AL_PLAYING)
writePos = readPos + ((ALuint)(updateLen*BufferFreq) * Channels * Bytes);
else
writePos = readPos;
- TotalBufferDataSize = 0;
- BufferList = Source->queue;
- while(BufferList)
- {
- if(BufferList->buffer)
- TotalBufferDataSize += BufferList->buffer->size;
- BufferList = BufferList->next;
- }
-
if(Source->bLooping)
{
readPos %= TotalBufferDataSize;