diff options
author | Chris Robinson <[email protected]> | 2014-11-21 13:45:57 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-11-21 13:45:57 -0800 |
commit | 4ad6905c135d6964e57fe48fb7f93e579d028887 (patch) | |
tree | c2de2460a576bfe06ede0b56d286987545f21597 | |
parent | d608f0e9f0e3c321ad02f4cbacde74df007fc2cd (diff) |
Allocate the DryBuffer dynamically
-rw-r--r-- | Alc/ALc.c | 14 | ||||
-rw-r--r-- | Alc/ALu.c | 2 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 2 |
3 files changed, 16 insertions, 2 deletions
@@ -1996,6 +1996,14 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) WARN("NEON performs best with multiple of 4 update sizes (%u)\n", device->UpdateSize); } + al_free(device->DryBuffer); + device->DryBuffer = al_calloc(16, sizeof(device->DryBuffer[0]) * device->NumChannels); + if(!device->DryBuffer) + { + ERR("Failed to allocate "SZFMT"-byte mix buffer\n", sizeof(device->DryBuffer[0]) * device->NumChannels); + return ALC_INVALID_DEVICE; + } + SetMixerFPUMode(&oldMode); V0(device->Backend,lock)(); context = ATOMIC_LOAD(&device->ContextList); @@ -2161,6 +2169,9 @@ static ALCvoid FreeDevice(ALCdevice *device) AL_STRING_DEINIT(device->DeviceName); + al_free(device->DryBuffer); + device->DryBuffer = NULL; + al_free(device); } @@ -3221,6 +3232,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->Bs2b = NULL; device->Bs2bLevel = 0; AL_STRING_INIT(device->DeviceName); + device->DryBuffer = NULL; ATOMIC_INIT(&device->ContextList, NULL); @@ -3484,6 +3496,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, device->Type = Capture; AL_STRING_INIT(device->DeviceName); + device->DryBuffer = NULL; InitUIntMap(&device->BufferMap, ~0); InitUIntMap(&device->EffectMap, ~0); @@ -3666,6 +3679,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN device->Bs2b = NULL; device->Bs2bLevel = 0; AL_STRING_INIT(device->DeviceName); + device->DryBuffer = NULL; ATOMIC_INIT(&device->ContextList, NULL); @@ -1128,7 +1128,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) IncrementRef(&device->MixCount); SamplesToDo = minu(size, BUFFERSIZE); - for(c = 0;c < MAX_OUTPUT_CHANNELS;c++) + for(c = 0;c < device->NumChannels;c++) memset(device->DryBuffer[c], 0, SamplesToDo*sizeof(ALfloat)); V0(device->Backend,lock)(); diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 2a6bac60..083d2613 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -673,7 +673,7 @@ struct ALCdevice_struct alignas(16) ALfloat FilteredData[BUFFERSIZE]; // Dry path buffer mix - alignas(16) ALfloat DryBuffer[MAX_OUTPUT_CHANNELS][BUFFERSIZE]; + alignas(16) ALfloat (*DryBuffer)[BUFFERSIZE]; /* Running count of the mixer invocations, in 31.1 fixed point. This * actually increments *twice* when mixing, first at the start and then at |