aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/panning.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-02-28 21:01:13 -0800
committerChris Robinson <[email protected]>2017-02-28 21:01:13 -0800
commit521abf2e0725cc4e4abfc17e75681e47fb372f68 (patch)
tree1082d544446782001c9f6a644955f9e510f60df6 /Alc/panning.c
parent51092a6315cf0a307efec2d76a32dde0f38873a3 (diff)
Dynamically allocate the channel delay buffers
Diffstat (limited to 'Alc/panning.c')
-rw-r--r--Alc/panning.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Alc/panning.c b/Alc/panning.c
index 84e1dbed..c4d3e43f 100644
--- a/Alc/panning.c
+++ b/Alc/panning.c
@@ -616,6 +616,7 @@ static void InitDistanceComp(ALCdevice *device, const AmbDecConf *conf, const AL
{
const char *devname = al_string_get_cstr(device->DeviceName);
ALfloat maxdist = 0.0f;
+ ALsizei total = 0;
ALsizei i;
for(i = 0;i < conf->NumSpeakers;i++)
@@ -649,6 +650,21 @@ static void InitDistanceComp(ALCdevice *device, const AmbDecConf *conf, const AL
al_string_get_cstr(conf->Speakers[i].Name), device->ChannelDelay[chan].Length,
device->ChannelDelay[chan].Gain
);
+
+ /* Round up to the next 4th sample, so each channel buffer starts
+ * 16-byte aligned.
+ */
+ total += RoundUp(device->ChannelDelay[chan].Length, 4);
+ }
+ }
+
+ if(total > 0)
+ {
+ device->ChannelDelay[0].Buffer = al_calloc(16, total * sizeof(ALfloat));
+ for(i = 1;i < MAX_OUTPUT_CHANNELS;i++)
+ {
+ size_t len = RoundUp(device->ChannelDelay[i-1].Length, 4);
+ device->ChannelDelay[i].Buffer = device->ChannelDelay[i-1].Buffer + len;
}
}
}