diff options
author | Chris Robinson <[email protected]> | 2016-08-24 00:25:28 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-08-24 00:25:28 -0700 |
commit | 8bf4a22876c30c16db71cd9063b9788c5e6a1aa8 (patch) | |
tree | 56d971457f23a819f8a7d051ca5d8925e3bcfe2f | |
parent | e77de8b12a01bc9385ec0b7b528274b799bac81e (diff) |
Combine related members into a struct
-rw-r--r-- | Alc/ALc.c | 78 | ||||
-rw-r--r-- | Alc/ALu.c | 14 | ||||
-rw-r--r-- | Alc/effects/reverb.c | 4 | ||||
-rw-r--r-- | Alc/mixer.c | 2 | ||||
-rw-r--r-- | Alc/panning.c | 51 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 22 |
6 files changed, 87 insertions, 84 deletions
@@ -1923,7 +1923,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) /************************************************************************* * Update device format request if HRTF is requested */ - device->Hrtf_Status = ALC_HRTF_DISABLED_SOFT; + device->Hrtf.Status = ALC_HRTF_DISABLED_SOFT; if(device->Type != Loopback) { const char *hrtf; @@ -1939,31 +1939,31 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(hrtf_userreq == Hrtf_Enable || (hrtf_userreq != Hrtf_Disable && hrtf_appreq == Hrtf_Enable)) { - if(VECTOR_SIZE(device->Hrtf_List) == 0) + if(VECTOR_SIZE(device->Hrtf.List) == 0) { - VECTOR_DEINIT(device->Hrtf_List); - device->Hrtf_List = EnumerateHrtf(device->DeviceName); + VECTOR_DEINIT(device->Hrtf.List); + device->Hrtf.List = EnumerateHrtf(device->DeviceName); } - if(VECTOR_SIZE(device->Hrtf_List) > 0) + if(VECTOR_SIZE(device->Hrtf.List) > 0) { device->FmtChans = DevFmtStereo; - if(hrtf_id >= 0 && (size_t)hrtf_id < VECTOR_SIZE(device->Hrtf_List)) - device->Frequency = VECTOR_ELEM(device->Hrtf_List, hrtf_id).hrtf->sampleRate; + if(hrtf_id >= 0 && (size_t)hrtf_id < VECTOR_SIZE(device->Hrtf.List)) + device->Frequency = VECTOR_ELEM(device->Hrtf.List, hrtf_id).hrtf->sampleRate; else - device->Frequency = VECTOR_ELEM(device->Hrtf_List, 0).hrtf->sampleRate; + device->Frequency = VECTOR_ELEM(device->Hrtf.List, 0).hrtf->sampleRate; device->Flags |= DEVICE_CHANNELS_REQUEST | DEVICE_FREQUENCY_REQUEST; } else { hrtf_userreq = Hrtf_Default; hrtf_appreq = Hrtf_Disable; - device->Hrtf_Status = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; + device->Hrtf.Status = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; } } } else if(hrtf_appreq == Hrtf_Enable) { - size_t i = VECTOR_SIZE(device->Hrtf_List); + size_t i = VECTOR_SIZE(device->Hrtf.List); /* Loopback device. We don't need to match to a specific HRTF entry * here. If the requested ID matches, we'll pick that later, if not, * we'll try to auto-select one anyway. Just make sure one exists @@ -1971,24 +1971,24 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) */ if(device->FmtChans == DevFmtStereo) { - if(VECTOR_SIZE(device->Hrtf_List) == 0) + if(VECTOR_SIZE(device->Hrtf.List) == 0) { - VECTOR_DEINIT(device->Hrtf_List); - device->Hrtf_List = EnumerateHrtf(device->DeviceName); + VECTOR_DEINIT(device->Hrtf.List); + device->Hrtf.List = EnumerateHrtf(device->DeviceName); } - for(i = 0;i < VECTOR_SIZE(device->Hrtf_List);i++) + for(i = 0;i < VECTOR_SIZE(device->Hrtf.List);i++) { - const struct Hrtf *hrtf = VECTOR_ELEM(device->Hrtf_List, i).hrtf; + const struct Hrtf *hrtf = VECTOR_ELEM(device->Hrtf.List, i).hrtf; if(hrtf->sampleRate == device->Frequency) break; } } - if(i == VECTOR_SIZE(device->Hrtf_List)) + if(i == VECTOR_SIZE(device->Hrtf.List)) { ERR("Requested format not HRTF compatible: %s, %uhz\n", DevFmtChannelsString(device->FmtChans), device->Frequency); hrtf_appreq = Hrtf_Disable; - device->Hrtf_Status = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; + device->Hrtf.Status = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; } } @@ -2043,7 +2043,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) size = device->Dry.NumChannels * sizeof(device->Dry.Buffer[0]); if((device->AmbiDecoder && bformatdec_getOrder(device->AmbiDecoder) >= 2)) size += (ChannelsFromDevFmt(device->FmtChans)+4) * sizeof(device->Dry.Buffer[0]); - else if(device->Hrtf || device->Uhj_Encoder || device->AmbiDecoder) + else if(device->Hrtf.Handle || device->Uhj_Encoder || device->AmbiDecoder) size += ChannelsFromDevFmt(device->FmtChans) * sizeof(device->Dry.Buffer[0]); else if(device->FmtChans > DevFmtAmbi1 && device->FmtChans <= DevFmtAmbi3) size += 4 * sizeof(device->Dry.Buffer[0]); @@ -2054,7 +2054,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) return ALC_INVALID_DEVICE; } - if(device->Hrtf || device->Uhj_Encoder || device->AmbiDecoder) + if(device->Hrtf.Handle || device->Uhj_Encoder || device->AmbiDecoder) { device->RealOut.Buffer = device->Dry.Buffer + device->Dry.NumChannels; device->RealOut.NumChannels = ChannelsFromDevFmt(device->FmtChans); @@ -2204,8 +2204,8 @@ static ALCvoid FreeDevice(ALCdevice *device) } ResetUIntMap(&device->FilterMap); - AL_STRING_DEINIT(device->Hrtf_Name); - FreeHrtfList(&device->Hrtf_List); + AL_STRING_DEINIT(device->Hrtf.Name); + FreeHrtfList(&device->Hrtf.List); al_free(device->Bs2b); device->Bs2b = NULL; @@ -2683,7 +2683,7 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *Device, ALCenum para else { almtx_lock(&Device->BackendLock); - value = (Device->Hrtf ? al_string_get_cstr(Device->Hrtf_Name) : ""); + value = (Device->Hrtf.Handle ? al_string_get_cstr(Device->Hrtf.Name) : ""); almtx_unlock(&Device->BackendLock); ALCdevice_DecRef(Device); } @@ -2824,10 +2824,10 @@ static ALCsizei GetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALC values[i++] = device->NumAuxSends; values[i++] = ALC_HRTF_SOFT; - values[i++] = (device->Hrtf ? ALC_TRUE : ALC_FALSE); + values[i++] = (device->Hrtf.Handle ? ALC_TRUE : ALC_FALSE); values[i++] = ALC_HRTF_STATUS_SOFT; - values[i++] = device->Hrtf_Status; + values[i++] = device->Hrtf.Status; almtx_unlock(&device->BackendLock); values[i++] = 0; @@ -2892,18 +2892,18 @@ static ALCsizei GetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALC return 1; case ALC_HRTF_SOFT: - values[0] = (device->Hrtf ? ALC_TRUE : ALC_FALSE); + values[0] = (device->Hrtf.Handle ? ALC_TRUE : ALC_FALSE); return 1; case ALC_HRTF_STATUS_SOFT: - values[0] = device->Hrtf_Status; + values[0] = device->Hrtf.Status; return 1; case ALC_NUM_HRTF_SPECIFIERS_SOFT: almtx_lock(&device->BackendLock); - FreeHrtfList(&device->Hrtf_List); - device->Hrtf_List = EnumerateHrtf(device->DeviceName); - values[0] = (ALCint)VECTOR_SIZE(device->Hrtf_List); + FreeHrtfList(&device->Hrtf.List); + device->Hrtf.List = EnumerateHrtf(device->DeviceName); + values[0] = (ALCint)VECTOR_SIZE(device->Hrtf.List); almtx_unlock(&device->BackendLock); return 1; @@ -2994,10 +2994,10 @@ ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname, values[i++] = device->NumAuxSends; values[i++] = ALC_HRTF_SOFT; - values[i++] = (device->Hrtf ? ALC_TRUE : ALC_FALSE); + values[i++] = (device->Hrtf.Handle ? ALC_TRUE : ALC_FALSE); values[i++] = ALC_HRTF_STATUS_SOFT; - values[i++] = device->Hrtf_Status; + values[i++] = device->Hrtf.Status; clock = V0(device->Backend,getClockLatency)(); values[i++] = ALC_DEVICE_CLOCK_SOFT; @@ -3403,8 +3403,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->Flags = 0; device->Bs2b = NULL; device->Uhj_Encoder = NULL; - VECTOR_INIT(device->Hrtf_List); - AL_STRING_INIT(device->Hrtf_Name); + VECTOR_INIT(device->Hrtf.List); + AL_STRING_INIT(device->Hrtf.Name); device->Render_Mode = NormalRender; AL_STRING_INIT(device->DeviceName); device->Dry.Buffer = NULL; @@ -3683,8 +3683,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, device->Connected = ALC_TRUE; device->Type = Capture; - VECTOR_INIT(device->Hrtf_List); - AL_STRING_INIT(device->Hrtf_Name); + VECTOR_INIT(device->Hrtf.List); + AL_STRING_INIT(device->Hrtf.Name); AL_STRING_INIT(device->DeviceName); device->Dry.Buffer = NULL; @@ -3878,8 +3878,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN ATOMIC_INIT(&device->LastError, ALC_NO_ERROR); device->Flags = 0; - VECTOR_INIT(device->Hrtf_List); - AL_STRING_INIT(device->Hrtf_Name); + VECTOR_INIT(device->Hrtf.List); + AL_STRING_INIT(device->Hrtf.Name); device->Bs2b = NULL; device->Uhj_Encoder = NULL; device->Render_Mode = NormalRender; @@ -4065,8 +4065,8 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetStringiSOFT(ALCdevice *device, ALCenum else switch(paramName) { case ALC_HRTF_SPECIFIER_SOFT: - if(index >= 0 && (size_t)index < VECTOR_SIZE(device->Hrtf_List)) - str = al_string_get_cstr(VECTOR_ELEM(device->Hrtf_List, index).name); + if(index >= 0 && (size_t)index < VECTOR_SIZE(device->Hrtf.List)) + str = al_string_get_cstr(VECTOR_ELEM(device->Hrtf.List, index).name); else alcSetError(device, ALC_INVALID_VALUE); break; @@ -649,7 +649,7 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps * } /* Get the static HRIR coefficients and delays for this channel. */ - GetLerpedHrtfCoeffs(Device->Hrtf, + GetLerpedHrtfCoeffs(Device->Hrtf.Handle, chans[c].elevation, chans[c].angle, 0.0f, DryGain, voice->Chan[c].Direct.Hrtf.Target.Coeffs, voice->Chan[c].Direct.Hrtf.Target.Delay @@ -1165,7 +1165,7 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro spread = asinf(radius / Distance) * 2.0f; /* Get the HRIR coefficients and delays. */ - GetLerpedHrtfCoeffs(Device->Hrtf, ev, az, spread, DryGain, + GetLerpedHrtfCoeffs(Device->Hrtf.Handle, ev, az, spread, DryGain, voice->Chan[0].Direct.Hrtf.Target.Coeffs, voice->Chan[0].Direct.Hrtf.Target.Delay); @@ -1526,23 +1526,23 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) V0(device->Backend,unlock)(); IncrementRef(&device->MixCount); - if(device->Hrtf) + if(device->Hrtf.Handle) { int lidx = GetChannelIdxByName(device->RealOut, FrontLeft); int ridx = GetChannelIdxByName(device->RealOut, FrontRight); if(lidx != -1 && ridx != -1) { HrtfDirectMixerFunc HrtfMix = SelectHrtfMixer(); - ALuint irsize = device->Hrtf_IrSize; + ALuint irsize = device->Hrtf.IrSize; for(c = 0;c < device->Dry.NumChannels;c++) { HrtfMix(device->RealOut.Buffer, lidx, ridx, - device->Dry.Buffer[c], device->Hrtf_Offset, irsize, - device->Hrtf_Coeffs[c], device->Hrtf_Values[c], + device->Dry.Buffer[c], device->Hrtf.Offset, irsize, + device->Hrtf.Coeffs[c], device->Hrtf.Values[c], SamplesToDo ); } - device->Hrtf_Offset += SamplesToDo; + device->Hrtf.Offset += SamplesToDo; } } else if(device->AmbiDecoder) diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c index 71c39f8c..e6a9e05a 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -391,7 +391,7 @@ static ALboolean ALreverbState_deviceUpdate(ALreverbState *State, ALCdevice *Dev return AL_FALSE; /* HRTF and UHJ will mix to the real output for ambient output. */ - if(Device->Hrtf || Device->Uhj_Encoder) + if(Device->Hrtf.Handle || Device->Uhj_Encoder) { State->ExtraOut = Device->RealOut.Buffer; State->ExtraChannels = Device->RealOut.NumChannels; @@ -956,7 +956,7 @@ static ALvoid ALreverbState_update(ALreverbState *State, const ALCdevice *Device gain = props->Reverb.Gain * Slot->Params.Gain * ReverbBoost; // Update early and late 3D panning. - if(Device->Hrtf || Device->Uhj_Encoder) + if(Device->Hrtf.Handle || Device->Uhj_Encoder) UpdateMixedPanning(Device, props->Reverb.ReflectionsPan, props->Reverb.LateReverbPan, gain, props->Reverb.ReflectionsGain, diff --git a/Alc/mixer.c b/Alc/mixer.c index 9f6ec9d1..bbf70153 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -393,7 +393,7 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam SampleSize = Source->SampleSize; increment = voice->Step; - IrSize = (Device->Hrtf ? Device->Hrtf->irSize : 0); + IrSize = (Device->Hrtf.Handle ? Device->Hrtf.Handle->irSize : 0); Resample = ((increment == FRACTIONONE && DataPosFrac == 0) ? Resample_copy32_C : ResampleSamples); diff --git a/Alc/panning.c b/Alc/panning.c index 70494547..172861da 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -772,12 +772,13 @@ static void InitHrtfPanning(ALCdevice *device) device->FOAOut.Ambi = device->Dry.Ambi; device->FOAOut.CoeffCount = device->Dry.CoeffCount; - memset(device->Hrtf_Coeffs, 0, sizeof(device->Hrtf_Coeffs)); - device->Hrtf_IrSize = BuildBFormatHrtf(device->Hrtf, device->Hrtf_Coeffs, - device->Dry.NumChannels); + memset(device->Hrtf.Coeffs, 0, sizeof(device->Hrtf.Coeffs)); + device->Hrtf.IrSize = BuildBFormatHrtf(device->Hrtf.Handle, + device->Hrtf.Coeffs, device->Dry.NumChannels + ); /* Round up to the nearest multiple of 8 */ - device->Hrtf_IrSize = (device->Hrtf_IrSize+7)&~7; + device->Hrtf.IrSize = (device->Hrtf.IrSize+7)&~7; } static void InitUhjPanning(ALCdevice *device) @@ -805,8 +806,8 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf int bs2blevel; size_t i; - device->Hrtf = NULL; - al_string_clear(&device->Hrtf_Name); + device->Hrtf.Handle = NULL; + al_string_clear(&device->Hrtf.Name); device->Render_Mode = NormalRender; memset(&device->Dry.Ambi, 0, sizeof(device->Dry.Ambi)); @@ -820,7 +821,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf AmbDecConf conf, *pconf = NULL; if(hrtf_appreq == Hrtf_Enable) - device->Hrtf_Status = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; + device->Hrtf.Status = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; ambdec_init(&conf); @@ -920,48 +921,48 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf (hrtf_appreq == Hrtf_Enable); if(!usehrtf) goto no_hrtf; - device->Hrtf_Status = ALC_HRTF_ENABLED_SOFT; + device->Hrtf.Status = ALC_HRTF_ENABLED_SOFT; if(headphones && hrtf_appreq != Hrtf_Disable) - device->Hrtf_Status = ALC_HRTF_HEADPHONES_DETECTED_SOFT; + device->Hrtf.Status = ALC_HRTF_HEADPHONES_DETECTED_SOFT; } else { if(hrtf_userreq != Hrtf_Enable) { if(hrtf_appreq == Hrtf_Enable) - device->Hrtf_Status = ALC_HRTF_DENIED_SOFT; + device->Hrtf.Status = ALC_HRTF_DENIED_SOFT; goto no_hrtf; } - device->Hrtf_Status = ALC_HRTF_REQUIRED_SOFT; + device->Hrtf.Status = ALC_HRTF_REQUIRED_SOFT; } - if(VECTOR_SIZE(device->Hrtf_List) == 0) + if(VECTOR_SIZE(device->Hrtf.List) == 0) { - VECTOR_DEINIT(device->Hrtf_List); - device->Hrtf_List = EnumerateHrtf(device->DeviceName); + VECTOR_DEINIT(device->Hrtf.List); + device->Hrtf.List = EnumerateHrtf(device->DeviceName); } - if(hrtf_id >= 0 && (size_t)hrtf_id < VECTOR_SIZE(device->Hrtf_List)) + if(hrtf_id >= 0 && (size_t)hrtf_id < VECTOR_SIZE(device->Hrtf.List)) { - const HrtfEntry *entry = &VECTOR_ELEM(device->Hrtf_List, hrtf_id); + const HrtfEntry *entry = &VECTOR_ELEM(device->Hrtf.List, hrtf_id); if(entry->hrtf->sampleRate == device->Frequency) { - device->Hrtf = entry->hrtf; - al_string_copy(&device->Hrtf_Name, entry->name); + device->Hrtf.Handle = entry->hrtf; + al_string_copy(&device->Hrtf.Name, entry->name); } } - for(i = 0;!device->Hrtf && i < VECTOR_SIZE(device->Hrtf_List);i++) + for(i = 0;!device->Hrtf.Handle && i < VECTOR_SIZE(device->Hrtf.List);i++) { - const HrtfEntry *entry = &VECTOR_ELEM(device->Hrtf_List, i); + const HrtfEntry *entry = &VECTOR_ELEM(device->Hrtf.List, i); if(entry->hrtf->sampleRate == device->Frequency) { - device->Hrtf = entry->hrtf; - al_string_copy(&device->Hrtf_Name, entry->name); + device->Hrtf.Handle = entry->hrtf; + al_string_copy(&device->Hrtf.Name, entry->name); } } - if(device->Hrtf) + if(device->Hrtf.Handle) { device->Render_Mode = HrtfRender; if(ConfigValueStr(al_string_get_cstr(device->DeviceName), NULL, "hrtf-mode", &mode)) @@ -974,11 +975,11 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf ERR("Unexpected hrtf-mode: %s\n", mode); } - TRACE("HRTF enabled, \"%s\"\n", al_string_get_cstr(device->Hrtf_Name)); + TRACE("HRTF enabled, \"%s\"\n", al_string_get_cstr(device->Hrtf.Name)); InitHrtfPanning(device); return; } - device->Hrtf_Status = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; + device->Hrtf.Status = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; no_hrtf: TRACE("HRTF disabled\n"); diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index b173c515..56bfa0b0 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -593,16 +593,18 @@ struct ALCdevice_struct UIntMap FilterMap; /* HRTF filter tables */ - vector_HrtfEntry Hrtf_List; - al_string Hrtf_Name; - const struct Hrtf *Hrtf; - ALCenum Hrtf_Status; - - /* HRTF filter state for dry buffer content */ - alignas(16) ALfloat Hrtf_Values[4][HRIR_LENGTH][2]; - alignas(16) ALfloat Hrtf_Coeffs[4][HRIR_LENGTH][2]; - ALuint Hrtf_Offset; - ALuint Hrtf_IrSize; + struct { + vector_HrtfEntry List; + al_string Name; + ALCenum Status; + const struct Hrtf *Handle; + + /* HRTF filter state for dry buffer content */ + alignas(16) ALfloat Values[4][HRIR_LENGTH][2]; + alignas(16) ALfloat Coeffs[4][HRIR_LENGTH][2]; + ALuint Offset; + ALuint IrSize; + } Hrtf; /* UHJ encoder state */ struct Uhj2Encoder *Uhj_Encoder; |