From cd419256ad16170dd796701fa4aadf99902f7712 Mon Sep 17 00:00:00 2001 From: Simon Meulenbeek Date: Thu, 22 Apr 2021 18:42:56 +0000 Subject: [PATCH] don't forget to close the audio device after you're done with it. --- apps/launcher/utils/openalutil.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/apps/launcher/utils/openalutil.cpp b/apps/launcher/utils/openalutil.cpp index 6f76b7130..52ad20894 100644 --- a/apps/launcher/utils/openalutil.cpp +++ b/apps/launcher/utils/openalutil.cpp @@ -37,19 +37,25 @@ std::vector Launcher::enumerateOpenALDevicesHrtf() std::vector ret; ALCdevice *device = alcOpenDevice(nullptr); - if(device && alcIsExtensionPresent(device, "ALC_SOFT_HRTF")) + if(device) { - LPALCGETSTRINGISOFT alcGetStringiSOFT = nullptr; - void* funcPtr = alcGetProcAddress(device, "alcGetStringiSOFT"); - memcpy(&alcGetStringiSOFT, &funcPtr, sizeof(funcPtr)); - 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) + if(alcIsExtensionPresent(device, "ALC_SOFT_HRTF")) { - const ALCchar *entry = alcGetStringiSOFT(device, ALC_HRTF_SPECIFIER_SOFT, i); - ret.emplace_back(entry); + LPALCGETSTRINGISOFT alcGetStringiSOFT = nullptr; + void* funcPtr = alcGetProcAddress(device, "alcGetStringiSOFT"); + memcpy(&alcGetStringiSOFT, &funcPtr, sizeof(funcPtr)); + 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) + { + const ALCchar *entry = alcGetStringiSOFT(device, ALC_HRTF_SPECIFIER_SOFT, i); + if(strcmp(entry, "") == 0) + break; + ret.emplace_back(entry); + } } + alcCloseDevice(device); } return ret; -} \ No newline at end of file +}