Avoid function calls to get the HRTF sample rate and IR size

This commit is contained in:
Chris Robinson 2016-07-07 10:26:42 -07:00
parent b495d80f56
commit 7ec89b4b6e
6 changed files with 21 additions and 36 deletions

View File

@ -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;
}
}

View File

@ -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++)

View File

@ -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;

View File

@ -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 */

View File

@ -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);

View File

@ -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);