aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alSource.h39
-rw-r--r--OpenAL32/Include/alu.h6
-rw-r--r--OpenAL32/alSource.c35
-rw-r--r--OpenAL32/alState.c4
4 files changed, 42 insertions, 42 deletions
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h
index ecc62a37..3fb3e553 100644
--- a/OpenAL32/Include/alSource.h
+++ b/OpenAL32/Include/alSource.h
@@ -30,11 +30,6 @@ typedef struct ALbufferlistitem {
} ALbufferlistitem;
-typedef struct ALactivesource {
- struct ALsource *Source;
-} ALactivesource;
-
-
typedef struct HrtfState {
ALboolean Moving;
ALuint Counter;
@@ -84,6 +79,24 @@ typedef struct SendParams {
} SendParams;
+typedef struct ALactivesource {
+ struct ALsource *Source;
+
+ /** Method to update mixing parameters. */
+ ALvoid (*Update)(struct ALactivesource *self, const ALCcontext *context);
+
+ /** Current target parameters used for mixing. */
+ ResamplerFunc Resample;
+ DryMixerFunc DryMix;
+ WetMixerFunc WetMix;
+
+ ALint Step;
+
+ DirectParams Direct;
+ SendParams Send[MAX_SENDS];
+} ALactivesource;
+
+
typedef struct ALsource {
/** Source properties. */
volatile ALfloat Pitch;
@@ -159,28 +172,12 @@ typedef struct ALsource {
/** HRTF info. */
HrtfState Hrtf;
- /** Current target parameters used for mixing. */
- struct {
- ResamplerFunc Resample;
- DryMixerFunc DryMix;
- WetMixerFunc WetMix;
-
- ALint Step;
-
- DirectParams Direct;
-
- SendParams Send[MAX_SENDS];
- } Params;
/** Source needs to update its mixing parameters. */
volatile ALenum NeedsUpdate;
- /** Method to update mixing parameters. */
- ALvoid (*Update)(struct ALsource *self, const ALCcontext *context);
-
/** Self ID */
ALuint id;
} ALsource;
-#define ALsource_Update(s,a) ((s)->Update(s,a))
inline struct ALsource *LookupSource(ALCcontext *context, ALuint id)
{ return (struct ALsource*)LookupUIntMapKey(&context->SourceMap, id); }
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index d88e860c..f8174e0e 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -137,10 +137,10 @@ inline void SetGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MaxC
}
-ALvoid CalcSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext);
-ALvoid CalcNonAttnSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext);
+ALvoid CalcSourceParams(struct ALactivesource *src, const ALCcontext *ALContext);
+ALvoid CalcNonAttnSourceParams(struct ALactivesource *src, const ALCcontext *ALContext);
-ALvoid MixSource(struct ALsource *Source, ALCdevice *Device, ALuint SamplesToDo);
+ALvoid MixSource(struct ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo);
ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size);
/* Caller must lock the device. */
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)
{
diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c
index aebee3e7..f97168d6 100644
--- a/OpenAL32/alState.c
+++ b/OpenAL32/alState.c
@@ -733,7 +733,7 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
{
ALsource *source = (*src)->Source;
- if(source->state != AL_PLAYING)
+ if(source->state != AL_PLAYING && source->state != AL_PAUSED)
{
ALactivesource *temp = *(--src_end);
*src_end = *src;
@@ -743,7 +743,7 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
}
if(ExchangeInt(&source->NeedsUpdate, AL_FALSE) || UpdateSources)
- ALsource_Update(source, context);
+ (*src)->Update(*src, context);
src++;
}