diff options
author | Chris Robinson <[email protected]> | 2018-10-30 09:31:52 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-10-30 09:31:52 -0700 |
commit | e2a1dd4503be8cd1280be8d34826c4858c4d6ed2 (patch) | |
tree | 19b1aa99abc2b41ed23cfd642cf3b916eaf2dcb2 | |
parent | ce212c911c8634fb9ccd9944b00dcd6c2b28d516 (diff) |
Use std::wstring in place of some fixed WCHAR arrays
-rw-r--r-- | router/router.cpp | 25 | ||||
-rw-r--r-- | router/router.h | 203 |
2 files changed, 114 insertions, 114 deletions
diff --git a/router/router.cpp b/router/router.cpp index 4d0cf5a5..38d00e27 100644 --- a/router/router.cpp +++ b/router/router.cpp @@ -93,7 +93,7 @@ static void AddModule(HMODULE module, const WCHAR *name) FreeLibrary(module); return; } - if(wcscmp(drv.Name, name) == 0) + if(drv.Name == name) { TRACE("Skipping similarly-named module %ls\n", name); FreeLibrary(module); @@ -212,7 +212,7 @@ static void AddModule(HMODULE module, const WCHAR *name) if(!err) { ALCint alc_ver[2] = { 0, 0 }; - wcsncpy(newdrv.Name, name, 32); + newdrv.Name = name; newdrv.Module = module; newdrv.alcGetIntegerv(nullptr, ALC_MAJOR_VERSION, 1, &alc_ver[0]); newdrv.alcGetIntegerv(nullptr, ALC_MINOR_VERSION, 1, &alc_ver[1]); @@ -250,27 +250,26 @@ static void AddModule(HMODULE module, const WCHAR *name) static void SearchDrivers(WCHAR *path) { - WCHAR srchPath[MAX_PATH+1] = L""; WIN32_FIND_DATAW fdata; - HANDLE srchHdl; TRACE("Searching for drivers in %ls...\n", path); - wcsncpy(srchPath, path, MAX_PATH); - wcsncat(srchPath, L"\\*oal.dll", MAX_PATH - lstrlenW(srchPath)); - srchHdl = FindFirstFileW(srchPath, &fdata); + std::wstring srchPath = path; + srchPath += L"\\*oal.dll"; + + HANDLE srchHdl = FindFirstFileW(srchPath.c_str(), &fdata); if(srchHdl != INVALID_HANDLE_VALUE) { do { HMODULE mod; - wcsncpy(srchPath, path, MAX_PATH); - wcsncat(srchPath, L"\\", MAX_PATH - lstrlenW(srchPath)); - wcsncat(srchPath, fdata.cFileName, MAX_PATH - lstrlenW(srchPath)); - TRACE("Found %ls\n", srchPath); + srchPath = path; + srchPath += L"\\"; + srchPath += fdata.cFileName; + TRACE("Found %ls\n", srchPath.c_str()); - mod = LoadLibraryW(srchPath); + mod = LoadLibraryW(srchPath.c_str()); if(!mod) - WARN("Could not load %ls\n", srchPath); + WARN("Could not load %ls\n", srchPath.c_str()); else AddModule(mod, fdata.cFileName); } while(FindNextFileW(srchHdl, &fdata)); diff --git a/router/router.h b/router/router.h index c7d2c89e..3ac0ab40 100644 --- a/router/router.h +++ b/router/router.h @@ -9,6 +9,7 @@ #include <vector> #include <atomic> +#include <string> #include "AL/alc.h" #include "AL/al.h" @@ -35,107 +36,107 @@ extern "C" { #define MAKE_ALC_VER(major, minor) (((major)<<8) | (minor)) typedef struct DriverIface { - WCHAR Name[32]; - HMODULE Module; - int ALCVer; - - LPALCCREATECONTEXT alcCreateContext; - LPALCMAKECONTEXTCURRENT alcMakeContextCurrent; - LPALCPROCESSCONTEXT alcProcessContext; - LPALCSUSPENDCONTEXT alcSuspendContext; - LPALCDESTROYCONTEXT alcDestroyContext; - LPALCGETCURRENTCONTEXT alcGetCurrentContext; - LPALCGETCONTEXTSDEVICE alcGetContextsDevice; - LPALCOPENDEVICE alcOpenDevice; - LPALCCLOSEDEVICE alcCloseDevice; - LPALCGETERROR alcGetError; - LPALCISEXTENSIONPRESENT alcIsExtensionPresent; - LPALCGETPROCADDRESS alcGetProcAddress; - LPALCGETENUMVALUE alcGetEnumValue; - LPALCGETSTRING alcGetString; - LPALCGETINTEGERV alcGetIntegerv; - LPALCCAPTUREOPENDEVICE alcCaptureOpenDevice; - LPALCCAPTURECLOSEDEVICE alcCaptureCloseDevice; - LPALCCAPTURESTART alcCaptureStart; - LPALCCAPTURESTOP alcCaptureStop; - LPALCCAPTURESAMPLES alcCaptureSamples; - - PFNALCSETTHREADCONTEXTPROC alcSetThreadContext; - PFNALCGETTHREADCONTEXTPROC alcGetThreadContext; - - LPALENABLE alEnable; - LPALDISABLE alDisable; - LPALISENABLED alIsEnabled; - LPALGETSTRING alGetString; - LPALGETBOOLEANV alGetBooleanv; - LPALGETINTEGERV alGetIntegerv; - LPALGETFLOATV alGetFloatv; - LPALGETDOUBLEV alGetDoublev; - LPALGETBOOLEAN alGetBoolean; - LPALGETINTEGER alGetInteger; - LPALGETFLOAT alGetFloat; - LPALGETDOUBLE alGetDouble; - LPALGETERROR alGetError; - LPALISEXTENSIONPRESENT alIsExtensionPresent; - LPALGETPROCADDRESS alGetProcAddress; - LPALGETENUMVALUE alGetEnumValue; - LPALLISTENERF alListenerf; - LPALLISTENER3F alListener3f; - LPALLISTENERFV alListenerfv; - LPALLISTENERI alListeneri; - LPALLISTENER3I alListener3i; - LPALLISTENERIV alListeneriv; - LPALGETLISTENERF alGetListenerf; - LPALGETLISTENER3F alGetListener3f; - LPALGETLISTENERFV alGetListenerfv; - LPALGETLISTENERI alGetListeneri; - LPALGETLISTENER3I alGetListener3i; - LPALGETLISTENERIV alGetListeneriv; - LPALGENSOURCES alGenSources; - LPALDELETESOURCES alDeleteSources; - LPALISSOURCE alIsSource; - LPALSOURCEF alSourcef; - LPALSOURCE3F alSource3f; - LPALSOURCEFV alSourcefv; - LPALSOURCEI alSourcei; - LPALSOURCE3I alSource3i; - LPALSOURCEIV alSourceiv; - LPALGETSOURCEF alGetSourcef; - LPALGETSOURCE3F alGetSource3f; - LPALGETSOURCEFV alGetSourcefv; - LPALGETSOURCEI alGetSourcei; - LPALGETSOURCE3I alGetSource3i; - LPALGETSOURCEIV alGetSourceiv; - LPALSOURCEPLAYV alSourcePlayv; - LPALSOURCESTOPV alSourceStopv; - LPALSOURCEREWINDV alSourceRewindv; - LPALSOURCEPAUSEV alSourcePausev; - LPALSOURCEPLAY alSourcePlay; - LPALSOURCESTOP alSourceStop; - LPALSOURCEREWIND alSourceRewind; - LPALSOURCEPAUSE alSourcePause; - LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers; - LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers; - LPALGENBUFFERS alGenBuffers; - LPALDELETEBUFFERS alDeleteBuffers; - LPALISBUFFER alIsBuffer; - LPALBUFFERF alBufferf; - LPALBUFFER3F alBuffer3f; - LPALBUFFERFV alBufferfv; - LPALBUFFERI alBufferi; - LPALBUFFER3I alBuffer3i; - LPALBUFFERIV alBufferiv; - LPALGETBUFFERF alGetBufferf; - LPALGETBUFFER3F alGetBuffer3f; - LPALGETBUFFERFV alGetBufferfv; - LPALGETBUFFERI alGetBufferi; - LPALGETBUFFER3I alGetBuffer3i; - LPALGETBUFFERIV alGetBufferiv; - LPALBUFFERDATA alBufferData; - LPALDOPPLERFACTOR alDopplerFactor; - LPALDOPPLERVELOCITY alDopplerVelocity; - LPALSPEEDOFSOUND alSpeedOfSound; - LPALDISTANCEMODEL alDistanceModel; + std::wstring Name; + HMODULE Module{nullptr}; + int ALCVer{0}; + + LPALCCREATECONTEXT alcCreateContext{nullptr}; + LPALCMAKECONTEXTCURRENT alcMakeContextCurrent{nullptr}; + LPALCPROCESSCONTEXT alcProcessContext{nullptr}; + LPALCSUSPENDCONTEXT alcSuspendContext{nullptr}; + LPALCDESTROYCONTEXT alcDestroyContext{nullptr}; + LPALCGETCURRENTCONTEXT alcGetCurrentContext{nullptr}; + LPALCGETCONTEXTSDEVICE alcGetContextsDevice{nullptr}; + LPALCOPENDEVICE alcOpenDevice{nullptr}; + LPALCCLOSEDEVICE alcCloseDevice{nullptr}; + LPALCGETERROR alcGetError{nullptr}; + LPALCISEXTENSIONPRESENT alcIsExtensionPresent{nullptr}; + LPALCGETPROCADDRESS alcGetProcAddress{nullptr}; + LPALCGETENUMVALUE alcGetEnumValue{nullptr}; + LPALCGETSTRING alcGetString{nullptr}; + LPALCGETINTEGERV alcGetIntegerv{nullptr}; + LPALCCAPTUREOPENDEVICE alcCaptureOpenDevice{nullptr}; + LPALCCAPTURECLOSEDEVICE alcCaptureCloseDevice{nullptr}; + LPALCCAPTURESTART alcCaptureStart{nullptr}; + LPALCCAPTURESTOP alcCaptureStop{nullptr}; + LPALCCAPTURESAMPLES alcCaptureSamples{nullptr}; + + PFNALCSETTHREADCONTEXTPROC alcSetThreadContext{nullptr}; + PFNALCGETTHREADCONTEXTPROC alcGetThreadContext{nullptr}; + + LPALENABLE alEnable{nullptr}; + LPALDISABLE alDisable{nullptr}; + LPALISENABLED alIsEnabled{nullptr}; + LPALGETSTRING alGetString{nullptr}; + LPALGETBOOLEANV alGetBooleanv{nullptr}; + LPALGETINTEGERV alGetIntegerv{nullptr}; + LPALGETFLOATV alGetFloatv{nullptr}; + LPALGETDOUBLEV alGetDoublev{nullptr}; + LPALGETBOOLEAN alGetBoolean{nullptr}; + LPALGETINTEGER alGetInteger{nullptr}; + LPALGETFLOAT alGetFloat{nullptr}; + LPALGETDOUBLE alGetDouble{nullptr}; + LPALGETERROR alGetError{nullptr}; + LPALISEXTENSIONPRESENT alIsExtensionPresent{nullptr}; + LPALGETPROCADDRESS alGetProcAddress{nullptr}; + LPALGETENUMVALUE alGetEnumValue{nullptr}; + LPALLISTENERF alListenerf{nullptr}; + LPALLISTENER3F alListener3f{nullptr}; + LPALLISTENERFV alListenerfv{nullptr}; + LPALLISTENERI alListeneri{nullptr}; + LPALLISTENER3I alListener3i{nullptr}; + LPALLISTENERIV alListeneriv{nullptr}; + LPALGETLISTENERF alGetListenerf{nullptr}; + LPALGETLISTENER3F alGetListener3f{nullptr}; + LPALGETLISTENERFV alGetListenerfv{nullptr}; + LPALGETLISTENERI alGetListeneri{nullptr}; + LPALGETLISTENER3I alGetListener3i{nullptr}; + LPALGETLISTENERIV alGetListeneriv{nullptr}; + LPALGENSOURCES alGenSources{nullptr}; + LPALDELETESOURCES alDeleteSources{nullptr}; + LPALISSOURCE alIsSource{nullptr}; + LPALSOURCEF alSourcef{nullptr}; + LPALSOURCE3F alSource3f{nullptr}; + LPALSOURCEFV alSourcefv{nullptr}; + LPALSOURCEI alSourcei{nullptr}; + LPALSOURCE3I alSource3i{nullptr}; + LPALSOURCEIV alSourceiv{nullptr}; + LPALGETSOURCEF alGetSourcef{nullptr}; + LPALGETSOURCE3F alGetSource3f{nullptr}; + LPALGETSOURCEFV alGetSourcefv{nullptr}; + LPALGETSOURCEI alGetSourcei{nullptr}; + LPALGETSOURCE3I alGetSource3i{nullptr}; + LPALGETSOURCEIV alGetSourceiv{nullptr}; + LPALSOURCEPLAYV alSourcePlayv{nullptr}; + LPALSOURCESTOPV alSourceStopv{nullptr}; + LPALSOURCEREWINDV alSourceRewindv{nullptr}; + LPALSOURCEPAUSEV alSourcePausev{nullptr}; + LPALSOURCEPLAY alSourcePlay{nullptr}; + LPALSOURCESTOP alSourceStop{nullptr}; + LPALSOURCEREWIND alSourceRewind{nullptr}; + LPALSOURCEPAUSE alSourcePause{nullptr}; + LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers{nullptr}; + LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers{nullptr}; + LPALGENBUFFERS alGenBuffers{nullptr}; + LPALDELETEBUFFERS alDeleteBuffers{nullptr}; + LPALISBUFFER alIsBuffer{nullptr}; + LPALBUFFERF alBufferf{nullptr}; + LPALBUFFER3F alBuffer3f{nullptr}; + LPALBUFFERFV alBufferfv{nullptr}; + LPALBUFFERI alBufferi{nullptr}; + LPALBUFFER3I alBuffer3i{nullptr}; + LPALBUFFERIV alBufferiv{nullptr}; + LPALGETBUFFERF alGetBufferf{nullptr}; + LPALGETBUFFER3F alGetBuffer3f{nullptr}; + LPALGETBUFFERFV alGetBufferfv{nullptr}; + LPALGETBUFFERI alGetBufferi{nullptr}; + LPALGETBUFFER3I alGetBuffer3i{nullptr}; + LPALGETBUFFERIV alGetBufferiv{nullptr}; + LPALBUFFERDATA alBufferData{nullptr}; + LPALDOPPLERFACTOR alDopplerFactor{nullptr}; + LPALDOPPLERVELOCITY alDopplerVelocity{nullptr}; + LPALSPEEDOFSOUND alSpeedOfSound{nullptr}; + LPALDISTANCEMODEL alDistanceModel{nullptr}; } DriverIface; extern std::vector<DriverIface> DriverList; |