1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 15:15:31 +00:00

Fix gcc warning about function casts

This commit is contained in:
scrawl 2015-12-08 16:48:25 +01:00
parent 624809c8dc
commit e69750905a

View file

@ -50,6 +50,20 @@ namespace
const int sLoudnessFPS = 20; // loudness values per second of audio const int sLoudnessFPS = 20; // loudness values per second of audio
// Helper to get an OpenAL extension function
template<typename T, typename R>
void convertPointer(T& dest, R src)
{
memcpy(&dest, &src, sizeof(src));
}
template<typename T>
void getFunc(T& func, ALCdevice *device, const char *name)
{
void* funcPtr = alcGetProcAddress(device, name);
convertPointer(func, funcPtr);
}
} }
namespace MWSound namespace MWSound
@ -602,9 +616,8 @@ std::vector<std::string> OpenAL_Output::enumerateHrtf()
if(!alcIsExtensionPresent(mDevice, "ALC_SOFT_HRTF")) if(!alcIsExtensionPresent(mDevice, "ALC_SOFT_HRTF"))
return ret; return ret;
LPALCGETSTRINGISOFT alcGetStringiSOFT = reinterpret_cast<LPALCGETSTRINGISOFT>( LPALCGETSTRINGISOFT alcGetStringiSOFT = 0;
alcGetProcAddress(mDevice, "alcGetStringiSOFT") getFunc(alcGetStringiSOFT, mDevice, "alcGetStringiSOFT");
);
ALCint num_hrtf; ALCint num_hrtf;
alcGetIntegerv(mDevice, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &num_hrtf); alcGetIntegerv(mDevice, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &num_hrtf);
@ -626,12 +639,12 @@ void OpenAL_Output::enableHrtf(const std::string &hrtfname, bool auto_enable)
return; return;
} }
LPALCGETSTRINGISOFT alcGetStringiSOFT = reinterpret_cast<LPALCGETSTRINGISOFT>(
alcGetProcAddress(mDevice, "alcGetStringiSOFT") LPALCGETSTRINGISOFT alcGetStringiSOFT = 0;
); getFunc(alcGetStringiSOFT, mDevice, "alcGetStringiSOFT");
LPALCRESETDEVICESOFT alcResetDeviceSOFT = reinterpret_cast<LPALCRESETDEVICESOFT>(
alcGetProcAddress(mDevice, "alcResetDeviceSOFT") LPALCRESETDEVICESOFT alcResetDeviceSOFT = 0;
); getFunc(alcResetDeviceSOFT, mDevice, "alcResetDeviceSOFT");
std::vector<ALCint> attrs; std::vector<ALCint> attrs;
attrs.push_back(ALC_HRTF_SOFT); attrs.push_back(ALC_HRTF_SOFT);
@ -681,9 +694,8 @@ void OpenAL_Output::disableHrtf()
return; return;
} }
LPALCRESETDEVICESOFT alcResetDeviceSOFT = reinterpret_cast<LPALCRESETDEVICESOFT>( LPALCRESETDEVICESOFT alcResetDeviceSOFT = 0;
alcGetProcAddress(mDevice, "alcResetDeviceSOFT") getFunc(alcResetDeviceSOFT, mDevice, "alcResetDeviceSOFT");
);
std::vector<ALCint> attrs; std::vector<ALCint> attrs;
attrs.push_back(ALC_HRTF_SOFT); attrs.push_back(ALC_HRTF_SOFT);