aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-03-10 11:52:39 -0700
committerChris Robinson <[email protected]>2019-03-10 11:52:39 -0700
commit0d295cf81192c6fa39714feae81102255afbe501 (patch)
treeea21baeeb9339b4bdd334d76254a9a91cb5e0ccd /Alc
parente5651c15dd1f296f0acf7448954fcb36df8a4abc (diff)
Don't directly use a buffer for updating source parameters
Diffstat (limited to 'Alc')
-rw-r--r--Alc/alc.cpp2
-rw-r--r--Alc/alu.cpp38
2 files changed, 15 insertions, 25 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index 9891fec5..8109f202 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -2648,6 +2648,8 @@ void AllocateVoices(ALCcontext *context, ALsizei num_voices, ALsizei old_sends)
voice->loop_buffer.store(old_voice->loop_buffer.load(std::memory_order_relaxed),
std::memory_order_relaxed);
+ voice->Frequency = old_voice->Frequency;
+ voice->Channels = old_voice->Channels;
voice->NumChannels = old_voice->NumChannels;
voice->SampleSize = old_voice->SampleSize;
diff --git a/Alc/alu.cpp b/Alc/alu.cpp
index e892470f..08ccd003 100644
--- a/Alc/alu.cpp
+++ b/Alc/alu.cpp
@@ -486,7 +486,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
const ALfloat zpos, const ALfloat Distance, const ALfloat Spread, const ALfloat DryGain,
const ALfloat DryGainHF, const ALfloat DryGainLF, const ALfloat (&WetGain)[MAX_SENDS],
const ALfloat (&WetGainLF)[MAX_SENDS], const ALfloat (&WetGainHF)[MAX_SENDS],
- ALeffectslot *(&SendSlots)[MAX_SENDS], const ALbuffer *Buffer, const ALvoicePropsBase *props,
+ ALeffectslot *(&SendSlots)[MAX_SENDS], const ALvoicePropsBase *props,
const ALlistener &Listener, const ALCdevice *Device)
{
ChanMap StereoMap[2]{
@@ -503,7 +503,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
ALsizei num_channels{0};
bool isbformat{false};
ALfloat downmix_gain{1.0f};
- switch(Buffer->mFmtChannels)
+ switch(voice->Channels)
{
case FmtMono:
chans = MonoMap;
@@ -1003,7 +1003,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
}
}
-void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const ALbuffer *ALBuffer, const ALCcontext *ALContext)
+void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const ALCcontext *ALContext)
{
const ALCdevice *Device{ALContext->Device};
ALeffectslot *SendSlots[MAX_SENDS];
@@ -1029,7 +1029,7 @@ void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, cons
}
/* Calculate the stepping value */
- const auto Pitch = static_cast<ALfloat>(ALBuffer->Frequency) /
+ const auto Pitch = static_cast<ALfloat>(voice->Frequency) /
static_cast<ALfloat>(Device->Frequency) * props->Pitch;
if(Pitch > static_cast<ALfloat>(MAX_PITCH))
voice->Step = MAX_PITCH<<FRACTIONBITS;
@@ -1059,10 +1059,10 @@ void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, cons
}
CalcPanningAndFilters(voice, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, DryGain, DryGainHF, DryGainLF,
- WetGain, WetGainLF, WetGainHF, SendSlots, ALBuffer, props, Listener, Device);
+ WetGain, WetGainLF, WetGainHF, SendSlots, props, Listener, Device);
}
-void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const ALbuffer *ALBuffer, const ALCcontext *ALContext)
+void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const ALCcontext *ALContext)
{
const ALCdevice *Device{ALContext->Device};
const ALsizei NumSends{Device->NumAuxSends};
@@ -1368,7 +1368,7 @@ void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const A
/* Adjust pitch based on the buffer and output frequencies, and calculate
* fixed-point stepping value.
*/
- Pitch *= static_cast<ALfloat>(ALBuffer->Frequency)/static_cast<ALfloat>(Device->Frequency);
+ Pitch *= static_cast<ALfloat>(voice->Frequency)/static_cast<ALfloat>(Device->Frequency);
if(Pitch > static_cast<ALfloat>(MAX_PITCH))
voice->Step = MAX_PITCH<<FRACTIONBITS;
else
@@ -1387,7 +1387,7 @@ void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const A
CalcPanningAndFilters(voice, ToSource[0], ToSource[1], ToSource[2]*ZScale,
Distance*Listener.Params.MetersPerUnit, spread, DryGain, DryGainHF, DryGainLF, WetGain,
- WetGainLF, WetGainHF, SendSlots, ALBuffer, props, Listener, Device);
+ WetGainLF, WetGainHF, SendSlots, props, Listener, Device);
}
void CalcSourceParams(ALvoice *voice, ALCcontext *context, bool force)
@@ -1402,23 +1402,11 @@ void CalcSourceParams(ALvoice *voice, ALCcontext *context, bool force)
AtomicReplaceHead(context->FreeVoiceProps, props);
}
- ALbufferlistitem *BufferListItem{voice->current_buffer.load(std::memory_order_relaxed)};
- while(BufferListItem)
- {
- auto buffers_end = BufferListItem->buffers+BufferListItem->num_buffers;
- auto buffer = std::find_if(BufferListItem->buffers, buffers_end,
- std::bind(std::not_equal_to<const ALbuffer*>{}, _1, nullptr));
- if(LIKELY(buffer != buffers_end))
- {
- if(voice->Props.mSpatializeMode==SpatializeOn ||
- (voice->Props.mSpatializeMode==SpatializeAuto && (*buffer)->mFmtChannels==FmtMono))
- CalcAttnSourceParams(voice, &voice->Props, *buffer, context);
- else
- CalcNonAttnSourceParams(voice, &voice->Props, *buffer, context);
- break;
- }
- BufferListItem = BufferListItem->next.load(std::memory_order_acquire);
- }
+ if(voice->Props.mSpatializeMode==SpatializeOn ||
+ (voice->Props.mSpatializeMode==SpatializeAuto && voice->Channels==FmtMono))
+ CalcAttnSourceParams(voice, &voice->Props, context);
+ else
+ CalcNonAttnSourceParams(voice, &voice->Props, context);
}