aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-11-21 13:45:57 -0800
committerChris Robinson <[email protected]>2014-11-21 13:45:57 -0800
commit4ad6905c135d6964e57fe48fb7f93e579d028887 (patch)
treec2de2460a576bfe06ede0b56d286987545f21597 /Alc
parentd608f0e9f0e3c321ad02f4cbacde74df007fc2cd (diff)
Allocate the DryBuffer dynamically
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c14
-rw-r--r--Alc/ALu.c2
2 files changed, 15 insertions, 1 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 13e0363e..915a03ef 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -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);
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 4a5402e7..97205d8b 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -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)();