aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--al/debug.cpp8
-rw-r--r--al/eax/call.h2
-rw-r--r--alc/effects/convolution.cpp6
-rw-r--r--alc/effects/pshifter.cpp4
-rw-r--r--common/alspan.h46
-rw-r--r--common/phase_shifter.h4
-rw-r--r--core/cubic_tables.cpp2
-rw-r--r--core/hrtf.cpp2
-rw-r--r--core/logging.cpp8
-rw-r--r--core/voice.cpp4
-rw-r--r--utils/makemhr/loaddef.cpp2
-rw-r--r--utils/makemhr/loadsofa.cpp2
-rw-r--r--utils/makemhr/makemhr.h4
13 files changed, 44 insertions, 50 deletions
diff --git a/al/debug.cpp b/al/debug.cpp
index 3df85d62..a4b66ffb 100644
--- a/al/debug.cpp
+++ b/al/debug.cpp
@@ -311,7 +311,7 @@ FORCE_ALIGN void AL_APIENTRY alDebugMessageControlEXT(ALenum source, ALenum type
static constexpr size_t ElemCount{DebugSourceCount + DebugTypeCount + DebugSeverityCount};
static constexpr auto Values = make_array<uint,ElemCount>();
- al::span<const uint> srcIndices{al::as_span(Values).subspan<DebugSourceBase,DebugSourceCount>()};
+ al::span<const uint> srcIndices{al::span{Values}.subspan<DebugSourceBase,DebugSourceCount>()};
if(source != AL_DONT_CARE_EXT)
{
auto dsource = GetDebugSource(source);
@@ -320,7 +320,7 @@ FORCE_ALIGN void AL_APIENTRY alDebugMessageControlEXT(ALenum source, ALenum type
srcIndices = srcIndices.subspan(al::to_underlying(*dsource), 1);
}
- al::span<const uint> typeIndices{al::as_span(Values).subspan<DebugTypeBase,DebugTypeCount>()};
+ al::span<const uint> typeIndices{al::span{Values}.subspan<DebugTypeBase,DebugTypeCount>()};
if(type != AL_DONT_CARE_EXT)
{
auto dtype = GetDebugType(type);
@@ -329,7 +329,7 @@ FORCE_ALIGN void AL_APIENTRY alDebugMessageControlEXT(ALenum source, ALenum type
typeIndices = typeIndices.subspan(al::to_underlying(*dtype), 1);
}
- al::span<const uint> svrIndices{al::as_span(Values).subspan<DebugSeverityBase,DebugSeverityCount>()};
+ al::span<const uint> svrIndices{al::span{Values}.subspan<DebugSeverityBase,DebugSeverityCount>()};
if(severity != AL_DONT_CARE_EXT)
{
auto dseverity = GetDebugSeverity(severity);
@@ -344,7 +344,7 @@ FORCE_ALIGN void AL_APIENTRY alDebugMessageControlEXT(ALenum source, ALenum type
{
const uint filterbase{(1u<<srcIndices[0]) | (1u<<typeIndices[0])};
- for(const uint id : al::as_span(ids, static_cast<uint>(count)))
+ for(const uint id : al::span{ids, static_cast<uint>(count)})
{
const uint64_t filter{filterbase | (uint64_t{id} << 32)};
diff --git a/al/eax/call.h b/al/eax/call.h
index 5ec33b0f..f2ad529e 100644
--- a/al/eax/call.h
+++ b/al/eax/call.h
@@ -55,7 +55,7 @@ public:
fail_too_small();
const auto count = minz(mPropertyBufferSize / sizeof(TValue), max_count);
- return al::as_span(static_cast<TValue*>(mPropertyBuffer), count);
+ return {static_cast<TValue*>(mPropertyBuffer), count};
}
template<typename TValue>
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp
index 4ca31246..04b88f66 100644
--- a/alc/effects/convolution.cpp
+++ b/alc/effects/convolution.cpp
@@ -360,7 +360,7 @@ void ConvolutionState::deviceUpdate(const DeviceBase *device, const BufferStorag
done += todo;
std::fill(iter, fftbuffer.end(), std::complex<double>{});
- forward_fft(al::as_span(fftbuffer));
+ forward_fft(al::span{fftbuffer});
filteriter = std::copy_n(fftbuffer.cbegin(), m, filteriter);
}
}
@@ -562,7 +562,7 @@ void ConvolutionState::process(const size_t samplesToDo,
*/
auto fftiter = std::copy_n(mInput.cbegin(), ConvolveUpdateSamples, mFftBuffer.begin());
std::fill(fftiter, mFftBuffer.end(), complex_f{});
- forward_fft(al::as_span(mFftBuffer));
+ forward_fft(al::span{mFftBuffer});
std::copy_n(mFftBuffer.cbegin(), m, &mComplexData[curseg*m]);
@@ -598,7 +598,7 @@ void ConvolutionState::process(const size_t samplesToDo,
* second-half samples (and this output's second half is
* subsequently saved for next time).
*/
- inverse_fft(al::as_span(mFftBuffer));
+ inverse_fft(al::span{mFftBuffer});
/* The iFFT'd response is scaled up by the number of bins, so apply
* the inverse to normalize the output.
diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp
index 426a2264..3cec1df9 100644
--- a/alc/effects/pshifter.cpp
+++ b/alc/effects/pshifter.cpp
@@ -186,7 +186,7 @@ void PshifterState::process(const size_t samplesToDo,
mFftBuffer[k] = mFIFO[src] * gWindow.mData[k];
for(size_t src{0u}, k{StftSize-mPos};src < mPos;++src,++k)
mFftBuffer[k] = mFIFO[src] * gWindow.mData[k];
- forward_fft(al::as_span(mFftBuffer));
+ forward_fft(al::span{mFftBuffer});
/* Analyze the obtained data. Since the real FFT is symmetric, only
* StftHalfSize+1 samples are needed.
@@ -274,7 +274,7 @@ void PshifterState::process(const size_t samplesToDo,
/* Apply an inverse FFT to get the time-domain signal, and accumulate
* for the output with windowing.
*/
- inverse_fft(al::as_span(mFftBuffer));
+ inverse_fft(al::span{mFftBuffer});
static constexpr float scale{3.0f / OversampleFactor / StftSize};
for(size_t dst{mPos}, k{0u};dst < StftSize;++dst,++k)
diff --git a/common/alspan.h b/common/alspan.h
index 42b3e057..f75bc84f 100644
--- a/common/alspan.h
+++ b/common/alspan.h
@@ -39,12 +39,15 @@ namespace detail_ {
std::void_t<decltype(std::size(std::declval<T>())),decltype(std::data(std::declval<T>()))>>
= true;
+ template<typename C>
+ constexpr bool is_valid_container_type = !is_span_v<C> && !is_std_array_v<C>
+ && !std::is_array<C>::value && has_size_and_data<C>;
+
template<typename T, typename U>
constexpr bool is_array_compatible = std::is_convertible<T(*)[],U(*)[]>::value;
template<typename C, typename T>
- constexpr bool is_valid_container = !is_span_v<C> && !is_std_array_v<C>
- && !std::is_array<C>::value && has_size_and_data<C>
+ constexpr bool is_valid_container = is_valid_container_type<C>
&& is_array_compatible<std::remove_pointer_t<decltype(std::data(std::declval<C&>()))>,T>;
} // namespace detail_
@@ -297,30 +300,21 @@ constexpr inline auto span<T,E>::subspan(size_t offset, size_t count) const
span<element_type>{mData+offset, mData+offset+count};
}
-/* Helpers to deal with the lack of user-defined deduction guides (C++17). */
-template<typename T, typename U>
-constexpr auto as_span(T ptr, U count_or_end)
-{
- using value_type = typename std::pointer_traits<T>::element_type;
- return span<value_type>{ptr, count_or_end};
-}
-template<typename T, size_t N>
-constexpr auto as_span(T (&arr)[N]) noexcept { return span<T,N>{std::data(arr), std::size(arr)}; }
-template<typename T, size_t N>
-constexpr auto as_span(std::array<T,N> &arr) noexcept
-{ return span<T,N>{std::data(arr), std::size(arr)}; }
-template<typename T, size_t N>
-constexpr auto as_span(const std::array<T,N> &arr) noexcept
-{ return span<std::add_const_t<T>,N>{std::data(arr), std::size(arr)}; }
-template<typename U, REQUIRES(!detail_::is_span_v<U> && !detail_::is_std_array_v<U>
- && !std::is_array<U>::value && detail_::has_size_and_data<U>)>
-constexpr auto as_span(U&& cont)
-{
- using value_type = std::remove_pointer_t<decltype(std::data(std::declval<U&>()))>;
- return span<value_type>{std::data(cont), std::size(cont)};
-}
-template<typename T, size_t N>
-constexpr auto as_span(span<T,N> span_) noexcept { return span_; }
+
+template<typename T, typename EndOrSize>
+span(T, EndOrSize) -> span<std::remove_reference_t<decltype(*std::declval<T&>())>>;
+
+template<typename T, std::size_t N>
+span(T (&)[N]) -> span<T, N>;
+
+template<typename T, std::size_t N>
+span(std::array<T, N>&) -> span<T, N>;
+
+template<typename T, std::size_t N>
+span(const std::array<T, N>&) -> span<const T, N>;
+
+template<typename C, REQUIRES(detail_::is_valid_container_type<C>)>
+span(C&&) -> span<std::remove_reference_t<decltype(*std::data(std::declval<C&>()))>>;
#undef REQUIRES
diff --git a/common/phase_shifter.h b/common/phase_shifter.h
index 0d4166bc..061e9176 100644
--- a/common/phase_shifter.h
+++ b/common/phase_shifter.h
@@ -53,12 +53,12 @@ struct PhaseShifterT {
std::fill_n(fftBuffer.get(), fft_size, complex_d{});
fftBuffer[half_size] = 1.0;
- forward_fft(al::as_span(fftBuffer.get(), fft_size));
+ forward_fft(al::span{fftBuffer.get(), fft_size});
for(size_t i{0};i < half_size+1;++i)
fftBuffer[i] = complex_d{-fftBuffer[i].imag(), fftBuffer[i].real()};
for(size_t i{half_size+1};i < fft_size;++i)
fftBuffer[i] = std::conj(fftBuffer[fft_size - i]);
- inverse_fft(al::as_span(fftBuffer.get(), fft_size));
+ inverse_fft(al::span{fftBuffer.get(), fft_size});
auto fftiter = fftBuffer.get() + half_size + (FilterSize/2 - 1);
for(float &coeff : mCoeffs)
diff --git a/core/cubic_tables.cpp b/core/cubic_tables.cpp
index 73ec6b3f..66958735 100644
--- a/core/cubic_tables.cpp
+++ b/core/cubic_tables.cpp
@@ -49,7 +49,7 @@ struct SplineFilterArray {
mTable[pi].mDeltas[3] = -mTable[pi].mCoeffs[3];
}
- constexpr auto getTable() const noexcept { return al::as_span(mTable); }
+ constexpr auto& getTable() const noexcept { return mTable; }
};
constexpr SplineFilterArray SplineFilter{};
diff --git a/core/hrtf.cpp b/core/hrtf.cpp
index 1d9bc368..607e3d3d 100644
--- a/core/hrtf.cpp
+++ b/core/hrtf.cpp
@@ -425,7 +425,7 @@ std::unique_ptr<HrtfStore> CreateHrtfStore(uint rate, uint8_t irSize,
std::uninitialized_copy_n(delays, irCount, delays_);
/* Finally, assign the storage pointers. */
- Hrtf->mFields = al::as_span(field_, fields.size());
+ Hrtf->mFields = {field_, fields.size()};
Hrtf->mElev = elev_;
Hrtf->mCoeffs = coeffs_;
Hrtf->mDelays = delays_;
diff --git a/core/logging.cpp b/core/logging.cpp
index 34a95e5a..8e0116ea 100644
--- a/core/logging.cpp
+++ b/core/logging.cpp
@@ -25,13 +25,13 @@ void al_print(LogLevel level, FILE *logfile, const char *fmt, ...)
* that includes the null terminator, which we want to exclude from the
* span.
*/
- auto prefix = al::as_span("[ALSOFT] (--) ").first<14>();
+ auto prefix = al::span{"[ALSOFT] (--) "}.first<14>();
switch(level)
{
case LogLevel::Disable: break;
- case LogLevel::Error: prefix = al::as_span("[ALSOFT] (EE) ").first<14>(); break;
- case LogLevel::Warning: prefix = al::as_span("[ALSOFT] (WW) ").first<14>(); break;
- case LogLevel::Trace: prefix = al::as_span("[ALSOFT] (II) ").first<14>(); break;
+ case LogLevel::Error: prefix = al::span{"[ALSOFT] (EE) "}.first<14>(); break;
+ case LogLevel::Warning: prefix = al::span{"[ALSOFT] (WW) "}.first<14>(); break;
+ case LogLevel::Trace: prefix = al::span{"[ALSOFT] (II) "}.first<14>(); break;
}
al::vector<char> dynmsg;
diff --git a/core/voice.cpp b/core/voice.cpp
index db6b6d27..478ea81f 100644
--- a/core/voice.cpp
+++ b/core/voice.cpp
@@ -389,7 +389,7 @@ inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const std::byte
sampleHistory[1] = int(input[2*srcChan + 0]) | (int(input[2*srcChan + 1])<<8);
input += srcStep*2;
- const auto coeffs = al::as_span(MSADPCMAdaptionCoeff[blockpred]);
+ const al::span coeffs{MSADPCMAdaptionCoeff[blockpred]};
delta = (delta^0x8000) - 32768;
sampleHistory[0] = (sampleHistory[0]^0x8000) - 32768;
sampleHistory[1] = (sampleHistory[1]^0x8000) - 32768;
@@ -798,7 +798,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi
using ResBufType = decltype(DeviceBase::mResampleData);
static constexpr uint srcSizeMax{static_cast<uint>(ResBufType{}.size()-MaxResamplerEdge)};
- const auto prevSamples = al::as_span(mPrevSamples[chan]);
+ const al::span prevSamples{mPrevSamples[chan]};
const auto resampleBuffer = std::copy(prevSamples.cbegin(), prevSamples.cend(),
Device->mResampleData.begin()) - MaxResamplerEdge;
int intPos{DataPosInt};
diff --git a/utils/makemhr/loaddef.cpp b/utils/makemhr/loaddef.cpp
index 84fbb48b..c8a98511 100644
--- a/utils/makemhr/loaddef.cpp
+++ b/utils/makemhr/loaddef.cpp
@@ -1450,7 +1450,7 @@ static int ProcessMetrics(TokenReaderT *tr, const uint fftSize, const uint trunc
}
if(hData->mChannelType == CT_NONE)
hData->mChannelType = CT_MONO;
- const auto azs = al::as_span(azCounts).first<MAX_FD_COUNT>();
+ const auto azs = al::span{azCounts}.first<MAX_FD_COUNT>();
if(!PrepareHrirData({distances, fdCount}, evCounts, azs, hData))
{
fprintf(stderr, "Error: Out of memory.\n");
diff --git a/utils/makemhr/loadsofa.cpp b/utils/makemhr/loadsofa.cpp
index 9e661839..9bcfc38d 100644
--- a/utils/makemhr/loadsofa.cpp
+++ b/utils/makemhr/loadsofa.cpp
@@ -87,7 +87,7 @@ static bool PrepareLayout(const uint m, const float *xyzs, HrirDataT *hData)
++fi;
}
fprintf(stdout, "Using %u of %u IRs.\n", ir_total, m);
- const auto azs = al::as_span(azCounts).first<MAX_FD_COUNT>();
+ const auto azs = al::span{azCounts}.first<MAX_FD_COUNT>();
return PrepareHrirData({distances, fi}, evCounts, azs, hData);
}
diff --git a/utils/makemhr/makemhr.h b/utils/makemhr/makemhr.h
index 13b5b2d1..aa18134d 100644
--- a/utils/makemhr/makemhr.h
+++ b/utils/makemhr/makemhr.h
@@ -113,12 +113,12 @@ void MagnitudeResponse(const uint n, const complex_d *in, double *out);
// Performs a forward FFT.
inline void FftForward(const uint n, complex_d *inout)
-{ forward_fft(al::as_span(inout, n)); }
+{ forward_fft(al::span{inout, n}); }
// Performs an inverse FFT.
inline void FftInverse(const uint n, complex_d *inout)
{
- inverse_fft(al::as_span(inout, n));
+ inverse_fft(al::span{inout, n});
double f{1.0 / n};
for(uint i{0};i < n;i++)
inout[i] *= f;