Ensure the device's default effect slot is properly aligned

This commit is contained in:
Chris Robinson 2012-09-26 18:21:03 -07:00
parent abf1309fb6
commit 68faef5b84

View File

@ -2647,7 +2647,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
if(deviceName && (!deviceName[0] || strcasecmp(deviceName, alcDefaultName) == 0 || strcasecmp(deviceName, "openal-soft") == 0)) if(deviceName && (!deviceName[0] || strcasecmp(deviceName, alcDefaultName) == 0 || strcasecmp(deviceName, "openal-soft") == 0))
deviceName = NULL; deviceName = NULL;
device = al_calloc(16, sizeof(ALCdevice)+sizeof(ALeffectslot)); device = al_calloc(16, sizeof(ALCdevice)+15+sizeof(ALeffectslot));
if(!device) if(!device)
{ {
alcSetError(NULL, ALC_OUT_OF_MEMORY); alcSetError(NULL, ALC_OUT_OF_MEMORY);
@ -2833,7 +2833,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
if(DefaultEffect.type != AL_EFFECT_NULL) if(DefaultEffect.type != AL_EFFECT_NULL)
{ {
device->DefaultSlot = (ALeffectslot*)(device+1); device->DefaultSlot = (ALeffectslot*)((ALintptrEXT)(device+1)&~15);
if(InitEffectSlot(device->DefaultSlot) != AL_NO_ERROR) if(InitEffectSlot(device->DefaultSlot) != AL_NO_ERROR)
{ {
device->DefaultSlot = NULL; device->DefaultSlot = NULL;