aboutsummaryrefslogtreecommitdiffstats
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
parentd6f7aac1bbc2c51dbe53e30a50275d550a020df6 (diff)
Store some source mixing parameters in the active source struct
-rw-r--r--Alc/ALc.c12
-rw-r--r--Alc/ALu.c149
-rw-r--r--Alc/mixer.c21
-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
7 files changed, 139 insertions, 127 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 574dce06..d67cf924 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1930,11 +1930,19 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
source->Send[s].GainHF = 1.0f;
s++;
}
- source->NeedsUpdate = AL_FALSE;
- ALsource_Update(source, context);
+ source->NeedsUpdate = AL_TRUE;
}
UnlockUIntMapRead(&context->SourceMap);
+ for(pos = 0;pos < context->ActiveSourceCount;pos++)
+ {
+ ALactivesource *src = context->ActiveSources[pos];
+ ALsource *source = src->Source;
+
+ src->Update(src, context);
+ source->NeedsUpdate = AL_FALSE;
+ }
+
context = context->next;
}
if(device->DefaultSlot)
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 6c92bf5d..9ff9fc07 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -227,7 +227,7 @@ static ALvoid CalcListenerParams(ALlistener *Listener)
aluMatrixVector(Listener->Params.Velocity, 0.0f, Listener->Params.Matrix);
}
-ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
+ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext)
{
static const struct ChanMap MonoMap[1] = { { FrontCenter, 0.0f } };
static const struct ChanMap StereoMap[2] = {
@@ -277,6 +277,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
};
ALCdevice *Device = ALContext->Device;
+ ALsource *ALSource = src->Source;
ALfloat SourceVolume,ListenerGain,MinVolume,MaxVolume;
ALbufferlistitem *BufferListItem;
enum FmtChannels Channels;
@@ -318,14 +319,14 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
{
Pitch = Pitch * ALBuffer->Frequency / Frequency;
if(Pitch > 10.0f)
- ALSource->Params.Step = 10<<FRACTIONBITS;
+ src->Step = 10<<FRACTIONBITS;
else
{
- ALSource->Params.Step = fastf2i(Pitch*FRACTIONONE);
- if(ALSource->Params.Step == 0)
- ALSource->Params.Step = 1;
+ src->Step = fastf2i(Pitch*FRACTIONONE);
+ if(src->Step == 0)
+ src->Step = 1;
}
- ALSource->Params.Resample = SelectResampler(Resampler, ALSource->Params.Step);
+ src->Resample = SelectResampler(Resampler, src->Step);
Channels = ALBuffer->FmtChannels;
break;
@@ -333,10 +334,10 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
BufferListItem = BufferListItem->next;
}
if(!DirectChannels && Device->Hrtf)
- ALSource->Params.DryMix = SelectHrtfMixer();
+ src->DryMix = SelectHrtfMixer();
else
- ALSource->Params.DryMix = SelectDirectMixer();
- ALSource->Params.WetMix = SelectSendMixer();
+ src->DryMix = SelectDirectMixer();
+ src->WetMix = SelectSendMixer();
/* Calculate gains */
DryGain = clampf(SourceVolume, MinVolume, MaxVolume);
@@ -349,7 +350,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
WetGainHF[i] = ALSource->Send[i].GainHF;
}
- SrcMatrix = ALSource->Params.Direct.Gains;
+ SrcMatrix = src->Direct.Gains;
for(i = 0;i < MAX_INPUT_CHANNELS;i++)
{
for(c = 0;c < MaxChannels;c++)
@@ -429,12 +430,12 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
if(chans[c].channel == LFE)
{
/* Skip LFE */
- ALSource->Params.Direct.Hrtf.Params.Delay[c][0] = 0;
- ALSource->Params.Direct.Hrtf.Params.Delay[c][1] = 0;
+ src->Direct.Hrtf.Params.Delay[c][0] = 0;
+ src->Direct.Hrtf.Params.Delay[c][1] = 0;
for(i = 0;i < HRIR_LENGTH;i++)
{
- ALSource->Params.Direct.Hrtf.Params.Coeffs[c][i][0] = 0.0f;
- ALSource->Params.Direct.Hrtf.Params.Coeffs[c][i][1] = 0.0f;
+ src->Direct.Hrtf.Params.Coeffs[c][i][0] = 0.0f;
+ src->Direct.Hrtf.Params.Coeffs[c][i][1] = 0.0f;
}
}
else
@@ -443,14 +444,14 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
* channel. */
GetLerpedHrtfCoeffs(Device->Hrtf,
0.0f, chans[c].angle, DryGain,
- ALSource->Params.Direct.Hrtf.Params.Coeffs[c],
- ALSource->Params.Direct.Hrtf.Params.Delay[c]);
+ src->Direct.Hrtf.Params.Coeffs[c],
+ src->Direct.Hrtf.Params.Delay[c]);
}
}
ALSource->Hrtf.Counter = 0;
- ALSource->Params.Direct.Hrtf.Params.IrSize = GetHrtfIrSize(Device->Hrtf);
+ src->Direct.Hrtf.Params.IrSize = GetHrtfIrSize(Device->Hrtf);
- ALSource->Params.Direct.Hrtf.State = &ALSource->Hrtf;
+ src->Direct.Hrtf.State = &ALSource->Hrtf;
}
else
{
@@ -468,9 +469,9 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
}
}
- ALSource->Params.Direct.OutBuffer = Device->DryBuffer;
- ALSource->Params.Direct.ClickRemoval = Device->ClickRemoval;
- ALSource->Params.Direct.PendingClicks = Device->PendingClicks;
+ src->Direct.OutBuffer = Device->DryBuffer;
+ src->Direct.ClickRemoval = Device->ClickRemoval;
+ src->Direct.PendingClicks = Device->PendingClicks;
for(i = 0;i < NumSends;i++)
{
ALeffectslot *Slot = ALSource->Send[i].Slot;
@@ -478,23 +479,23 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
Slot = Device->DefaultSlot;
if(!Slot || Slot->EffectType == AL_EFFECT_NULL)
{
- ALSource->Params.Send[i].OutBuffer = NULL;
- ALSource->Params.Send[i].ClickRemoval = NULL;
- ALSource->Params.Send[i].PendingClicks = NULL;
+ src->Send[i].OutBuffer = NULL;
+ src->Send[i].ClickRemoval = NULL;
+ src->Send[i].PendingClicks = NULL;
}
else
{
- ALSource->Params.Send[i].OutBuffer = Slot->WetBuffer;
- ALSource->Params.Send[i].ClickRemoval = Slot->ClickRemoval;
- ALSource->Params.Send[i].PendingClicks = Slot->PendingClicks;
+ src->Send[i].OutBuffer = Slot->WetBuffer;
+ src->Send[i].ClickRemoval = Slot->ClickRemoval;
+ src->Send[i].PendingClicks = Slot->PendingClicks;
}
- ALSource->Params.Send[i].Gain = WetGain[i];
+ src->Send[i].Gain = WetGain[i];
}
{
ALfloat gain = maxf(0.01f, DryGainHF);
for(c = 0;c < num_channels;c++)
- ALfilterState_setParams(&ALSource->Params.Direct.LpFilter[c],
+ ALfilterState_setParams(&src->Direct.LpFilter[c],
ALfilterType_HighShelf, gain,
(ALfloat)LOWPASSFREQREF/Frequency, 0.0f);
}
@@ -502,15 +503,16 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
{
ALfloat gain = maxf(0.01f, WetGainHF[i]);
for(c = 0;c < num_channels;c++)
- ALfilterState_setParams(&ALSource->Params.Send[i].LpFilter[c],
+ ALfilterState_setParams(&src->Send[i].LpFilter[c],
ALfilterType_HighShelf, gain,
(ALfloat)LOWPASSFREQREF/Frequency, 0.0f);
}
}
-ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
+ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext)
{
ALCdevice *Device = ALContext->Device;
+ ALsource *ALSource = src->Source;
ALfloat Velocity[3],Direction[3],Position[3],SourceToListener[3];
ALfloat InnerAngle,OuterAngle,Angle,Distance,ClampedDist;
ALfloat MinVolume,MaxVolume,MinDist,MaxDist,Rolloff;
@@ -578,9 +580,9 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
WetGainHFAuto = ALSource->WetGainHFAuto;
RoomRolloffBase = ALSource->RoomRolloffFactor;
- ALSource->Params.Direct.OutBuffer = Device->DryBuffer;
- ALSource->Params.Direct.ClickRemoval = Device->ClickRemoval;
- ALSource->Params.Direct.PendingClicks = Device->PendingClicks;
+ src->Direct.OutBuffer = Device->DryBuffer;
+ src->Direct.ClickRemoval = Device->ClickRemoval;
+ src->Direct.PendingClicks = Device->PendingClicks;
for(i = 0;i < NumSends;i++)
{
ALeffectslot *Slot = ALSource->Send[i].Slot;
@@ -621,15 +623,15 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
if(!Slot || Slot->EffectType == AL_EFFECT_NULL)
{
- ALSource->Params.Send[i].OutBuffer = NULL;
- ALSource->Params.Send[i].ClickRemoval = NULL;
- ALSource->Params.Send[i].PendingClicks = NULL;
+ src->Send[i].OutBuffer = NULL;
+ src->Send[i].ClickRemoval = NULL;
+ src->Send[i].PendingClicks = NULL;
}
else
{
- ALSource->Params.Send[i].OutBuffer = Slot->WetBuffer;
- ALSource->Params.Send[i].ClickRemoval = Slot->ClickRemoval;
- ALSource->Params.Send[i].PendingClicks = Slot->PendingClicks;
+ src->Send[i].OutBuffer = Slot->WetBuffer;
+ src->Send[i].ClickRemoval = Slot->ClickRemoval;
+ src->Send[i].PendingClicks = Slot->PendingClicks;
}
}
@@ -830,24 +832,24 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
* frequency, and output frequency. */
Pitch = Pitch * ALBuffer->Frequency / Frequency;
if(Pitch > 10.0f)
- ALSource->Params.Step = 10<<FRACTIONBITS;
+ src->Step = 10<<FRACTIONBITS;
else
{
- ALSource->Params.Step = fastf2i(Pitch*FRACTIONONE);
- if(ALSource->Params.Step == 0)
- ALSource->Params.Step = 1;
+ src->Step = fastf2i(Pitch*FRACTIONONE);
+ if(src->Step == 0)
+ src->Step = 1;
}
- ALSource->Params.Resample = SelectResampler(Resampler, ALSource->Params.Step);
+ src->Resample = SelectResampler(Resampler, src->Step);
break;
}
BufferListItem = BufferListItem->next;
}
if(Device->Hrtf)
- ALSource->Params.DryMix = SelectHrtfMixer();
+ src->DryMix = SelectHrtfMixer();
else
- ALSource->Params.DryMix = SelectDirectMixer();
- ALSource->Params.WetMix = SelectSendMixer();
+ src->DryMix = SelectDirectMixer();
+ src->WetMix = SelectSendMixer();
if(Device->Hrtf)
{
@@ -873,8 +875,8 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
if(ALSource->Hrtf.Moving)
{
/* Calculate the normalized HRTF transition factor (delta). */
- delta = CalcHrtfDelta(ALSource->Params.Direct.Hrtf.Params.Gain, DryGain,
- ALSource->Params.Direct.Hrtf.Params.Dir, Position);
+ delta = CalcHrtfDelta(src->Direct.Hrtf.Params.Gain, DryGain,
+ src->Direct.Hrtf.Params.Dir, Position);
/* If the delta is large enough, get the moving HRIR target
* coefficients, target delays, steppping values, and counter. */
if(delta > 0.001f)
@@ -882,36 +884,36 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
ALSource->Hrtf.Counter = GetMovingHrtfCoeffs(Device->Hrtf,
ev, az, DryGain, delta,
ALSource->Hrtf.Counter,
- ALSource->Params.Direct.Hrtf.Params.Coeffs[0],
- ALSource->Params.Direct.Hrtf.Params.Delay[0],
- ALSource->Params.Direct.Hrtf.Params.CoeffStep,
- ALSource->Params.Direct.Hrtf.Params.DelayStep);
- ALSource->Params.Direct.Hrtf.Params.Gain = DryGain;
- ALSource->Params.Direct.Hrtf.Params.Dir[0] = Position[0];
- ALSource->Params.Direct.Hrtf.Params.Dir[1] = Position[1];
- ALSource->Params.Direct.Hrtf.Params.Dir[2] = Position[2];
+ src->Direct.Hrtf.Params.Coeffs[0],
+ src->Direct.Hrtf.Params.Delay[0],
+ src->Direct.Hrtf.Params.CoeffStep,
+ src->Direct.Hrtf.Params.DelayStep);
+ src->Direct.Hrtf.Params.Gain = DryGain;
+ src->Direct.Hrtf.Params.Dir[0] = Position[0];
+ src->Direct.Hrtf.Params.Dir[1] = Position[1];
+ src->Direct.Hrtf.Params.Dir[2] = Position[2];
}
}
else
{
/* Get the initial (static) HRIR coefficients and delays. */
GetLerpedHrtfCoeffs(Device->Hrtf, ev, az, DryGain,
- ALSource->Params.Direct.Hrtf.Params.Coeffs[0],
- ALSource->Params.Direct.Hrtf.Params.Delay[0]);
+ src->Direct.Hrtf.Params.Coeffs[0],
+ src->Direct.Hrtf.Params.Delay[0]);
ALSource->Hrtf.Counter = 0;
ALSource->Hrtf.Moving = AL_TRUE;
- ALSource->Params.Direct.Hrtf.Params.Gain = DryGain;
- ALSource->Params.Direct.Hrtf.Params.Dir[0] = Position[0];
- ALSource->Params.Direct.Hrtf.Params.Dir[1] = Position[1];
- ALSource->Params.Direct.Hrtf.Params.Dir[2] = Position[2];
+ src->Direct.Hrtf.Params.Gain = DryGain;
+ src->Direct.Hrtf.Params.Dir[0] = Position[0];
+ src->Direct.Hrtf.Params.Dir[1] = Position[1];
+ src->Direct.Hrtf.Params.Dir[2] = Position[2];
}
- ALSource->Params.Direct.Hrtf.Params.IrSize = GetHrtfIrSize(Device->Hrtf);
+ src->Direct.Hrtf.Params.IrSize = GetHrtfIrSize(Device->Hrtf);
- ALSource->Params.Direct.Hrtf.State = &ALSource->Hrtf;
+ src->Direct.Hrtf.State = &ALSource->Hrtf;
}
else
{
- ALfloat (*Matrix)[MaxChannels] = ALSource->Params.Direct.Gains;
+ ALfloat (*Matrix)[MaxChannels] = src->Direct.Gains;
ALfloat DirGain = 0.0f;
ALfloat AmbientGain;
@@ -944,19 +946,19 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
}
}
for(i = 0;i < NumSends;i++)
- ALSource->Params.Send[i].Gain = WetGain[i];
+ src->Send[i].Gain = WetGain[i];
{
ALfloat gain = maxf(0.01f, DryGainHF);
- ALfilterState_setParams(&ALSource->Params.Direct.LpFilter[0],
+ ALfilterState_setParams(&src->Direct.LpFilter[0],
ALfilterType_HighShelf, gain,
(ALfloat)LOWPASSFREQREF/Frequency, 0.0f);
}
for(i = 0;i < NumSends;i++)
{
ALfloat gain = maxf(0.01f, WetGainHF[i]);
- ALfilterState_setParams(&ALSource->Params.Send[i].LpFilter[0],
+ ALfilterState_setParams(&src->Send[i].LpFilter[0],
ALfilterType_HighShelf, gain,
(ALfloat)LOWPASSFREQREF/Frequency, 0.0f);
}
@@ -1060,7 +1062,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
{
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;
@@ -1071,9 +1073,10 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
if(!DeferUpdates && (ExchangeInt(&source->NeedsUpdate, AL_FALSE) ||
UpdateSources))
- ALsource_Update(source, ctx);
+ (*src)->Update(*src, ctx);
- MixSource(source, device, SamplesToDo);
+ if(source->state != AL_PAUSED)
+ MixSource(*src, device, SamplesToDo);
src++;
}
diff --git a/Alc/mixer.c b/Alc/mixer.c
index acd6c610..36a08ccd 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -94,8 +94,9 @@ static void DoFilter(ALfilterState *filter, ALfloat *restrict dst, const ALfloat
}
-ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
+ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo)
{
+ ALsource *Source = src->Source;
ALbufferlistitem *BufferListItem;
ALuint DataPosInt, DataPosFrac;
ALuint BuffersPlayed;
@@ -115,7 +116,7 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
DataPosInt = Source->position;
DataPosFrac = Source->position_fraction;
Looping = Source->Looping;
- increment = Source->Params.Step;
+ increment = src->Step;
Resampler = (increment==FRACTIONONE) ? PointResampler : Source->Resampler;
NumChannels = Source->NumChannels;
SampleSize = Source->SampleSize;
@@ -322,28 +323,28 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
}
/* Now resample, then filter and mix to the appropriate outputs. */
- Source->Params.Resample(&SrcData[BufferPrePadding], DataPosFrac,
- increment, ResampledData, DstBufferSize);
+ src->Resample(&SrcData[BufferPrePadding], DataPosFrac,
+ increment, ResampledData, DstBufferSize);
{
- DirectParams *directparms = &Source->Params.Direct;
+ DirectParams *directparms = &src->Direct;
DoFilter(&directparms->LpFilter[chan], SrcData, ResampledData,
DstBufferSize);
- Source->Params.DryMix(directparms, SrcData, chan, OutPos,
- SamplesToDo, DstBufferSize);
+ src->DryMix(directparms, SrcData, chan, OutPos,
+ SamplesToDo, DstBufferSize);
}
for(j = 0;j < Device->NumAuxSends;j++)
{
- SendParams *sendparms = &Source->Params.Send[j];
+ SendParams *sendparms = &src->Send[j];
if(!sendparms->OutBuffer)
continue;
DoFilter(&sendparms->LpFilter[chan], SrcData, ResampledData,
DstBufferSize);
- Source->Params.WetMix(sendparms, SrcData, OutPos,
- SamplesToDo, DstBufferSize);
+ src->WetMix(sendparms, SrcData, OutPos,
+ SamplesToDo, DstBufferSize);
}
}
/* Update positions */
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++;
}