Assign the HRTF storage pointers separately

This commit is contained in:
Chris Robinson 2018-01-15 08:38:25 -08:00
parent 5acb2e5165
commit 44795b8614

View File

@ -343,20 +343,22 @@ static struct Hrtf *CreateHrtfStore(ALuint rate, ALsizei irSize,
Hrtf->evCount = evCount; Hrtf->evCount = evCount;
/* Set up pointers to storage following the main HRTF struct. */ /* Set up pointers to storage following the main HRTF struct. */
_azCount = (ALubyte*)(base + offset); Hrtf->azCount = _azCount; _azCount = (ALubyte*)(base + offset);
offset += sizeof(_azCount[0])*evCount; offset += sizeof(_azCount[0])*evCount;
offset = RoundUp(offset, sizeof(ALushort)); /* Align for ushort fields */ offset = RoundUp(offset, sizeof(ALushort)); /* Align for ushort fields */
_evOffset = (ALushort*)(base + offset); Hrtf->evOffset = _evOffset; _evOffset = (ALushort*)(base + offset);
offset += sizeof(_evOffset[0])*evCount; offset += sizeof(_evOffset[0])*evCount;
offset = RoundUp(offset, 16); /* Align for coefficients using SIMD */ offset = RoundUp(offset, 16); /* Align for coefficients using SIMD */
_coeffs = (ALfloat(*)[2])(base + offset); Hrtf->coeffs = _coeffs; _coeffs = (ALfloat(*)[2])(base + offset);
offset += sizeof(_coeffs[0])*irSize*irCount; offset += sizeof(_coeffs[0])*irSize*irCount;
_delays = (ALubyte(*)[2])(base + offset); Hrtf->delays = _delays; _delays = (ALubyte(*)[2])(base + offset);
offset += sizeof(_delays[0])*irCount; offset += sizeof(_delays[0])*irCount;
assert(offset == total);
/* Copy input data to storage. */ /* Copy input data to storage. */
for(i = 0;i < evCount;i++) _azCount[i] = azCount[i]; for(i = 0;i < evCount;i++) _azCount[i] = azCount[i];
for(i = 0;i < evCount;i++) _evOffset[i] = evOffset[i]; for(i = 0;i < evCount;i++) _evOffset[i] = evOffset[i];
@ -371,7 +373,11 @@ static struct Hrtf *CreateHrtfStore(ALuint rate, ALsizei irSize,
_delays[i][1] = delays[i][1]; _delays[i][1] = delays[i][1];
} }
assert(offset == total); /* Finally, assign the storage pointers. */
Hrtf->azCount = _azCount;
Hrtf->evOffset = _evOffset;
Hrtf->coeffs = _coeffs;
Hrtf->delays = _delays;
} }
return Hrtf; return Hrtf;