diff options
-rw-r--r-- | alc/helpers.cpp | 6 | ||||
-rw-r--r-- | alc/hrtf.cpp | 186 | ||||
-rw-r--r-- | alc/hrtf.h | 6 | ||||
-rw-r--r-- | alc/mixer/hrtfbase.h | 2 | ||||
-rw-r--r-- | alc/mixvoice.cpp | 12 | ||||
-rw-r--r-- | alc/panning.cpp | 2 |
6 files changed, 105 insertions, 109 deletions
diff --git a/alc/helpers.cpp b/alc/helpers.cpp index 84787637..46be5a3b 100644 --- a/alc/helpers.cpp +++ b/alc/helpers.cpp @@ -614,7 +614,7 @@ const PathNamePair &GetProcBinary() return ret; } - pathname.resize(len); + pathname.resize(static_cast<size_t>(len)); } while(!pathname.empty() && pathname.back() == 0) pathname.pop_back(); @@ -651,8 +651,8 @@ static void DirectorySearch(const char *path, const char *ext, al::vector<std::s DIR *dir{opendir(path)}; if(dir != nullptr) { - const size_t extlen = strlen(ext); - size_t base = results->size(); + auto base = results->cend() - results->cbegin(); + const size_t extlen{strlen(ext)}; struct dirent *dirent; while((dirent=readdir(dir)) != nullptr) diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp index 04818a4f..bd6ecb3a 100644 --- a/alc/hrtf.cpp +++ b/alc/hrtf.cpp @@ -257,7 +257,7 @@ void GetHrtfCoeffs(const HrtfEntry *Hrtf, ALfloat elevation, ALfloat azimuth, AL Hrtf->delays[idx[2]][1]*blend[2] + Hrtf->delays[idx[3]][1]*blend[3] ); - const ALsizei irSize{Hrtf->irSize}; + const ALuint irSize{Hrtf->irSize}; ASSUME(irSize >= MIN_IR_SIZE); /* Calculate the sample offsets for the HRIR indices. */ @@ -304,27 +304,26 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALuin ASSUME(AmbiCount > 0); auto &field = Hrtf->field[0]; - ALsizei min_delay{HRTF_HISTORY_LENGTH}; - ALsizei max_delay{0}; - auto idx = al::vector<ALsizei>(AmbiCount); - auto calc_idxs = [Hrtf,&field,&max_delay,&min_delay](const AngularPoint &pt) noexcept -> ALsizei + ALuint min_delay{HRTF_HISTORY_LENGTH}; + ALuint max_delay{0}; + auto idx = al::vector<ALuint>(AmbiCount); + auto calc_idxs = [Hrtf,&field,&max_delay,&min_delay](const AngularPoint &pt) noexcept -> ALuint { /* Calculate elevation index. */ - const auto evidx = clampi( - static_cast<ALsizei>((90.0f+pt.Elev)*(field.evCount-1)/180.0f + 0.5f), + const auto evidx = clampi(float2int((90.0f+pt.Elev)*(field.evCount-1)/180.0f + 0.5f), 0, field.evCount-1); - const ALsizei azcount{Hrtf->elev[evidx].azCount}; - const ALsizei iroffset{Hrtf->elev[evidx].irOffset}; + const ALuint azcount{Hrtf->elev[evidx].azCount}; + const ALuint iroffset{Hrtf->elev[evidx].irOffset}; /* Calculate azimuth index for this elevation. */ - const auto azidx = static_cast<ALsizei>((360.0f+pt.Azim)*azcount/360.0f + 0.5f) % azcount; + const auto azidx = static_cast<ALuint>((360.0f+pt.Azim)*azcount/360.0f + 0.5f) % azcount; /* Calculate the index for the impulse response. */ - ALsizei idx{iroffset + azidx}; + ALuint idx{iroffset + azidx}; - min_delay = mini(min_delay, mini(Hrtf->delays[idx][0], Hrtf->delays[idx][1])); - max_delay = maxi(max_delay, maxi(Hrtf->delays[idx][0], Hrtf->delays[idx][1])); + min_delay = minu(min_delay, minu(Hrtf->delays[idx][0], Hrtf->delays[idx][1])); + max_delay = maxu(max_delay, maxu(Hrtf->delays[idx][0], Hrtf->delays[idx][1])); return idx; }; @@ -342,8 +341,8 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALuin for(size_t c{0u};c < AmbiCount;++c) { const ALfloat (*fir)[2]{&Hrtf->coeffs[idx[c] * Hrtf->irSize]}; - const ALsizei ldelay{Hrtf->delays[idx[c]][0] - min_delay + base_delay}; - const ALsizei rdelay{Hrtf->delays[idx[c]][1] - min_delay + base_delay}; + const ALuint ldelay{Hrtf->delays[idx[c]][0] - min_delay + base_delay}; + const ALuint rdelay{Hrtf->delays[idx[c]][1] - min_delay + base_delay}; if(!DualBand) { @@ -352,9 +351,9 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALuin { const ALdouble mult{ALdouble{AmbiOrderHFGain[OrderFromChan[i]]} * AmbiMatrix[c][i]}; - const ALsizei numirs{mini(Hrtf->irSize, HRIR_LENGTH-maxi(ldelay, rdelay))}; - ALsizei lidx{ldelay}, ridx{rdelay}; - for(ALsizei j{0};j < numirs;++j) + const ALuint numirs{minu(Hrtf->irSize, HRIR_LENGTH-maxu(ldelay, rdelay))}; + ALuint lidx{ldelay}, ridx{rdelay}; + for(ALuint j{0};j < numirs;++j) { tmpres[i][lidx++][0] += fir[j][0] * mult; tmpres[i][ridx++][1] += fir[j][1] * mult; @@ -394,8 +393,8 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALuin { const ALdouble mult{AmbiMatrix[c][i]}; const ALdouble hfgain{AmbiOrderHFGain[OrderFromChan[i]]}; - ALsizei j{HRIR_LENGTH*3 - ldelay}; - for(ALsizei lidx{0};lidx < HRIR_LENGTH;++lidx,++j) + ALuint j{HRIR_LENGTH*3 - ldelay}; + for(ALuint lidx{0};lidx < HRIR_LENGTH;++lidx,++j) tmpres[i][lidx][0] += (tmpfilt[0][j]*hfgain + tmpfilt[1][j]) * mult; } @@ -415,8 +414,8 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALuin { const ALdouble mult{AmbiMatrix[c][i]}; const ALdouble hfgain{AmbiOrderHFGain[OrderFromChan[i]]}; - ALsizei j{HRIR_LENGTH*3 - rdelay}; - for(ALsizei ridx{0};ridx < HRIR_LENGTH;++ridx,++j) + ALuint j{HRIR_LENGTH*3 - rdelay}; + for(ALuint ridx{0};ridx < HRIR_LENGTH;++ridx,++j) tmpres[i][ridx][1] += (tmpfilt[0][j]*hfgain + tmpfilt[1][j]) * mult; } } @@ -432,33 +431,33 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALuin } tmpres.clear(); - ALsizei max_length{HRIR_LENGTH}; + ALuint max_length{HRIR_LENGTH}; /* Increase the IR size by double the base delay with dual-band processing * to account for the head and tail from the HF response scale. */ - const ALsizei irsize{mini(Hrtf->irSize + base_delay*2, max_length)}; - max_length = mini(max_delay-min_delay + irsize, max_length); + const ALuint irsize{minu(Hrtf->irSize + base_delay*2, max_length)}; + max_length = minu(max_delay-min_delay + irsize, max_length); /* Round up to the next IR size multiple. */ max_length += MOD_IR_SIZE-1; max_length -= max_length%MOD_IR_SIZE; - TRACE("Skipped delay: %d, max delay: %d, new FIR length: %d\n", - min_delay, max_delay-min_delay, max_length); + TRACE("Skipped delay: %u, max delay: %u, new FIR length: %u\n", min_delay, max_delay-min_delay, + max_length); state->IrSize = max_length; } namespace { -std::unique_ptr<HrtfEntry> CreateHrtfStore(ALuint rate, ALsizei irSize, const ALsizei fdCount, +std::unique_ptr<HrtfEntry> CreateHrtfStore(ALuint rate, ALushort irSize, const ALuint fdCount, const ALubyte *evCount, const ALfloat *distance, const ALushort *azCount, - const ALushort *irOffset, ALsizei irCount, const ALfloat (*coeffs)[2], + const ALushort *irOffset, ALushort irCount, const ALfloat (*coeffs)[2], const ALubyte (*delays)[2], const char *filename) { std::unique_ptr<HrtfEntry> Hrtf; - ALsizei evTotal{std::accumulate(evCount, evCount+fdCount, 0)}; + ALuint evTotal{std::accumulate(evCount, evCount+fdCount, 0u)}; size_t total{sizeof(HrtfEntry)}; total = RoundUp(total, alignof(HrtfEntry::Field)); /* Align for field infos */ total += sizeof(HrtfEntry::Field)*fdCount; @@ -500,22 +499,22 @@ std::unique_ptr<HrtfEntry> CreateHrtfStore(ALuint rate, ALsizei irSize, const AL assert(offset == total); /* Copy input data to storage. */ - for(ALsizei i{0};i < fdCount;i++) + for(ALuint i{0};i < fdCount;i++) { field_[i].distance = distance[i]; field_[i].evCount = evCount[i]; } - for(ALsizei i{0};i < evTotal;i++) + for(ALuint i{0};i < evTotal;i++) { elev_[i].azCount = azCount[i]; elev_[i].irOffset = irOffset[i]; } - for(ALsizei i{0};i < irSize*irCount;i++) + for(ALuint i{0};i < irSize*irCount;i++) { coeffs_[i][0] = coeffs[i][0]; coeffs_[i][1] = coeffs[i][1]; } - for(ALsizei i{0};i < irCount;i++) + for(ALuint i{0};i < irCount;i++) { delays_[i][0] = delays[i][0]; delays_[i][1] = delays[i][1]; @@ -564,7 +563,7 @@ ALuint GetLE_ALuint(std::istream &data) ret |= data.get() << 8; ret |= data.get() << 16; ret |= data.get() << 24; - return ret; + return static_cast<ALuint>(ret); } std::unique_ptr<HrtfEntry> LoadHrtf00(std::istream &data, const char *filename) @@ -603,12 +602,11 @@ std::unique_ptr<HrtfEntry> LoadHrtf00(std::istream &data, const char *filename) ERR("Failed reading %s\n", filename); return nullptr; } - for(ALsizei i{1};i < evCount;i++) + for(size_t i{1};i < evCount;i++) { if(evOffset[i] <= evOffset[i-1]) { - ERR("Invalid evOffset: evOffset[%d]=%d (last=%d)\n", - i, evOffset[i], evOffset[i-1]); + ERR("Invalid evOffset: evOffset[%zu]=%d (last=%d)\n", i, evOffset[i], evOffset[i-1]); failed = AL_TRUE; } } @@ -622,12 +620,12 @@ std::unique_ptr<HrtfEntry> LoadHrtf00(std::istream &data, const char *filename) return nullptr; al::vector<ALushort> azCount(evCount); - for(ALsizei i{1};i < evCount;i++) + for(size_t i{1};i < evCount;i++) { azCount[i-1] = evOffset[i] - evOffset[i-1]; if(azCount[i-1] < MIN_AZ_COUNT || azCount[i-1] > MAX_AZ_COUNT) { - ERR("Unsupported azimuth count: azCount[%d]=%d (%d to %d)\n", + ERR("Unsupported azimuth count: azCount[%zd]=%d (%d to %d)\n", i-1, azCount[i-1], MIN_AZ_COUNT, MAX_AZ_COUNT); failed = AL_TRUE; } @@ -653,11 +651,11 @@ std::unique_ptr<HrtfEntry> LoadHrtf00(std::istream &data, const char *filename) ERR("Failed reading %s\n", filename); return nullptr; } - for(ALsizei i{0};i < irCount;i++) + for(size_t i{0};i < irCount;i++) { if(delays[i][0] > MAX_HRIR_DELAY) { - ERR("Invalid delays[%d]: %d (%d)\n", i, delays[i][0], MAX_HRIR_DELAY); + ERR("Invalid delays[%zd]: %d (%d)\n", i, delays[i][0], MAX_HRIR_DELAY); failed = AL_TRUE; } } @@ -665,16 +663,16 @@ std::unique_ptr<HrtfEntry> LoadHrtf00(std::istream &data, const char *filename) return nullptr; /* Mirror the left ear responses to the right ear. */ - for(ALsizei i{0};i < evCount;i++) + for(size_t i{0};i < evCount;i++) { const ALushort evoffset{evOffset[i]}; const ALushort azcount{azCount[i]}; - for(ALsizei j{0};j < azcount;j++) + for(size_t j{0};j < azcount;j++) { - const ALsizei lidx{evoffset + j}; - const ALsizei ridx{evoffset + ((azcount-j) % azcount)}; + const size_t lidx{evoffset + j}; + const size_t ridx{evoffset + ((azcount-j) % azcount)}; - for(ALsizei k{0};k < irSize;k++) + for(size_t k{0};k < irSize;k++) coeffs[ridx*irSize + k][1] = coeffs[lidx*irSize + k][0]; delays[ridx][1] = delays[lidx][0]; } @@ -720,22 +718,22 @@ std::unique_ptr<HrtfEntry> LoadHrtf01(std::istream &data, const char *filename) ERR("Failed reading %s\n", filename); return nullptr; } - for(ALsizei i{0};i < evCount;++i) + for(size_t i{0};i < evCount;++i) { if(azCount[i] < MIN_AZ_COUNT || azCount[i] > MAX_AZ_COUNT) { - ERR("Unsupported azimuth count: azCount[%d]=%d (%d to %d)\n", - i, azCount[i], MIN_AZ_COUNT, MAX_AZ_COUNT); + ERR("Unsupported azimuth count: azCount[%zd]=%d (%d to %d)\n", i, azCount[i], + MIN_AZ_COUNT, MAX_AZ_COUNT); failed = AL_TRUE; } } if(failed) return nullptr; - al::vector<ALushort> evOffset(evCount); + auto evOffset = al::vector<ALushort>(evCount); evOffset[0] = 0; ALushort irCount{azCount[0]}; - for(ALsizei i{1};i < evCount;i++) + for(size_t i{1};i < evCount;i++) { evOffset[i] = evOffset[i-1] + azCount[i-1]; irCount += azCount[i]; @@ -752,11 +750,11 @@ std::unique_ptr<HrtfEntry> LoadHrtf01(std::istream &data, const char *filename) ERR("Failed reading %s\n", filename); return nullptr; } - for(ALsizei i{0};i < irCount;i++) + for(size_t i{0};i < irCount;i++) { if(delays[i][0] > MAX_HRIR_DELAY) { - ERR("Invalid delays[%d]: %d (%d)\n", i, delays[i][0], MAX_HRIR_DELAY); + ERR("Invalid delays[%zd]: %d (%d)\n", i, delays[i][0], MAX_HRIR_DELAY); failed = AL_TRUE; } } @@ -764,16 +762,16 @@ std::unique_ptr<HrtfEntry> LoadHrtf01(std::istream &data, const char *filename) return nullptr; /* Mirror the left ear responses to the right ear. */ - for(ALsizei i{0};i < evCount;i++) + for(size_t i{0};i < evCount;i++) { const ALushort evoffset{evOffset[i]}; const ALushort azcount{azCount[i]}; - for(ALsizei j{0};j < azcount;j++) + for(size_t j{0};j < azcount;j++) { - const ALsizei lidx{evoffset + j}; - const ALsizei ridx{evoffset + ((azcount-j) % azcount)}; + const size_t lidx{evoffset + j}; + const size_t ridx{evoffset + ((azcount-j) % azcount)}; - for(ALsizei k{0};k < irSize;k++) + for(size_t k{0};k < irSize;k++) coeffs[ridx*irSize + k][1] = coeffs[lidx*irSize + k][0]; delays[ridx][1] = delays[lidx][0]; } @@ -831,10 +829,10 @@ std::unique_ptr<HrtfEntry> LoadHrtf02(std::istream &data, const char *filename) if(failed) return nullptr; - al::vector<ALfloat> distance(fdCount); - al::vector<ALubyte> evCount(fdCount); - al::vector<ALushort> azCount; - for(ALsizei f{0};f < fdCount;f++) + auto distance = al::vector<ALfloat>(fdCount); + auto evCount = al::vector<ALubyte>(fdCount); + auto azCount = al::vector<ALushort>{}; + for(size_t f{0};f < fdCount;f++) { distance[f] = GetLE_ALushort(data) / 1000.0f; evCount[f] = GetLE_ALubyte(data); @@ -846,28 +844,28 @@ std::unique_ptr<HrtfEntry> LoadHrtf02(std::istream &data, const char *filename) if(distance[f] < MIN_FD_DISTANCE || distance[f] > MAX_FD_DISTANCE) { - ERR("Unsupported field distance[%d]=%f (%f to %f meters)\n", f, - distance[f], MIN_FD_DISTANCE, MAX_FD_DISTANCE); + ERR("Unsupported field distance[%zu]=%f (%f to %f meters)\n", f, distance[f], + MIN_FD_DISTANCE, MAX_FD_DISTANCE); failed = AL_TRUE; } if(f > 0 && distance[f] <= distance[f-1]) { - ERR("Field distance[%d] is not after previous (%f > %f)\n", f, distance[f], + ERR("Field distance[%zu] is not after previous (%f > %f)\n", f, distance[f], distance[f-1]); failed = AL_TRUE; } if(evCount[f] < MIN_EV_COUNT || evCount[f] > MAX_EV_COUNT) { - ERR("Unsupported elevation count: evCount[%d]=%d (%d to %d)\n", f, - evCount[f], MIN_EV_COUNT, MAX_EV_COUNT); + ERR("Unsupported elevation count: evCount[%zu]=%d (%d to %d)\n", f, evCount[f], + MIN_EV_COUNT, MAX_EV_COUNT); failed = AL_TRUE; } if(failed) return nullptr; - size_t ebase{azCount.size()}; + const size_t ebase{azCount.size()}; azCount.resize(ebase + evCount[f]); - std::generate(azCount.begin()+ebase, azCount.end(), + std::generate(azCount.begin()+static_cast<ptrdiff_t>(ebase), azCount.end(), std::bind(GetLE_ALubyte, std::ref(data))); if(!data || data.eof()) { @@ -875,11 +873,11 @@ std::unique_ptr<HrtfEntry> LoadHrtf02(std::istream &data, const char *filename) return nullptr; } - for(ALsizei e{0};e < evCount[f];e++) + for(size_t e{0};e < evCount[f];e++) { if(azCount[ebase+e] < MIN_AZ_COUNT || azCount[ebase+e] > MAX_AZ_COUNT) { - ERR("Unsupported azimuth count: azCount[%d][%d]=%d (%d to %d)\n", f, e, + ERR("Unsupported azimuth count: azCount[%zu][%zu]=%d (%d to %d)\n", f, e, azCount[ebase+e], MIN_AZ_COUNT, MAX_AZ_COUNT); failed = AL_TRUE; } @@ -888,13 +886,13 @@ std::unique_ptr<HrtfEntry> LoadHrtf02(std::istream &data, const char *filename) return nullptr; } - al::vector<ALushort> evOffset(azCount.size()); + auto evOffset = al::vector<ALushort>(azCount.size()); evOffset[0] = 0; std::partial_sum(azCount.cbegin(), azCount.cend()-1, evOffset.begin()+1); - const ALsizei irTotal{evOffset.back() + azCount.back()}; + const auto irTotal = static_cast<ALushort>(evOffset.back() + azCount.back()); - al::vector<std::array<ALfloat,2>> coeffs(irSize*irTotal); - al::vector<std::array<ALubyte,2>> delays(irTotal); + auto coeffs = al::vector<std::array<ALfloat,2>>(irSize*irTotal); + auto delays = al::vector<std::array<ALubyte,2>>(irTotal); if(channelType == CHANTYPE_LEFTONLY) { if(sampleType == SAMPLETYPE_S16) @@ -914,11 +912,11 @@ std::unique_ptr<HrtfEntry> LoadHrtf02(std::istream &data, const char *filename) ERR("Failed reading %s\n", filename); return nullptr; } - for(ALsizei i{0};i < irTotal;++i) + for(size_t i{0};i < irTotal;++i) { if(delays[i][0] > MAX_HRIR_DELAY) { - ERR("Invalid delays[%d][0]: %d (%d)\n", i, delays[i][0], MAX_HRIR_DELAY); + ERR("Invalid delays[%zu][0]: %d (%d)\n", i, delays[i][0], MAX_HRIR_DELAY); failed = AL_TRUE; } } @@ -952,16 +950,16 @@ std::unique_ptr<HrtfEntry> LoadHrtf02(std::istream &data, const char *filename) return nullptr; } - for(ALsizei i{0};i < irTotal;++i) + for(size_t i{0};i < irTotal;++i) { if(delays[i][0] > MAX_HRIR_DELAY) { - ERR("Invalid delays[%d][0]: %d (%d)\n", i, delays[i][0], MAX_HRIR_DELAY); + ERR("Invalid delays[%zu][0]: %d (%d)\n", i, delays[i][0], MAX_HRIR_DELAY); failed = AL_TRUE; } if(delays[i][1] > MAX_HRIR_DELAY) { - ERR("Invalid delays[%d][1]: %d (%d)\n", i, delays[i][1], MAX_HRIR_DELAY); + ERR("Invalid delays[%zu][1]: %d (%d)\n", i, delays[i][1], MAX_HRIR_DELAY); failed = AL_TRUE; } } @@ -972,19 +970,19 @@ std::unique_ptr<HrtfEntry> LoadHrtf02(std::istream &data, const char *filename) if(channelType == CHANTYPE_LEFTONLY) { /* Mirror the left ear responses to the right ear. */ - ALsizei ebase{0}; - for(ALsizei f{0};f < fdCount;f++) + size_t ebase{0}; + for(size_t f{0};f < fdCount;f++) { - for(ALsizei e{0};e < evCount[f];e++) + for(size_t e{0};e < evCount[f];e++) { const ALushort evoffset{evOffset[ebase+e]}; const ALushort azcount{azCount[ebase+e]}; - for(ALsizei a{0};a < azcount;a++) + for(size_t a{0};a < azcount;a++) { - const ALsizei lidx{evoffset + a}; - const ALsizei ridx{evoffset + ((azcount-a) % azcount)}; + const size_t lidx{evoffset + a}; + const size_t ridx{evoffset + ((azcount-a) % azcount)}; - for(ALsizei k{0};k < irSize;k++) + for(size_t k{0};k < irSize;k++) coeffs[ridx*irSize + k][1] = coeffs[lidx*irSize + k][0]; delays[ridx][1] = delays[lidx][0]; } @@ -1011,13 +1009,13 @@ std::unique_ptr<HrtfEntry> LoadHrtf02(std::istream &data, const char *filename) * of per-group azimuth counts. */ auto azcnt_end = azCount_.end(); - auto copy_azs = [&azCount,&azcnt_end](const size_t ebase, const ALubyte num_evs) -> size_t + auto copy_azs = [&azCount,&azcnt_end](const ptrdiff_t ebase, const ALubyte num_evs) -> ptrdiff_t { auto azcnt_src = azCount.begin()+ebase; azcnt_end = std::copy_backward(azcnt_src, azcnt_src+num_evs, azcnt_end); return ebase + num_evs; }; - std::accumulate(evCount.cbegin(), evCount.cend(), size_t{0u}, copy_azs); + std::accumulate(evCount.cbegin(), evCount.cend(), ptrdiff_t{0}, copy_azs); assert(azCount_.begin() == azcnt_end); /* Reestablish the IR offset for each elevation index, given the new @@ -1029,7 +1027,7 @@ std::unique_ptr<HrtfEntry> LoadHrtf02(std::istream &data, const char *filename) /* Reverse the order of each field's group of IRs. */ auto coeffs_end = coeffs_.end(); auto delays_end = delays_.end(); - auto copy_irs = [irSize,&azCount,&coeffs,&delays,&coeffs_end,&delays_end](const size_t ebase, const ALubyte num_evs) -> size_t + auto copy_irs = [irSize,&azCount,&coeffs,&delays,&coeffs_end,&delays_end](const ptrdiff_t ebase, const ALubyte num_evs) -> ptrdiff_t { const ALsizei abase{std::accumulate(azCount.cbegin(), azCount.cbegin()+ebase, 0)}; const ALsizei num_azs{std::accumulate(azCount.cbegin()+ebase, @@ -1042,7 +1040,7 @@ std::unique_ptr<HrtfEntry> LoadHrtf02(std::istream &data, const char *filename) return ebase + num_evs; }; - std::accumulate(evCount.cbegin(), evCount.cend(), size_t{0u}, copy_irs); + std::accumulate(evCount.cbegin(), evCount.cend(), ptrdiff_t{0}, copy_irs); assert(coeffs_.begin() == coeffs_end); assert(delays_.begin() == delays_end); @@ -1293,9 +1291,9 @@ HrtfEntry *GetLoadedHrtf(HrtfHandle *handle) std::unique_ptr<std::istream> stream; const char *name{""}; - ALuint residx{}; + ALint residx{}; char ch{}; - if(sscanf(handle->filename.data(), "!%u%c", &residx, &ch) == 2 && ch == '_') + if(sscanf(handle->filename.data(), "!%d%c", &residx, &ch) == 2 && ch == '_') { name = strchr(handle->filename.data(), ch)+1; @@ -29,7 +29,7 @@ struct HrtfEntry { RefCount ref; ALuint sampleRate; - ALsizei irSize; + ALuint irSize; struct Field { ALfloat distance; @@ -38,7 +38,7 @@ struct HrtfEntry { /* NOTE: Fields are stored *backwards*. field[0] is the farthest field, and * field[fdCount-1] is the nearest. */ - ALsizei fdCount; + ALuint fdCount; const Field *field; struct Elevation { @@ -78,7 +78,7 @@ struct HrtfFilter { struct DirectHrtfState { /* HRTF filter state for dry buffer content */ - ALsizei IrSize{0}; + ALuint IrSize{0}; alignas(16) HrirArray Values; al::FlexArray<HrirArray,16> Coeffs; diff --git a/alc/mixer/hrtfbase.h b/alc/mixer/hrtfbase.h index 0309fe5d..dd33ce2d 100644 --- a/alc/mixer/hrtfbase.h +++ b/alc/mixer/hrtfbase.h @@ -103,7 +103,7 @@ inline void MixDirectHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOu { ASSUME(BufferSize > 0); - const ALsizei IrSize{State->IrSize}; + const auto IrSize = static_cast<ALsizei>(State->IrSize); auto accum_iter = std::copy_n(State->Values.begin(), State->Values.size(), AccumSamples); std::fill_n(accum_iter, BufferSize, float2{}); diff --git a/alc/mixvoice.cpp b/alc/mixvoice.cpp index 9d7dead4..c3598612 100644 --- a/alc/mixvoice.cpp +++ b/alc/mixvoice.cpp @@ -496,9 +496,7 @@ void ALvoice::mix(State vstate, ALCcontext *Context, const ALuint SamplesToDo) ALCdevice *Device{Context->mDevice.get()}; const ALuint NumSends{Device->NumAuxSends}; - const ALsizei IrSize{Device->mHrtf ? Device->mHrtf->irSize : 0}; - - ASSUME(IrSize >= 0); + const ALuint IrSize{Device->mHrtf ? Device->mHrtf->irSize : 0}; ResamplerFunc Resample{(increment == FRACTIONONE && DataPosFrac == 0) ? Resample_<CopyTag,CTag> : mResampler}; @@ -700,8 +698,8 @@ void ALvoice::mix(State vstate, ALCcontext *Context, const ALuint SamplesToDo) hrtfparams.GainStep = gain / static_cast<ALfloat>(fademix); MixHrtfBlendSamples(mDirect.Buffer[OutLIdx], mDirect.Buffer[OutRIdx], - HrtfSamples, AccumSamples, OutPos, IrSize, &parms.Hrtf.Old, - &hrtfparams, fademix); + HrtfSamples, AccumSamples, OutPos, static_cast<ALsizei>(IrSize), + &parms.Hrtf.Old, &hrtfparams, fademix); /* Update the old parameters with the result. */ parms.Hrtf.Old = parms.Hrtf.Target; if(fademix < Counter) @@ -733,8 +731,8 @@ void ALvoice::mix(State vstate, ALCcontext *Context, const ALuint SamplesToDo) hrtfparams.GainStep = (gain - parms.Hrtf.Old.Gain) / static_cast<ALfloat>(todo); MixHrtfSamples(mDirect.Buffer[OutLIdx], mDirect.Buffer[OutRIdx], - HrtfSamples+fademix, AccumSamples+fademix, OutPos+fademix, IrSize, - &hrtfparams, todo); + HrtfSamples+fademix, AccumSamples+fademix, OutPos+fademix, + static_cast<ALsizei>(IrSize), &hrtfparams, todo); /* Store the interpolated gain or the final target gain * depending if the fade is done. */ diff --git a/alc/panning.cpp b/alc/panning.cpp index 31daf455..b5394cbc 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -219,7 +219,7 @@ bool MakeSpeakerMap(ALCdevice *device, const AmbDecConf *conf, ALuint (&speakerm else { ERR("AmbDec speaker label \"%s\" not recognized\n", name); - return -1; + return INVALID_CHANNEL_INDEX; } } const ALuint chidx{GetChannelIdxByName(device->RealOut, ch)}; |