aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/hrtf.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-04-07 06:40:42 -0700
committerChris Robinson <[email protected]>2017-04-07 06:40:42 -0700
commitb551291840ee0b670fb54c41ec385702d51604d8 (patch)
tree1961622bbb8a3e43d6c3fe15a25b085d5bcd2d1d /Alc/hrtf.c
parent36f7dda1caafaef886ccd520ec3216c2689a062e (diff)
Allocate temp storage for delays when loading HRTFs
Diffstat (limited to 'Alc/hrtf.c')
-rw-r--r--Alc/hrtf.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index 32a6357e..8c6df0d6 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -317,7 +317,7 @@ static struct Hrtf *LoadHrtf00(const ALubyte *data, size_t datalen, const char *
ALubyte *azCount = NULL;
ALushort *evOffset = NULL;
ALshort *coeffs = NULL;
- const ALubyte *delays = NULL;
+ ALubyte *delays = NULL;
ALuint i, j;
if(datalen < 9)
@@ -416,6 +416,7 @@ static struct Hrtf *LoadHrtf00(const ALubyte *data, size_t datalen, const char *
if(!failed)
{
coeffs = malloc(sizeof(coeffs[0])*irSize*irCount);
+ delays = malloc(sizeof(delays[0])*irCount);
if(coeffs == NULL)
{
ERR("Out of memory.\n");
@@ -446,11 +447,10 @@ static struct Hrtf *LoadHrtf00(const ALubyte *data, size_t datalen, const char *
}
}
- delays = data;
- data += irCount;
- datalen -= irCount;
for(i = 0;i < irCount;i++)
{
+ delays[i] = *(data++);
+ datalen -= 1;
if(delays[i] > maxDelay)
{
ERR("Invalid delays[%d]: %d (%d)\n", i, delays[i], maxDelay);
@@ -466,6 +466,7 @@ static struct Hrtf *LoadHrtf00(const ALubyte *data, size_t datalen, const char *
free(azCount);
free(evOffset);
free(coeffs);
+ free(delays);
return Hrtf;
}
@@ -479,7 +480,7 @@ static struct Hrtf *LoadHrtf01(const ALubyte *data, size_t datalen, const char *
const ALubyte *azCount = NULL;
ALushort *evOffset = NULL;
ALshort *coeffs = NULL;
- const ALubyte *delays = NULL;
+ ALubyte *delays = NULL;
ALuint i, j;
if(datalen < 6)
@@ -556,6 +557,7 @@ static struct Hrtf *LoadHrtf01(const ALubyte *data, size_t datalen, const char *
}
coeffs = malloc(sizeof(coeffs[0])*irSize*irCount);
+ delays = malloc(sizeof(delays[0])*irCount);
if(coeffs == NULL)
{
ERR("Out of memory.\n");
@@ -588,11 +590,10 @@ static struct Hrtf *LoadHrtf01(const ALubyte *data, size_t datalen, const char *
}
}
- delays = data;
- data += irCount;
- datalen -= irCount;
for(i = 0;i < irCount;i++)
{
+ delays[i] = *(data++);
+ datalen -= 1;
if(delays[i] > maxDelay)
{
ERR("Invalid delays[%d]: %d (%d)\n", i, delays[i], maxDelay);
@@ -607,9 +608,11 @@ static struct Hrtf *LoadHrtf01(const ALubyte *data, size_t datalen, const char *
free(evOffset);
free(coeffs);
+ free(delays);
return Hrtf;
}
+
static void AddFileEntry(vector_EnumeratedHrtf *list, const_al_string filename)
{
EnumeratedHrtf entry = { AL_STRING_INIT_STATIC(), NULL };