aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-04-28 14:08:10 -0700
committerChris Robinson <[email protected]>2010-04-28 14:08:10 -0700
commitaaa7082aa81c5862c0c11daab0ca4e93e9c47591 (patch)
tree658aaa515a668e36315612f64172186288ec7046
parent5d7815beed9c03122a585700eb27c04ece31f660 (diff)
Get the offset even if the current buffer is 0
-rw-r--r--OpenAL32/alSource.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index a073b8a4..d0701468 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -1768,7 +1768,7 @@ static ALvoid InitSourceParams(ALsource *Source)
static ALvoid GetSourceOffset(ALsource *Source, ALenum name, ALfloat *offset, ALfloat updateLen)
{
ALbufferlistitem *BufferList;
- ALbuffer *Buffer;
+ ALbuffer *Buffer = NULL;
ALfloat BufferFreq;
ALint Channels, Bytes;
ALint readPos, writePos;
@@ -1776,16 +1776,25 @@ static ALvoid GetSourceOffset(ALsource *Source, ALenum name, ALfloat *offset, AL
ALint TotalBufferDataSize;
ALuint i;
- if((Source->state != AL_PLAYING && Source->state != AL_PAUSED) ||
- !Source->Buffer)
+ // Find the first non-NULL Buffer in the Queue
+ BufferList = Source->queue;
+ while(BufferList)
+ {
+ if(BufferList->buffer)
+ {
+ Buffer = BufferList->buffer;
+ break;
+ }
+ BufferList = BufferList->next;
+ }
+
+ if((Source->state != AL_PLAYING && Source->state != AL_PAUSED) || !Buffer)
{
offset[0] = 0.0f;
offset[1] = 0.0f;
return;
}
- Buffer = Source->Buffer;
-
// Get Current Buffer Size and frequency (in milliseconds)
BufferFreq = (ALfloat)Buffer->frequency;
OriginalFormat = Buffer->eOriginalFormat;