From 9e10f632c7a5d66b0f896753e197970eec3ab7cf Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 24 Nov 2018 16:58:49 -0800 Subject: Replace remaining uses of std::vector with al::vector Which uses a custom allocator that uses our allocation functions. --- Alc/alc.cpp | 4 ++-- Alc/alconfig.cpp | 2 +- Alc/backends/alsa.cpp | 14 +++++++------- Alc/backends/dsound.cpp | 8 ++++---- Alc/backends/oss.cpp | 14 +++++++------- Alc/backends/pulseaudio.cpp | 6 +++--- Alc/backends/wasapi.cpp | 12 ++++++------ Alc/backends/wave.cpp | 2 +- Alc/backends/winmm.cpp | 6 +++--- Alc/helpers.cpp | 18 +++++++++--------- Alc/hrtf.cpp | 28 ++++++++++++++-------------- OpenAL32/Include/alMain.h | 2 +- OpenAL32/alBuffer.cpp | 2 +- OpenAL32/alEffect.cpp | 2 +- OpenAL32/alFilter.cpp | 2 +- 15 files changed, 61 insertions(+), 61 deletions(-) diff --git a/Alc/alc.cpp b/Alc/alc.cpp index 40bf25b4..434e4660 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -3362,7 +3362,7 @@ ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname, alcSetError(dev.get(), ALC_INVALID_VALUE); else if(!dev || dev->Type == Capture) { - std::vector ivals(size); + al::vector ivals(size); size = GetIntegerv(dev.get(), pname, size, ivals.data()); std::copy(ivals.begin(), ivals.begin()+size, values); } @@ -3482,7 +3482,7 @@ ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname, break; default: - std::vector ivals(size); + al::vector ivals(size); size = GetIntegerv(dev.get(), pname, size, ivals.data()); std::copy(ivals.begin(), ivals.begin()+size, values); break; diff --git a/Alc/alconfig.cpp b/Alc/alconfig.cpp index 73ea0458..a6304ce7 100644 --- a/Alc/alconfig.cpp +++ b/Alc/alconfig.cpp @@ -59,7 +59,7 @@ struct ConfigEntry { : key{std::forward(key_)}, value{std::forward(val_)} { } }; -std::vector ConfOpts; +al::vector ConfOpts; std::string &lstrip(std::string &line) diff --git a/Alc/backends/alsa.cpp b/Alc/backends/alsa.cpp index 35c1f834..1a048fc7 100644 --- a/Alc/backends/alsa.cpp +++ b/Alc/backends/alsa.cpp @@ -253,8 +253,8 @@ struct DevMap { { } }; -std::vector PlaybackDevices; -std::vector CaptureDevices; +al::vector PlaybackDevices; +al::vector CaptureDevices; const char *prefix_name(snd_pcm_stream_t stream) @@ -263,9 +263,9 @@ const char *prefix_name(snd_pcm_stream_t stream) return (stream==SND_PCM_STREAM_PLAYBACK) ? "device-prefix" : "capture-prefix"; } -std::vector probe_devices(snd_pcm_stream_t stream) +al::vector probe_devices(snd_pcm_stream_t stream) { - std::vector devlist; + al::vector devlist; snd_ctl_card_info_t *info; snd_ctl_card_info_malloc(&info); @@ -425,7 +425,7 @@ int verify_state(snd_pcm_t *handle) struct ALCplaybackAlsa final : public ALCbackend { snd_pcm_t *pcmHandle{nullptr}; - std::vector buffer; + al::vector buffer; std::atomic killNow{AL_TRUE}; std::thread thread; @@ -926,7 +926,7 @@ ClockLatency ALCplaybackAlsa_getClockLatency(ALCplaybackAlsa *self) struct ALCcaptureAlsa final : public ALCbackend { snd_pcm_t *pcmHandle{nullptr}; - std::vector buffer; + al::vector buffer; bool doCapture{false}; ll_ringbuffer_t *ring{nullptr}; @@ -1129,7 +1129,7 @@ void ALCcaptureAlsa_stop(ALCcaptureAlsa *self) { /* The ring buffer implicitly captures when checking availability. * Direct access needs to explicitly capture it into temp storage. */ - std::vector temp(snd_pcm_frames_to_bytes(self->pcmHandle, avail)); + al::vector temp(snd_pcm_frames_to_bytes(self->pcmHandle, avail)); ALCcaptureAlsa_captureSamples(self, temp.data(), avail); self->buffer = std::move(temp); } diff --git a/Alc/backends/dsound.cpp b/Alc/backends/dsound.cpp index 085dab90..4f1186ee 100644 --- a/Alc/backends/dsound.cpp +++ b/Alc/backends/dsound.cpp @@ -142,10 +142,10 @@ struct DevMap { { } }; -std::vector PlaybackDevices; -std::vector CaptureDevices; +al::vector PlaybackDevices; +al::vector CaptureDevices; -bool checkName(const std::vector &list, const std::string &name) +bool checkName(const al::vector &list, const std::string &name) { return std::find_if(list.cbegin(), list.cend(), [&name](const DevMap &entry) -> bool @@ -158,7 +158,7 @@ BOOL CALLBACK DSoundEnumDevices(GUID *guid, const WCHAR *desc, const WCHAR* UNUS if(!guid) return TRUE; - auto& devices = *reinterpret_cast*>(data); + auto& devices = *reinterpret_cast*>(data); const std::string basename{DEVNAME_HEAD + wstr_to_utf8(desc)}; int count{1}; diff --git a/Alc/backends/oss.cpp b/Alc/backends/oss.cpp index 3985cd27..7b8d234a 100644 --- a/Alc/backends/oss.cpp +++ b/Alc/backends/oss.cpp @@ -91,7 +91,7 @@ struct DevMap { { } }; -bool checkName(const std::vector &list, const std::string &name) +bool checkName(const al::vector &list, const std::string &name) { return std::find_if(list.cbegin(), list.cend(), [&name](const DevMap &entry) -> bool @@ -99,22 +99,22 @@ bool checkName(const std::vector &list, const std::string &name) ) != list.cend(); } -std::vector PlaybackDevices; -std::vector CaptureDevices; +al::vector PlaybackDevices; +al::vector CaptureDevices; #ifdef ALC_OSS_COMPAT #define DSP_CAP_OUTPUT 0x00020000 #define DSP_CAP_INPUT 0x00010000 -void ALCossListPopulate(std::vector *devlist, int type) +void ALCossListPopulate(al::vector *devlist, int type) { devlist->emplace_back(DefaultName, (type==DSP_CAP_INPUT) ? DefaultCapture : DefaultPlayback); } #else -void ALCossListAppend(std::vector *list, const char *handle, size_t hlen, const char *path, size_t plen) +void ALCossListAppend(al::vector *list, const char *handle, size_t hlen, const char *path, size_t plen) { #ifdef ALC_OSS_DEVNODE_TRUC for(size_t i{0};i < plen;i++) @@ -160,7 +160,7 @@ void ALCossListAppend(std::vector *list, const char *handle, size_t hlen TRACE("Got device \"%s\", \"%s\"\n", entry.name.c_str(), entry.device_name.c_str()); } -void ALCossListPopulate(std::vector *devlist, int type_flag) +void ALCossListPopulate(al::vector *devlist, int type_flag) { int fd{open("/dev/mixer", O_RDONLY)}; if(fd < 0) @@ -243,7 +243,7 @@ int log2i(ALCuint x) struct ALCplaybackOSS final : public ALCbackend { int fd{-1}; - std::vector mix_data; + al::vector mix_data; std::atomic killNow{AL_TRUE}; std::thread thread; diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp index 9563cdd4..c64c3ed7 100644 --- a/Alc/backends/pulseaudio.cpp +++ b/Alc/backends/pulseaudio.cpp @@ -511,7 +511,7 @@ struct DevMap { { } }; -bool checkName(const std::vector &list, const std::string &name) +bool checkName(const al::vector &list, const std::string &name) { return std::find_if(list.cbegin(), list.cend(), [&name](const DevMap &entry) -> bool @@ -519,8 +519,8 @@ bool checkName(const std::vector &list, const std::string &name) ) != list.cend(); } -std::vector PlaybackDevices; -std::vector CaptureDevices; +al::vector PlaybackDevices; +al::vector CaptureDevices; struct PulsePlayback final : public ALCbackend { diff --git a/Alc/backends/wasapi.cpp b/Alc/backends/wasapi.cpp index 52f324f7..3d6c3e8c 100644 --- a/Alc/backends/wasapi.cpp +++ b/Alc/backends/wasapi.cpp @@ -123,7 +123,7 @@ struct DevMap { { } }; -bool checkName(const std::vector &list, const std::string &name) +bool checkName(const al::vector &list, const std::string &name) { return std::find_if(list.cbegin(), list.cend(), [&name](const DevMap &entry) -> bool @@ -131,8 +131,8 @@ bool checkName(const std::vector &list, const std::string &name) ) != list.cend(); } -std::vector PlaybackDevices; -std::vector CaptureDevices; +al::vector PlaybackDevices; +al::vector CaptureDevices; HANDLE ThreadHdl; @@ -251,7 +251,7 @@ void get_device_formfactor(IMMDevice *device, EndpointFormFactor *formfactor) } -void add_device(IMMDevice *device, const WCHAR *devid, std::vector &list) +void add_device(IMMDevice *device, const WCHAR *devid, al::vector &list) { std::string basename, guidstr; std::tie(basename, guidstr) = get_device_name_and_guid(device); @@ -285,7 +285,7 @@ WCHAR *get_device_id(IMMDevice *device) return devid; } -HRESULT probe_devices(IMMDeviceEnumerator *devenum, EDataFlow flowdir, std::vector &list) +HRESULT probe_devices(IMMDeviceEnumerator *devenum, EDataFlow flowdir, al::vector &list) { IMMDeviceCollection *coll; HRESULT hr = devenum->EnumAudioEndpoints(flowdir, DEVICE_STATE_ACTIVE, &coll); @@ -1248,7 +1248,7 @@ FORCE_ALIGN int ALCwasapiCapture_recordProc(ALCwasapiCapture *self) althrd_setname(RECORD_THREAD_NAME); - std::vector samples; + al::vector samples; while(!self->mKillNow.load(std::memory_order_relaxed)) { UINT32 avail; diff --git a/Alc/backends/wave.cpp b/Alc/backends/wave.cpp index d1356338..d9219336 100644 --- a/Alc/backends/wave.cpp +++ b/Alc/backends/wave.cpp @@ -82,7 +82,7 @@ struct ALCwaveBackend final : public ALCbackend { FILE *mFile; long mDataStart; - std::vector mBuffer; + al::vector mBuffer; ATOMIC(ALenum) killNow; std::thread thread; diff --git a/Alc/backends/winmm.cpp b/Alc/backends/winmm.cpp index f17b5d1f..f1aee5b3 100644 --- a/Alc/backends/winmm.cpp +++ b/Alc/backends/winmm.cpp @@ -51,10 +51,10 @@ namespace { #define DEVNAME_HEAD "OpenAL Soft on " -std::vector PlaybackDevices; -std::vector CaptureDevices; +al::vector PlaybackDevices; +al::vector CaptureDevices; -bool checkName(const std::vector &list, const std::string &name) +bool checkName(const al::vector &list, const std::string &name) { return std::find(list.cbegin(), list.cend(), name) != list.cend(); } void ProbePlaybackDevices(void) diff --git a/Alc/helpers.cpp b/Alc/helpers.cpp index 658c7d09..d06a4807 100644 --- a/Alc/helpers.cpp +++ b/Alc/helpers.cpp @@ -315,7 +315,7 @@ PathNamePair GetProcBinary() { PathNamePair ret; - std::vector fullpath(256); + al::vector fullpath(256); DWORD len; while((len=GetModuleFileNameW(nullptr, fullpath.data(), fullpath.size())) == fullpath.size()) fullpath.resize(fullpath.size() << 1); @@ -379,7 +379,7 @@ void al_print(const char *type, const char *func, const char *fmt, ...) static inline int is_slash(int c) { return (c == '\\' || c == '/'); } -static void DirectorySearch(const char *path, const char *ext, std::vector *const results) +static void DirectorySearch(const char *path, const char *ext, al::vector *const results) { std::string pathstr{path}; pathstr += "\\*"; @@ -406,13 +406,13 @@ static void DirectorySearch(const char *path, const char *ext, std::vector SearchDataFiles(const char *ext, const char *subdir) +al::vector SearchDataFiles(const char *ext, const char *subdir) { static std::mutex search_lock; std::lock_guard _{search_lock}; /* If the path is absolute, use it directly. */ - std::vector results; + al::vector results; if(isalpha(subdir[0]) && subdir[1] == ':' && is_slash(subdir[2])) { std::string path{subdir}; @@ -481,7 +481,7 @@ void SetRTPriority(void) PathNamePair GetProcBinary() { PathNamePair ret; - std::vector pathname; + al::vector pathname; #ifdef __FreeBSD__ size_t pathlen; @@ -598,7 +598,7 @@ void al_print(const char *type, const char *func, const char *fmt, ...) } -static void DirectorySearch(const char *path, const char *ext, std::vector *const results) +static void DirectorySearch(const char *path, const char *ext, al::vector *const results) { TRACE("Searching %s for *%s\n", path, ext); DIR *dir{opendir(path)}; @@ -632,12 +632,12 @@ static void DirectorySearch(const char *path, const char *ext, std::vector SearchDataFiles(const char *ext, const char *subdir) +al::vector SearchDataFiles(const char *ext, const char *subdir) { static std::mutex search_lock; std::lock_guard _{search_lock}; - std::vector results; + al::vector results; if(subdir[0] == '/') { DirectorySearch(subdir, ext, &results); @@ -650,7 +650,7 @@ std::vector SearchDataFiles(const char *ext, const char *subdir) DirectorySearch(str, ext, &results); else { - std::vector cwdbuf(256); + al::vector cwdbuf(256); while(!getcwd(cwdbuf.data(), cwdbuf.size())) { if(errno != ERANGE) diff --git a/Alc/hrtf.cpp b/Alc/hrtf.cpp index 034d5a49..19919717 100644 --- a/Alc/hrtf.cpp +++ b/Alc/hrtf.cpp @@ -281,7 +281,7 @@ void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei N #define NUM_BANDS 2 ALsizei min_delay{HRTF_HISTORY_LENGTH}; ALsizei max_delay{0}; - std::vector idx(AmbiCount); + al::vector idx(AmbiCount); for(ALsizei c{0};c < AmbiCount;c++) { ALuint evidx, azidx; @@ -305,7 +305,7 @@ void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei N max_delay = maxi(max_delay, maxi(Hrtf->delays[idx[c]][0], Hrtf->delays[idx[c]][1])); } - std::vector,HRIR_LENGTH>> tmpres(NumChannels); + al::vector,HRIR_LENGTH>> tmpres(NumChannels); ALfloat temps[3][HRIR_LENGTH]{}; BandSplitter splitter; @@ -549,7 +549,7 @@ struct Hrtf *LoadHrtf00(std::istream &data, const char *filename) if(failed) return nullptr; - std::vector evOffset(evCount); + al::vector evOffset(evCount); for(auto &val : evOffset) val = GetLE_ALushort(data); if(!data || data.eof()) @@ -575,7 +575,7 @@ struct Hrtf *LoadHrtf00(std::istream &data, const char *filename) if(failed) return nullptr; - std::vector azCount(evCount); + al::vector azCount(evCount); for(ALsizei i{1};i < evCount;i++) { azCount[i-1] = evOffset[i] - evOffset[i-1]; @@ -596,8 +596,8 @@ struct Hrtf *LoadHrtf00(std::istream &data, const char *filename) if(failed) return nullptr; - std::vector> coeffs(irSize*irCount); - std::vector> delays(irCount); + al::vector> coeffs(irSize*irCount); + al::vector> delays(irCount); for(auto &val : coeffs) val[0] = GetLE_ALshort(data) / 32768.0f; for(auto &val : delays) @@ -666,7 +666,7 @@ struct Hrtf *LoadHrtf01(std::istream &data, const char *filename) if(failed) return nullptr; - std::vector azCount(evCount); + al::vector azCount(evCount); data.read(reinterpret_cast(azCount.data()), evCount); if(!data || data.eof() || data.gcount() < evCount) { @@ -685,7 +685,7 @@ struct Hrtf *LoadHrtf01(std::istream &data, const char *filename) if(failed) return nullptr; - std::vector evOffset(evCount); + al::vector evOffset(evCount); evOffset[0] = 0; ALushort irCount{azCount[0]}; for(ALsizei i{1};i < evCount;i++) @@ -694,8 +694,8 @@ struct Hrtf *LoadHrtf01(std::istream &data, const char *filename) irCount += azCount[i]; } - std::vector> coeffs(irSize*irCount); - std::vector> delays(irCount); + al::vector> coeffs(irSize*irCount); + al::vector> delays(irCount); for(auto &val : coeffs) val[0] = GetLE_ALshort(data) / 32768.0f; for(auto &val : delays) @@ -785,7 +785,7 @@ struct Hrtf *LoadHrtf02(std::istream &data, const char *filename) ALushort distance{}; ALubyte evCount{}; - std::vector azCount; + al::vector azCount; for(ALsizei i{0};i < fdCount;i++) { distance = GetLE_ALushort(data); @@ -832,7 +832,7 @@ struct Hrtf *LoadHrtf02(std::istream &data, const char *filename) return nullptr; } - std::vector evOffset(evCount); + al::vector evOffset(evCount); evOffset[0] = 0; ALushort irCount{azCount[0]}; for(ALsizei i{1};i < evCount;++i) @@ -841,8 +841,8 @@ struct Hrtf *LoadHrtf02(std::istream &data, const char *filename) irCount += azCount[i]; } - std::vector> coeffs(irSize*irCount); - std::vector> delays(irCount); + al::vector> coeffs(irSize*irCount); + al::vector> delays(irCount); if(channelType == CHANTYPE_LEFTONLY) { if(sampleType == SAMPLETYPE_S16) diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 1a2f7d8d..21aa1e89 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -853,6 +853,6 @@ void StartEventThrd(ALCcontext *ctx); void StopEventThrd(ALCcontext *ctx); -std::vector SearchDataFiles(const char *match, const char *subdir); +al::vector SearchDataFiles(const char *match, const char *subdir); #endif diff --git a/OpenAL32/alBuffer.cpp b/OpenAL32/alBuffer.cpp index 0580b33a..5c40a27e 100644 --- a/OpenAL32/alBuffer.cpp +++ b/OpenAL32/alBuffer.cpp @@ -439,7 +439,7 @@ AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers) /* Store the allocated buffer IDs in a separate local list, to avoid * modifying the user storage in case of failure. */ - std::vector ids; + al::vector ids; ids.reserve(n); do { ALbuffer *buffer = AllocBuffer(context.get()); diff --git a/OpenAL32/alEffect.cpp b/OpenAL32/alEffect.cpp index e25e2007..2bc60e24 100644 --- a/OpenAL32/alEffect.cpp +++ b/OpenAL32/alEffect.cpp @@ -312,7 +312,7 @@ AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) /* Store the allocated buffer IDs in a separate local list, to avoid * modifying the user storage in case of failure. */ - std::vector ids; + al::vector ids; ids.reserve(n); do { ALeffect *effect = AllocEffect(context.get()); diff --git a/OpenAL32/alFilter.cpp b/OpenAL32/alFilter.cpp index bda03fae..5b15e7e0 100644 --- a/OpenAL32/alFilter.cpp +++ b/OpenAL32/alFilter.cpp @@ -373,7 +373,7 @@ AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters) /* Store the allocated buffer IDs in a separate local list, to avoid * modifying the user storage in case of failure. */ - std::vector ids; + al::vector ids; ids.reserve(n); do { ALfilter *filter = AllocFilter(context.get()); -- cgit v1.2.3