aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/hrtf.c30
-rw-r--r--OpenAL32/Include/alMain.h10
2 files changed, 25 insertions, 15 deletions
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index 16db0c33..b94faf9d 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -468,6 +468,7 @@ static struct Hrtf *LoadHrtf00(const ALubyte *data, size_t datalen, const_al_str
{
size_t total = sizeof(struct Hrtf);
total += sizeof(azCount[0])*evCount;
+ total = (total+1)&~1; /* Align for (u)short fields */
total += sizeof(evOffset[0])*evCount;
total += sizeof(coeffs[0])*irSize*irCount;
total += sizeof(delays[0])*irCount;
@@ -483,14 +484,18 @@ static struct Hrtf *LoadHrtf00(const ALubyte *data, size_t datalen, const_al_str
if(!failed)
{
+ char *base = (char*)Hrtf;
+ uintptr_t offset = sizeof(*Hrtf);
+
Hrtf->sampleRate = rate;
Hrtf->irSize = irSize;
Hrtf->evCount = evCount;
- Hrtf->azCount = ((ALubyte*)(Hrtf+1));
- Hrtf->evOffset = ((ALushort*)(Hrtf->azCount + evCount));
- Hrtf->coeffs = ((ALshort*)(Hrtf->evOffset + evCount));
- Hrtf->delays = ((ALubyte*)(Hrtf->coeffs + irSize*irCount));
- Hrtf->filename = ((char*)(Hrtf->delays + irCount));
+ Hrtf->azCount = ((ALubyte*)(base + offset)); offset += evCount*sizeof(Hrtf->azCount[0]);
+ offset = (offset+1)&~1; /* Align for (u)short fields */
+ Hrtf->evOffset = ((ALushort*)(base + offset)); offset += evCount*sizeof(Hrtf->evOffset[0]);
+ Hrtf->coeffs = ((ALshort*)(base + offset)); offset += irSize*irCount*sizeof(Hrtf->coeffs[0]);
+ Hrtf->delays = ((ALubyte*)(base + offset)); offset += irCount*sizeof(Hrtf->delays[0]);
+ Hrtf->filename = ((char*)(base + offset));
Hrtf->next = NULL;
memcpy((void*)Hrtf->azCount, azCount, sizeof(azCount[0])*evCount);
@@ -644,6 +649,7 @@ static struct Hrtf *LoadHrtf01(const ALubyte *data, size_t datalen, const_al_str
{
size_t total = sizeof(struct Hrtf);
total += sizeof(azCount[0])*evCount;
+ total = (total+1)&~1; /* Align for (u)short fields */
total += sizeof(evOffset[0])*evCount;
total += sizeof(coeffs[0])*irSize*irCount;
total += sizeof(delays[0])*irCount;
@@ -659,14 +665,18 @@ static struct Hrtf *LoadHrtf01(const ALubyte *data, size_t datalen, const_al_str
if(!failed)
{
+ char *base = (char*)Hrtf;
+ uintptr_t offset = sizeof(*Hrtf);
+
Hrtf->sampleRate = rate;
Hrtf->irSize = irSize;
Hrtf->evCount = evCount;
- Hrtf->azCount = ((ALubyte*)(Hrtf+1));
- Hrtf->evOffset = ((ALushort*)(Hrtf->azCount + evCount));
- Hrtf->coeffs = ((ALshort*)(Hrtf->evOffset + evCount));
- Hrtf->delays = ((ALubyte*)(Hrtf->coeffs + irSize*irCount));
- Hrtf->filename = ((char*)(Hrtf->delays + irCount));
+ Hrtf->azCount = ((ALubyte*)(base + offset)); offset += evCount*sizeof(Hrtf->azCount[0]);
+ offset = (offset+1)&~1; /* Align for (u)short fields */
+ Hrtf->evOffset = ((ALushort*)(base + offset)); offset += evCount*sizeof(Hrtf->evOffset[0]);
+ Hrtf->coeffs = ((ALshort*)(base + offset)); offset += irSize*irCount*sizeof(Hrtf->coeffs[0]);
+ Hrtf->delays = ((ALubyte*)(base + offset)); offset += irCount*sizeof(Hrtf->delays[0]);
+ Hrtf->filename = ((char*)(base + offset));
Hrtf->next = NULL;
memcpy((void*)Hrtf->azCount, azCount, sizeof(azCount[0])*evCount);
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index d7975cea..ac537978 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -699,17 +699,17 @@ struct ALCdevice_struct
};
// Frequency was requested by the app or config file
-#define DEVICE_FREQUENCY_REQUEST (1<<1)
+#define DEVICE_FREQUENCY_REQUEST (1u<<1)
// Channel configuration was requested by the config file
-#define DEVICE_CHANNELS_REQUEST (1<<2)
+#define DEVICE_CHANNELS_REQUEST (1u<<2)
// Sample type was requested by the config file
-#define DEVICE_SAMPLE_TYPE_REQUEST (1<<3)
+#define DEVICE_SAMPLE_TYPE_REQUEST (1u<<3)
// Specifies if the DSP is paused at user request
-#define DEVICE_PAUSED (1<<30)
+#define DEVICE_PAUSED (1u<<30)
// Specifies if the device is currently running
-#define DEVICE_RUNNING (1<<31)
+#define DEVICE_RUNNING (1u<<31)
/* Nanosecond resolution for the device clock time. */