diff options
author | Chris Robinson <[email protected]> | 2017-04-05 12:27:30 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-04-05 12:27:30 -0700 |
commit | 2eaa10fc213dd60b197129da17b431b3d7e9f1d5 (patch) | |
tree | 21795210b08e9d29b5afff3fcfe557e58b079f05 /Alc/ALc.c | |
parent | f76dea0c0321ebcc0f5a8838f1826309463cd2c1 (diff) |
Load HRTF files as needed
Currently only applies to external files, rather than embedded datasets. Also,
HRTFs aren't unloaded after being loaded, until library shutdown.
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r-- | Alc/ALc.c | 40 |
1 files changed, 8 insertions, 32 deletions
@@ -2049,6 +2049,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(hrtf_userreq == Hrtf_Enable || (hrtf_userreq != Hrtf_Disable && hrtf_appreq == Hrtf_Enable)) { + const struct Hrtf *hrtf = NULL; if(VECTOR_SIZE(device->HrtfList) == 0) { VECTOR_DEINIT(device->HrtfList); @@ -2056,9 +2057,14 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) } if(VECTOR_SIZE(device->HrtfList) > 0) { - const struct Hrtf *hrtf = VECTOR_ELEM(device->HrtfList, 0).hrtf->handle; if(hrtf_id >= 0 && (size_t)hrtf_id < VECTOR_SIZE(device->HrtfList)) - hrtf = VECTOR_ELEM(device->HrtfList, hrtf_id).hrtf->handle; + hrtf = GetLoadedHrtf(VECTOR_ELEM(device->HrtfList, hrtf_id).hrtf); + else + hrtf = GetLoadedHrtf(VECTOR_ELEM(device->HrtfList, 0).hrtf); + } + + if(hrtf) + { device->FmtChans = DevFmtStereo; device->Frequency = hrtf->sampleRate; device->Flags |= DEVICE_CHANNELS_REQUEST | DEVICE_FREQUENCY_REQUEST; @@ -2071,36 +2077,6 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) } } } - else if(hrtf_appreq == Hrtf_Enable) - { - size_t i = VECTOR_SIZE(device->HrtfList); - /* 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 - * that'll work. - */ - if(device->FmtChans == DevFmtStereo) - { - if(VECTOR_SIZE(device->HrtfList) == 0) - { - VECTOR_DEINIT(device->HrtfList); - device->HrtfList = EnumerateHrtf(device->DeviceName); - } - for(i = 0;i < VECTOR_SIZE(device->HrtfList);i++) - { - const struct Hrtf *hrtf = VECTOR_ELEM(device->HrtfList, i).hrtf->handle; - if(hrtf->sampleRate == device->Frequency) - break; - } - } - if(i == VECTOR_SIZE(device->HrtfList)) - { - ERR("Requested format not HRTF compatible: %s, %uhz\n", - DevFmtChannelsString(device->FmtChans), device->Frequency); - hrtf_appreq = Hrtf_Disable; - device->HrtfStatus = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; - } - } oldFreq = device->Frequency; oldChans = device->FmtChans; |