1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-10 16:14:26 +00:00

Merge branch 'audio-device-close-error' into 'master'

don't forget to close the audio device after you're done with it.

See merge request OpenMW/openmw!759
This commit is contained in:
psi29a 2021-04-22 18:42:57 +00:00
commit 138d3b65a3

View File

@ -37,7 +37,9 @@ std::vector<const char *> Launcher::enumerateOpenALDevicesHrtf()
std::vector<const char *> ret;
ALCdevice *device = alcOpenDevice(nullptr);
if(device && alcIsExtensionPresent(device, "ALC_SOFT_HRTF"))
if(device)
{
if(alcIsExtensionPresent(device, "ALC_SOFT_HRTF"))
{
LPALCGETSTRINGISOFT alcGetStringiSOFT = nullptr;
void* funcPtr = alcGetProcAddress(device, "alcGetStringiSOFT");
@ -45,11 +47,15 @@ std::vector<const char *> Launcher::enumerateOpenALDevicesHrtf()
ALCint num_hrtf;
alcGetIntegerv(device, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &num_hrtf);
ret.reserve(num_hrtf);
for(ALCint i = 0;i < num_hrtf && i < 20;++i)
for(ALCint i = 0;i < num_hrtf;++i)
{
const ALCchar *entry = alcGetStringiSOFT(device, ALC_HRTF_SPECIFIER_SOFT, i);
if(strcmp(entry, "") == 0)
break;
ret.emplace_back(entry);
}
}
alcCloseDevice(device);
}
return ret;
}