aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-07-07 10:26:42 -0700
committerChris Robinson <[email protected]>2016-07-07 10:26:42 -0700
commit7ec89b4b6e787c9bb0b73aea7f736351f1b0bfca (patch)
treeb12b9da8d160048f7aaa8da8d4e8eb9cef2daecd
parentb495d80f5624328569bd0d8b9478927c0fc32100 (diff)
Avoid function calls to get the HRTF sample rate and IR size
-rw-r--r--Alc/ALc.c6
-rw-r--r--Alc/ALu.c2
-rw-r--r--Alc/hrtf.c25
-rw-r--r--Alc/hrtf.h18
-rw-r--r--Alc/mixer.c2
-rw-r--r--Alc/panning.c4
6 files changed, 21 insertions, 36 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index c50f0b25..bc6304d7 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1906,9 +1906,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
{
device->FmtChans = DevFmtStereo;
if(hrtf_id >= 0 && (size_t)hrtf_id < VECTOR_SIZE(device->Hrtf_List))
- device->Frequency = GetHrtfSampleRate(VECTOR_ELEM(device->Hrtf_List, hrtf_id).hrtf);
+ device->Frequency = VECTOR_ELEM(device->Hrtf_List, hrtf_id).hrtf->sampleRate;
else
- device->Frequency = GetHrtfSampleRate(VECTOR_ELEM(device->Hrtf_List, 0).hrtf);
+ device->Frequency = VECTOR_ELEM(device->Hrtf_List, 0).hrtf->sampleRate;
device->Flags |= DEVICE_CHANNELS_REQUEST | DEVICE_FREQUENCY_REQUEST;
}
else
@@ -1937,7 +1937,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
for(i = 0;i < VECTOR_SIZE(device->Hrtf_List);i++)
{
const struct Hrtf *hrtf = VECTOR_ELEM(device->Hrtf_List, i).hrtf;
- if(GetHrtfSampleRate(hrtf) == device->Frequency)
+ if(hrtf->sampleRate == device->Frequency)
break;
}
}
diff --git a/Alc/ALu.c b/Alc/ALu.c
index ac9057b7..ac958d41 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1506,7 +1506,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
if(lidx != -1 && ridx != -1)
{
HrtfMixerFunc HrtfMix = SelectHrtfMixer();
- ALuint irsize = GetHrtfIrSize(device->Hrtf);
+ ALuint irsize = device->Hrtf->irSize;
MixHrtfParams hrtfparams;
memset(&hrtfparams, 0, sizeof(hrtfparams));
for(c = 0;c < device->Dry.NumChannels;c++)
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index 1f972f87..eb586d38 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -44,20 +44,6 @@
#define MIN_AZ_COUNT (1)
#define MAX_AZ_COUNT (128)
-struct Hrtf {
- ALuint sampleRate;
- ALuint irSize;
- ALubyte evCount;
-
- const ALubyte *azCount;
- const ALushort *evOffset;
- const ALshort *coeffs;
- const ALubyte *delays;
-
- const char *filename;
- struct Hrtf *next;
-};
-
static const ALchar magicMarker00[8] = "MinPHR00";
static const ALchar magicMarker01[8] = "MinPHR01";
@@ -696,17 +682,6 @@ void FreeHrtfList(vector_HrtfEntry *list)
}
-ALuint GetHrtfSampleRate(const struct Hrtf *Hrtf)
-{
- return Hrtf->sampleRate;
-}
-
-ALuint GetHrtfIrSize(const struct Hrtf *Hrtf)
-{
- return Hrtf->irSize;
-}
-
-
void FreeHrtfs(void)
{
struct Hrtf *Hrtf = LoadedHrtfs;
diff --git a/Alc/hrtf.h b/Alc/hrtf.h
index e8a127c7..e9f04d49 100644
--- a/Alc/hrtf.h
+++ b/Alc/hrtf.h
@@ -6,7 +6,20 @@
#include "alstring.h"
-struct Hrtf;
+
+struct Hrtf {
+ ALuint sampleRate;
+ ALuint irSize;
+ ALubyte evCount;
+
+ const ALubyte *azCount;
+ const ALushort *evOffset;
+ const ALshort *coeffs;
+ const ALubyte *delays;
+
+ const char *filename;
+ struct Hrtf *next;
+};
typedef struct HrtfEntry {
al_string name;
@@ -27,9 +40,6 @@ void FreeHrtfs(void);
vector_HrtfEntry EnumerateHrtf(const_al_string devname);
void FreeHrtfList(vector_HrtfEntry *list);
-ALuint GetHrtfSampleRate(const struct Hrtf *Hrtf);
-ALuint GetHrtfIrSize(const struct Hrtf *Hrtf);
-
void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat spread, ALfloat gain, ALfloat (*coeffs)[2], ALuint *delays);
#endif /* ALC_HRTF_H */
diff --git a/Alc/mixer.c b/Alc/mixer.c
index 1ee422be..094d3768 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -393,7 +393,7 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
Looping = voice->Looping;
increment = voice->Step;
- IrSize = (Device->Hrtf ? GetHrtfIrSize(Device->Hrtf) : 0);
+ IrSize = (Device->Hrtf ? Device->Hrtf->irSize : 0);
Resample = ((increment == FRACTIONONE && DataPosFrac == 0) ?
Resample_copy32_C : ResampleSamples);
diff --git a/Alc/panning.c b/Alc/panning.c
index c7bc82f8..bfdd47e2 100644
--- a/Alc/panning.c
+++ b/Alc/panning.c
@@ -922,7 +922,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf
if(hrtf_id >= 0 && (size_t)hrtf_id < VECTOR_SIZE(device->Hrtf_List))
{
const HrtfEntry *entry = &VECTOR_ELEM(device->Hrtf_List, hrtf_id);
- if(GetHrtfSampleRate(entry->hrtf) == device->Frequency)
+ if(entry->hrtf->sampleRate == device->Frequency)
{
device->Hrtf = entry->hrtf;
al_string_copy(&device->Hrtf_Name, entry->name);
@@ -932,7 +932,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf
for(i = 0;!device->Hrtf && i < VECTOR_SIZE(device->Hrtf_List);i++)
{
const HrtfEntry *entry = &VECTOR_ELEM(device->Hrtf_List, i);
- if(GetHrtfSampleRate(entry->hrtf) == device->Frequency)
+ if(entry->hrtf->sampleRate == device->Frequency)
{
device->Hrtf = entry->hrtf;
al_string_copy(&device->Hrtf_Name, entry->name);