mirror of https://github.com/OpenMW/openmw.git
Merge branch 'hrtf-setting' into 'master'
Add Audio settings to openmw-launcher See merge request OpenMW/openmw!692pull/3064/head
commit
484c46cb58
@ -0,0 +1,55 @@
|
|||||||
|
#include <cstring>
|
||||||
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <apps/openmw/mwsound/alext.h>
|
||||||
|
|
||||||
|
#include "openalutil.hpp"
|
||||||
|
|
||||||
|
#ifndef ALC_ALL_DEVICES_SPECIFIER
|
||||||
|
#define ALC_ALL_DEVICES_SPECIFIER 0x1013
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::vector<const char *> Launcher::enumerateOpenALDevices()
|
||||||
|
{
|
||||||
|
std::vector<const char *> devlist;
|
||||||
|
const ALCchar *devnames;
|
||||||
|
|
||||||
|
if(alcIsExtensionPresent(nullptr, "ALC_ENUMERATE_ALL_EXT"))
|
||||||
|
{
|
||||||
|
devnames = alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
devnames = alcGetString(nullptr, ALC_DEVICE_SPECIFIER);
|
||||||
|
}
|
||||||
|
|
||||||
|
while(devnames && *devnames)
|
||||||
|
{
|
||||||
|
devlist.emplace_back(devnames);
|
||||||
|
devnames += strlen(devnames)+1;
|
||||||
|
}
|
||||||
|
return devlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<const char *> Launcher::enumerateOpenALDevicesHrtf()
|
||||||
|
{
|
||||||
|
std::vector<const char *> ret;
|
||||||
|
|
||||||
|
ALCdevice *device = alcOpenDevice(nullptr);
|
||||||
|
if(device && alcIsExtensionPresent(device, "ALC_SOFT_HRTF"))
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
const ALCchar *entry = alcGetStringiSOFT(device, ALC_HRTF_SPECIFIER_SOFT, i);
|
||||||
|
ret.emplace_back(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Launcher
|
||||||
|
{
|
||||||
|
std::vector<const char *> enumerateOpenALDevices();
|
||||||
|
std::vector<const char *> enumerateOpenALDevicesHrtf();
|
||||||
|
}
|
Loading…
Reference in New Issue