aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alSource.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-03-19 13:14:11 -0700
committerChris Robinson <[email protected]>2014-03-19 13:14:11 -0700
commit6ee54fb1f3e050c6f49e5fef379c9b9f80e4683d (patch)
tree6764b47fe9a76728b78bb22233b76e6583cd9aec /OpenAL32/alSource.c
parentd6f7aac1bbc2c51dbe53e30a50275d550a020df6 (diff)
Store some source mixing parameters in the active source struct
Diffstat (limited to 'OpenAL32/alSource.c')
-rw-r--r--OpenAL32/alSource.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index b2a314ee..7a1d42e5 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -603,11 +603,6 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SrcIntProp p
Source->NumChannels = ChannelsFromFmt(buffer->FmtChannels);
Source->SampleSize = BytesFromFmt(buffer->FmtType);
ReadUnlock(&buffer->lock);
- if(buffer->FmtChannels == FmtMono)
- Source->Update = CalcSourceParams;
- else
- Source->Update = CalcNonAttnSourceParams;
- Source->NeedsUpdate = AL_TRUE;
}
else
{
@@ -2117,12 +2112,6 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint src, ALsizei nb, const ALu
source->NumChannels = ChannelsFromFmt(buffer->FmtChannels);
source->SampleSize = BytesFromFmt(buffer->FmtType);
- if(buffer->FmtChannels == FmtMono)
- source->Update = CalcSourceParams;
- else
- source->Update = CalcNonAttnSourceParams;
-
- source->NeedsUpdate = AL_TRUE;
}
else if(BufferFmt->Frequency != buffer->Frequency ||
BufferFmt->OriginalChannels != buffer->OriginalChannels ||
@@ -2291,6 +2280,7 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
if(state == AL_PLAYING)
{
ALbufferlistitem *BufferList;
+ ALactivesource *src = NULL;
ALsizei j, k;
/* Check that there is a queue containing at least one valid, non zero
@@ -2342,16 +2332,29 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
for(j = 0;j < Context->ActiveSourceCount;j++)
{
if(Context->ActiveSources[j]->Source == Source)
+ {
+ src = Context->ActiveSources[j];
break;
+ }
}
- if(j == Context->ActiveSourceCount)
+ if(src == NULL)
{
- ALsizei idx = Context->ActiveSourceCount;
- if(!Context->ActiveSources[idx])
- Context->ActiveSources[idx] = al_malloc(16, sizeof(Context->ActiveSources[0]));
- Context->ActiveSources[idx]->Source = Source;
+ src = Context->ActiveSources[Context->ActiveSourceCount];
+ if(src == NULL)
+ {
+ src = al_malloc(16, sizeof(src[0]));
+ Context->ActiveSources[Context->ActiveSourceCount] = src;
+ }
+ memset(src, 0, sizeof(*src));
+
+ src->Source = Source;
+ if(BufferList->buffer->FmtChannels == FmtMono)
+ src->Update = CalcSourceParams;
+ else
+ src->Update = CalcNonAttnSourceParams;
Context->ActiveSourceCount++;
}
+ Source->NeedsUpdate = AL_TRUE;
}
else if(state == AL_PAUSED)
{