From 98e8f941b773df0b591e7c6c6c0e3b5096a9b4f2 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 11 Mar 2017 06:20:04 -0800 Subject: Allocate as many channels for DirectHrtfState as needed --- Alc/panning.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Alc/panning.c') diff --git a/Alc/panning.c b/Alc/panning.c index 728001c2..0ff58c3a 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -927,11 +927,14 @@ static void InitHrtfPanning(ALCdevice *device, bool hoa_mode) }; const ALfloat (*AmbiMatrix)[2][MAX_AMBI_COEFFS] = hoa_mode ? AmbiMatrixHOA : AmbiMatrixFOA; ALsizei count = hoa_mode ? 9 : 4; + size_t sizeof_hrtfstate; ALsizei i; - static_assert(9 <= COUNTOF(device->Hrtf->Coeffs), "ALCdevice::Hrtf.Values/Coeffs size is too small"); static_assert(COUNTOF(AmbiPoints) <= HRTF_AMBI_MAX_CHANNELS, "HRTF_AMBI_MAX_CHANNELS is too small"); + sizeof_hrtfstate = offsetof(DirectHrtfState, Chan[count]); + device->Hrtf = al_calloc(16, sizeof_hrtfstate); + for(i = 0;i < count;i++) { device->Dry.Ambi.Map[i].Scale = 1.0f; @@ -962,9 +965,8 @@ static void InitHrtfPanning(ALCdevice *device, bool hoa_mode) device->RealOut.NumChannels = ChannelsFromDevFmt(device->FmtChans); - memset(device->Hrtf->Coeffs, 0, sizeof(device->Hrtf->Coeffs)); device->Hrtf->IrSize = BuildBFormatHrtf(device->HrtfHandle, - device->Hrtf->Coeffs, device->Dry.NumChannels, + device->Hrtf, device->Dry.NumChannels, AmbiPoints, AmbiMatrix, COUNTOF(AmbiPoints) ); @@ -1196,7 +1198,6 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf device->AmbiUp = ambiup_alloc(); hoa_mode = true; } - device->Hrtf = al_calloc(16, sizeof(device->Hrtf[0])); TRACE("%s HRTF rendering enabled, using \"%s\"\n", ((device->Render_Mode == HrtfRender) ? "Full" : "Basic"), -- cgit v1.2.3