Enable and fix more warnings
This commit is contained in:
+2
-5
@@ -220,11 +220,8 @@ IF(MSVC)
|
||||
ENDFOREACH(flag_var)
|
||||
ENDIF()
|
||||
ELSE()
|
||||
SET(C_FLAGS ${C_FLAGS} -Winline -Wall $<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast> -Wconversion)
|
||||
CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
|
||||
IF(HAVE_W_EXTRA)
|
||||
SET(C_FLAGS ${C_FLAGS} -Wextra)
|
||||
ENDIF()
|
||||
SET(C_FLAGS ${C_FLAGS} -Winline -Wall -Wextra -Wshadow -Wconversion -Wcast-align
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual>)
|
||||
|
||||
IF(ALSOFT_WERROR)
|
||||
SET(C_FLAGS ${C_FLAGS} -Werror)
|
||||
|
||||
+5
-13
@@ -44,21 +44,13 @@ static int EventThread(ALCcontext *context)
|
||||
|
||||
std::lock_guard<std::mutex> _{context->mEventCbLock};
|
||||
do {
|
||||
auto &evt = *reinterpret_cast<AsyncEvent*>(evt_data.buf);
|
||||
auto *evt_ptr = reinterpret_cast<AsyncEvent*>(evt_data.buf);
|
||||
evt_data.buf += sizeof(AsyncEvent);
|
||||
evt_data.len -= 1;
|
||||
/* This automatically destructs the event object and advances the
|
||||
* ringbuffer's read offset at the end of scope.
|
||||
*/
|
||||
const struct EventAutoDestructor {
|
||||
AsyncEvent &evt_;
|
||||
RingBuffer *ring_;
|
||||
~EventAutoDestructor()
|
||||
{
|
||||
al::destroy_at(std::addressof(evt_));
|
||||
ring_->readAdvance(1);
|
||||
}
|
||||
} _{evt, ring};
|
||||
|
||||
AsyncEvent evt{*evt_ptr};
|
||||
al::destroy_at(evt_ptr);
|
||||
ring->readAdvance(1);
|
||||
|
||||
quitnow = evt.EnumType == EventType_KillThread;
|
||||
if UNLIKELY(quitnow) break;
|
||||
|
||||
+16
-14
@@ -1199,7 +1199,7 @@ bool SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a
|
||||
std::unique_ptr<ALbufferlistitem> temp{oldlist};
|
||||
oldlist = temp->mNext.load(std::memory_order_relaxed);
|
||||
|
||||
if(ALbuffer *buffer{temp->mBuffer})
|
||||
if((buffer=temp->mBuffer) != nullptr)
|
||||
DecrementRef(buffer->ref);
|
||||
}
|
||||
return true;
|
||||
@@ -1215,7 +1215,6 @@ bool SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a
|
||||
|
||||
if(IsPlayingOrPaused(Source))
|
||||
{
|
||||
ALCdevice *device{Context->mDevice.get()};
|
||||
BackendLockGuard _{*device->Backend};
|
||||
if(ALvoice *voice{GetSourceVoice(Source, Context)})
|
||||
{
|
||||
@@ -1347,8 +1346,8 @@ bool SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a
|
||||
{
|
||||
/* Add refcount on the new slot, and release the previous slot */
|
||||
if(slot) IncrementRef(slot->ref);
|
||||
if(auto *slot = Source->Send[static_cast<ALuint>(values[1])].Slot)
|
||||
DecrementRef(slot->ref);
|
||||
if(auto *oldslot = Source->Send[static_cast<ALuint>(values[1])].Slot)
|
||||
DecrementRef(oldslot->ref);
|
||||
Source->Send[static_cast<ALuint>(values[1])].Slot = slot;
|
||||
|
||||
/* We must force an update if the auxiliary slot changed on an
|
||||
@@ -1361,8 +1360,8 @@ bool SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a
|
||||
else
|
||||
{
|
||||
if(slot) IncrementRef(slot->ref);
|
||||
if(auto *slot = Source->Send[static_cast<ALuint>(values[1])].Slot)
|
||||
DecrementRef(slot->ref);
|
||||
if(auto *oldslot = Source->Send[static_cast<ALuint>(values[1])].Slot)
|
||||
DecrementRef(oldslot->ref);
|
||||
Source->Send[static_cast<ALuint>(values[1])].Slot = slot;
|
||||
UpdateSourceProps(Source, Context);
|
||||
}
|
||||
@@ -1730,7 +1729,6 @@ bool GetSourcedv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a
|
||||
|
||||
bool GetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const al::span<ALint> values)
|
||||
{
|
||||
ALbufferlistitem *BufferList;
|
||||
ALdouble dvals[MaxValues];
|
||||
bool err;
|
||||
|
||||
@@ -1748,9 +1746,13 @@ bool GetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a
|
||||
|
||||
case AL_BUFFER:
|
||||
CHECKSIZE(values, 1);
|
||||
BufferList = (Source->SourceType == AL_STATIC) ? Source->queue : nullptr;
|
||||
values[0] = (BufferList && BufferList->mBuffer) ?
|
||||
static_cast<ALint>(BufferList->mBuffer->id) : 0;
|
||||
{
|
||||
ALbufferlistitem *BufferList{nullptr};
|
||||
if(Source->SourceType == AL_STATIC) BufferList = Source->queue;
|
||||
ALbuffer *buffer{nullptr};
|
||||
if(BufferList) buffer = BufferList->mBuffer;
|
||||
values[0] = buffer ? static_cast<ALint>(buffer->id) : 0;
|
||||
}
|
||||
return true;
|
||||
|
||||
case AL_SOURCE_STATE:
|
||||
@@ -1760,9 +1762,7 @@ bool GetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a
|
||||
|
||||
case AL_BUFFERS_QUEUED:
|
||||
CHECKSIZE(values, 1);
|
||||
if(!(BufferList=Source->queue))
|
||||
values[0] = 0;
|
||||
else
|
||||
if(ALbufferlistitem *BufferList{Source->queue})
|
||||
{
|
||||
ALsizei count{0};
|
||||
do {
|
||||
@@ -1771,6 +1771,8 @@ bool GetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a
|
||||
} while(BufferList != nullptr);
|
||||
values[0] = count;
|
||||
}
|
||||
else
|
||||
values[0] = 0;
|
||||
return true;
|
||||
|
||||
case AL_BUFFERS_PROCESSED:
|
||||
@@ -3135,7 +3137,7 @@ START_API_FUNC
|
||||
{
|
||||
std::unique_ptr<ALbufferlistitem> head{BufferListStart};
|
||||
BufferListStart = head->mNext.load(std::memory_order_relaxed);
|
||||
if(ALbuffer *buffer{head->mBuffer}) DecrementRef(buffer->ref);
|
||||
if((buffer=head->mBuffer) != nullptr) DecrementRef(buffer->ref);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
+4
-4
@@ -3731,11 +3731,11 @@ START_API_FUNC
|
||||
al::vector<ContextRef> orphanctxs;
|
||||
for(ALCcontext *ctx : *dev->mContexts.load())
|
||||
{
|
||||
auto iter = std::lower_bound(ContextList.begin(), ContextList.end(), ctx);
|
||||
if(iter != ContextList.end() && *iter == ctx)
|
||||
auto ctxiter = std::lower_bound(ContextList.begin(), ContextList.end(), ctx);
|
||||
if(ctxiter != ContextList.end() && *ctxiter == ctx)
|
||||
{
|
||||
orphanctxs.emplace_back(std::move(*iter));
|
||||
ContextList.erase(iter);
|
||||
orphanctxs.emplace_back(std::move(*ctxiter));
|
||||
ContextList.erase(ctxiter);
|
||||
}
|
||||
}
|
||||
listlock.unlock();
|
||||
|
||||
+6
-6
@@ -359,7 +359,7 @@ void ReadALConfig()
|
||||
else fname += "alsoft.conf";
|
||||
|
||||
TRACE("Loading config %s...\n", fname.c_str());
|
||||
al::ifstream f{fname};
|
||||
f = al::ifstream{fname};
|
||||
if(f.is_open())
|
||||
LoadConfigFromFile(f);
|
||||
}
|
||||
@@ -376,7 +376,7 @@ void ReadALConfig()
|
||||
if((configURL=CFBundleCopyResourceURL(mainBundle, CFSTR(".alsoftrc"), CFSTR(""), nullptr)) &&
|
||||
CFURLGetFileSystemRepresentation(configURL, true, fileName, sizeof(fileName)))
|
||||
{
|
||||
al::ifstream f{reinterpret_cast<char*>(fileName)};
|
||||
f = al::ifstream{reinterpret_cast<char*>(fileName)};
|
||||
if(f.is_open())
|
||||
LoadConfigFromFile(f);
|
||||
}
|
||||
@@ -390,7 +390,7 @@ void ReadALConfig()
|
||||
else fname += ".alsoftrc";
|
||||
|
||||
TRACE("Loading config %s...\n", fname.c_str());
|
||||
al::ifstream f{fname};
|
||||
f = al::ifstream{fname};
|
||||
if(f.is_open())
|
||||
LoadConfigFromFile(f);
|
||||
}
|
||||
@@ -414,7 +414,7 @@ void ReadALConfig()
|
||||
if(!fname.empty())
|
||||
{
|
||||
TRACE("Loading config %s...\n", fname.c_str());
|
||||
al::ifstream f{fname};
|
||||
f = al::ifstream{fname};
|
||||
if(f.is_open())
|
||||
LoadConfigFromFile(f);
|
||||
}
|
||||
@@ -426,7 +426,7 @@ void ReadALConfig()
|
||||
else ppath += "alsoft.conf";
|
||||
|
||||
TRACE("Loading config %s...\n", ppath.c_str());
|
||||
al::ifstream f{ppath};
|
||||
f = al::ifstream{ppath};
|
||||
if(f.is_open())
|
||||
LoadConfigFromFile(f);
|
||||
}
|
||||
@@ -434,7 +434,7 @@ void ReadALConfig()
|
||||
if(auto confname = al::getenv("ALSOFT_CONF"))
|
||||
{
|
||||
TRACE("Loading config %s...\n", confname->c_str());
|
||||
al::ifstream f{*confname};
|
||||
f = al::ifstream{*confname};
|
||||
if(f.is_open())
|
||||
LoadConfigFromFile(f);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,8 @@ enum class DevProbe {
|
||||
|
||||
|
||||
struct BackendFactory {
|
||||
virtual ~BackendFactory() = default;
|
||||
|
||||
virtual bool init() = 0;
|
||||
|
||||
virtual bool querySupport(BackendType type) = 0;
|
||||
|
||||
@@ -484,7 +484,7 @@ pa_stream *pulse_connect_stream(const char *device_name, std::unique_lock<std::m
|
||||
{
|
||||
if(!PA_STREAM_IS_GOOD(state))
|
||||
{
|
||||
int err{pa_context_errno(context)};
|
||||
err = pa_context_errno(context);
|
||||
pa_stream_unref(stream);
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s did not get ready (%s)", stream_id,
|
||||
pa_strerror(err)};
|
||||
|
||||
+14
-14
@@ -81,11 +81,11 @@ void BiquadFilterR<Real>::setParams(BiquadType type, Real gain, Real f0norm, Rea
|
||||
break;
|
||||
}
|
||||
|
||||
a1 = a[1] / a[0];
|
||||
a2 = a[2] / a[0];
|
||||
b0 = b[0] / a[0];
|
||||
b1 = b[1] / a[0];
|
||||
b2 = b[2] / a[0];
|
||||
mA1 = a[1] / a[0];
|
||||
mA2 = a[2] / a[0];
|
||||
mB0 = b[0] / a[0];
|
||||
mB1 = b[1] / a[0];
|
||||
mB2 = b[2] / a[0];
|
||||
}
|
||||
|
||||
template<typename Real>
|
||||
@@ -93,13 +93,13 @@ void BiquadFilterR<Real>::process(Real *dst, const Real *src, const size_t numsa
|
||||
{
|
||||
ASSUME(numsamples > 0);
|
||||
|
||||
const Real b0{this->b0};
|
||||
const Real b1{this->b1};
|
||||
const Real b2{this->b2};
|
||||
const Real a1{this->a1};
|
||||
const Real a2{this->a2};
|
||||
Real z1{this->z1};
|
||||
Real z2{this->z2};
|
||||
const Real b0{mB0};
|
||||
const Real b1{mB1};
|
||||
const Real b2{mB2};
|
||||
const Real a1{mA1};
|
||||
const Real a2{mA2};
|
||||
Real z1{mZ1};
|
||||
Real z2{mZ2};
|
||||
|
||||
/* Processing loop is Transposed Direct Form II. This requires less storage
|
||||
* compared to Direct Form I (only two delay components, instead of a four-
|
||||
@@ -118,8 +118,8 @@ void BiquadFilterR<Real>::process(Real *dst, const Real *src, const size_t numsa
|
||||
};
|
||||
std::transform(src, src+numsamples, dst, proc_sample);
|
||||
|
||||
this->z1 = z1;
|
||||
this->z2 = z2;
|
||||
mZ1 = z1;
|
||||
mZ2 = z2;
|
||||
}
|
||||
|
||||
template class BiquadFilterR<float>;
|
||||
|
||||
+15
-17
@@ -38,14 +38,14 @@ enum class BiquadType {
|
||||
template<typename Real>
|
||||
class BiquadFilterR {
|
||||
/* Last two delayed components for direct form II. */
|
||||
Real z1{0.0f}, z2{0.0f};
|
||||
Real mZ1{0.0f}, mZ2{0.0f};
|
||||
/* Transfer function coefficients "b" (numerator) */
|
||||
Real b0{1.0f}, b1{0.0f}, b2{0.0f};
|
||||
Real mB0{1.0f}, mB1{0.0f}, mB2{0.0f};
|
||||
/* Transfer function coefficients "a" (denominator; a0 is pre-applied). */
|
||||
Real a1{0.0f}, a2{0.0f};
|
||||
Real mA1{0.0f}, mA2{0.0f};
|
||||
|
||||
public:
|
||||
void clear() noexcept { z1 = z2 = 0.0f; }
|
||||
void clear() noexcept { mZ1 = mZ2 = 0.0f; }
|
||||
|
||||
/**
|
||||
* Sets the filter state for the specified filter type and its parameters.
|
||||
@@ -65,26 +65,24 @@ public:
|
||||
|
||||
void copyParamsFrom(const BiquadFilterR &other)
|
||||
{
|
||||
b0 = other.b0;
|
||||
b1 = other.b1;
|
||||
b2 = other.b2;
|
||||
a1 = other.a1;
|
||||
a2 = other.a2;
|
||||
mB0 = other.mB0;
|
||||
mB1 = other.mB1;
|
||||
mB2 = other.mB2;
|
||||
mA1 = other.mA1;
|
||||
mA2 = other.mA2;
|
||||
}
|
||||
|
||||
|
||||
void process(Real *dst, const Real *src, const size_t numsamples);
|
||||
|
||||
/* Rather hacky. It's just here to support "manual" processing. */
|
||||
std::pair<Real,Real> getComponents() const noexcept
|
||||
{ return {z1, z2}; }
|
||||
void setComponents(Real z1_, Real z2_) noexcept
|
||||
{ z1 = z1_; z2 = z2_; }
|
||||
Real processOne(const Real in, Real &z1_, Real &z2_) const noexcept
|
||||
std::pair<Real,Real> getComponents() const noexcept { return {mZ1, mZ2}; }
|
||||
void setComponents(Real z1, Real z2) noexcept { mZ1 = z1; mZ2 = z2; }
|
||||
Real processOne(const Real in, Real &z1, Real &z2) const noexcept
|
||||
{
|
||||
Real out{in*b0 + z1_};
|
||||
z1_ = in*b1 - out*a1 + z2_;
|
||||
z2_ = in*b2 - out*a2;
|
||||
Real out{in*mB0 + z1};
|
||||
z1 = in*mB1 - out*mA1 + z2;
|
||||
z2 = in*mB2 - out*mA2;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
+22
-22
@@ -17,13 +17,13 @@ void BandSplitterR<Real>::init(Real f0norm)
|
||||
const Real w{f0norm * al::MathDefs<Real>::Tau()};
|
||||
const Real cw{std::cos(w)};
|
||||
if(cw > std::numeric_limits<float>::epsilon())
|
||||
coeff = (std::sin(w) - 1.0f) / cw;
|
||||
mCoeff = (std::sin(w) - 1.0f) / cw;
|
||||
else
|
||||
coeff = cw * -0.5f;
|
||||
mCoeff = cw * -0.5f;
|
||||
|
||||
lp_z1 = 0.0f;
|
||||
lp_z2 = 0.0f;
|
||||
ap_z1 = 0.0f;
|
||||
mLpZ1 = 0.0f;
|
||||
mLpZ2 = 0.0f;
|
||||
mApZ1 = 0.0f;
|
||||
}
|
||||
|
||||
template<typename Real>
|
||||
@@ -31,11 +31,11 @@ void BandSplitterR<Real>::process(Real *hpout, Real *lpout, const Real *input, c
|
||||
{
|
||||
ASSUME(count > 0);
|
||||
|
||||
const Real ap_coeff{this->coeff};
|
||||
const Real lp_coeff{this->coeff*0.5f + 0.5f};
|
||||
Real lp_z1{this->lp_z1};
|
||||
Real lp_z2{this->lp_z2};
|
||||
Real ap_z1{this->ap_z1};
|
||||
const Real ap_coeff{mCoeff};
|
||||
const Real lp_coeff{mCoeff*0.5f + 0.5f};
|
||||
Real lp_z1{mLpZ1};
|
||||
Real lp_z2{mLpZ2};
|
||||
Real ap_z1{mApZ1};
|
||||
auto proc_sample = [ap_coeff,lp_coeff,&lp_z1,&lp_z2,&ap_z1,&lpout](const Real in) noexcept -> Real
|
||||
{
|
||||
/* Low-pass sample processing. */
|
||||
@@ -57,9 +57,9 @@ void BandSplitterR<Real>::process(Real *hpout, Real *lpout, const Real *input, c
|
||||
return ap_y - lp_y;
|
||||
};
|
||||
std::transform(input, input+count, hpout, proc_sample);
|
||||
this->lp_z1 = lp_z1;
|
||||
this->lp_z2 = lp_z2;
|
||||
this->ap_z1 = ap_z1;
|
||||
mLpZ1 = lp_z1;
|
||||
mLpZ2 = lp_z2;
|
||||
mApZ1 = ap_z1;
|
||||
}
|
||||
|
||||
template<typename Real>
|
||||
@@ -67,11 +67,11 @@ void BandSplitterR<Real>::applyHfScale(Real *samples, const Real hfscale, const
|
||||
{
|
||||
ASSUME(count > 0);
|
||||
|
||||
const Real ap_coeff{this->coeff};
|
||||
const Real lp_coeff{this->coeff*0.5f + 0.5f};
|
||||
Real lp_z1{this->lp_z1};
|
||||
Real lp_z2{this->lp_z2};
|
||||
Real ap_z1{this->ap_z1};
|
||||
const Real ap_coeff{mCoeff};
|
||||
const Real lp_coeff{mCoeff*0.5f + 0.5f};
|
||||
Real lp_z1{mLpZ1};
|
||||
Real lp_z2{mLpZ2};
|
||||
Real ap_z1{mApZ1};
|
||||
auto proc_sample = [hfscale,ap_coeff,lp_coeff,&lp_z1,&lp_z2,&ap_z1](const Real in) noexcept -> Real
|
||||
{
|
||||
/* Low-pass sample processing. */
|
||||
@@ -91,9 +91,9 @@ void BandSplitterR<Real>::applyHfScale(Real *samples, const Real hfscale, const
|
||||
return (ap_y-lp_y)*hfscale + lp_y;
|
||||
};
|
||||
std::transform(samples, samples+count, samples, proc_sample);
|
||||
this->lp_z1 = lp_z1;
|
||||
this->lp_z2 = lp_z2;
|
||||
this->ap_z1 = ap_z1;
|
||||
mLpZ1 = lp_z1;
|
||||
mLpZ2 = lp_z2;
|
||||
mApZ1 = ap_z1;
|
||||
}
|
||||
|
||||
template<typename Real>
|
||||
@@ -101,7 +101,7 @@ void BandSplitterR<Real>::applyAllpass(Real *samples, const size_t count) const
|
||||
{
|
||||
ASSUME(count > 0);
|
||||
|
||||
const Real coeff{this->coeff};
|
||||
const Real coeff{mCoeff};
|
||||
Real z1{0.0f};
|
||||
auto proc_sample = [coeff,&z1](const Real in) noexcept -> Real
|
||||
{
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
/* Band splitter. Splits a signal into two phase-matching frequency bands. */
|
||||
template<typename Real>
|
||||
class BandSplitterR {
|
||||
Real coeff{0.0f};
|
||||
Real lp_z1{0.0f};
|
||||
Real lp_z2{0.0f};
|
||||
Real ap_z1{0.0f};
|
||||
Real mCoeff{0.0f};
|
||||
Real mLpZ1{0.0f};
|
||||
Real mLpZ2{0.0f};
|
||||
Real mApZ1{0.0f};
|
||||
|
||||
public:
|
||||
BandSplitterR() = default;
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
BandSplitterR(Real f0norm) { init(f0norm); }
|
||||
|
||||
void init(Real f0norm);
|
||||
void clear() noexcept { lp_z1 = lp_z2 = ap_z1 = 0.0f; }
|
||||
void clear() noexcept { mLpZ1 = mLpZ2 = mApZ1 = 0.0f; }
|
||||
void process(Real *hpout, Real *lpout, const Real *input, const size_t count);
|
||||
|
||||
void applyHfScale(Real *samples, const Real hfscale, const size_t count);
|
||||
|
||||
+4
-4
@@ -475,7 +475,7 @@ std::unique_ptr<HrtfEntry> CreateHrtfStore(ALuint rate, ALushort irSize, const A
|
||||
ERR("Out of memory allocating storage for %s.\n", filename);
|
||||
else
|
||||
{
|
||||
InitRef(Hrtf->ref, 1u);
|
||||
InitRef(Hrtf->mRef, 1u);
|
||||
Hrtf->sampleRate = rate;
|
||||
Hrtf->irSize = irSize;
|
||||
Hrtf->fdCount = fdCount;
|
||||
@@ -1362,13 +1362,13 @@ HrtfEntry *GetLoadedHrtf(HrtfHandle *handle)
|
||||
|
||||
void HrtfEntry::IncRef()
|
||||
{
|
||||
auto ref = IncrementRef(this->ref);
|
||||
auto ref = IncrementRef(mRef);
|
||||
TRACE("HrtfEntry %p increasing refcount to %u\n", this, ref);
|
||||
}
|
||||
|
||||
void HrtfEntry::DecRef()
|
||||
{
|
||||
auto ref = DecrementRef(this->ref);
|
||||
auto ref = DecrementRef(mRef);
|
||||
TRACE("HrtfEntry %p decreasing refcount to %u\n", this, ref);
|
||||
if(ref == 0)
|
||||
{
|
||||
@@ -1378,7 +1378,7 @@ void HrtfEntry::DecRef()
|
||||
auto delete_unused = [](HrtfHandlePtr &handle) -> void
|
||||
{
|
||||
HrtfEntry *entry{handle->entry.get()};
|
||||
if(entry && ReadRef(entry->ref) == 0)
|
||||
if(entry && ReadRef(entry->mRef) == 0)
|
||||
{
|
||||
TRACE("Unloading unused HRTF %s\n", handle->filename.data());
|
||||
handle->entry = nullptr;
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ struct HrtfHandle;
|
||||
|
||||
|
||||
struct HrtfEntry {
|
||||
RefCount ref;
|
||||
RefCount mRef;
|
||||
|
||||
ALuint sampleRate;
|
||||
ALuint irSize;
|
||||
|
||||
+15
-14
@@ -405,24 +405,24 @@ ALfloat *LoadBufferStatic(ALbufferlistitem *BufferListItem, ALbufferlistitem *&B
|
||||
BufferLoopItem = nullptr;
|
||||
|
||||
/* Load what's left to play from the buffer */
|
||||
const size_t DataSize{minz(SrcBuffer.size(), Buffer->SampleLen-DataPosInt)};
|
||||
const size_t DataRem{minz(SrcBuffer.size(), Buffer->SampleLen-DataPosInt)};
|
||||
|
||||
const al::byte *Data{Buffer->mData.data()};
|
||||
Data += (DataPosInt*NumChannels + chan)*SampleSize;
|
||||
|
||||
LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer->mFmtType, DataSize);
|
||||
SrcBuffer = SrcBuffer.subspan(DataSize);
|
||||
LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer->mFmtType, DataRem);
|
||||
SrcBuffer = SrcBuffer.subspan(DataRem);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Load what's left of this loop iteration */
|
||||
const size_t DataSize{minz(SrcBuffer.size(), LoopEnd-DataPosInt)};
|
||||
const size_t DataRem{minz(SrcBuffer.size(), LoopEnd-DataPosInt)};
|
||||
|
||||
const al::byte *Data{Buffer->mData.data()};
|
||||
Data += (DataPosInt*NumChannels + chan)*SampleSize;
|
||||
|
||||
LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer->mFmtType, DataSize);
|
||||
SrcBuffer = SrcBuffer.subspan(DataSize);
|
||||
LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer->mFmtType, DataRem);
|
||||
SrcBuffer = SrcBuffer.subspan(DataRem);
|
||||
|
||||
/* Load any repeats of the loop we can to fill the buffer. */
|
||||
const auto LoopSize = static_cast<size_t>(LoopEnd - LoopStart);
|
||||
@@ -430,8 +430,7 @@ ALfloat *LoadBufferStatic(ALbufferlistitem *BufferListItem, ALbufferlistitem *&B
|
||||
{
|
||||
const size_t DataSize{minz(SrcBuffer.size(), LoopSize)};
|
||||
|
||||
const al::byte *Data{Buffer->mData.data()};
|
||||
Data += (LoopStart*NumChannels + chan)*SampleSize;
|
||||
Data = Buffer->mData.data() + (LoopStart*NumChannels + chan)*SampleSize;
|
||||
|
||||
LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer->mFmtType, DataSize);
|
||||
SrcBuffer = SrcBuffer.subspan(DataSize);
|
||||
@@ -510,12 +509,14 @@ void ALvoice::mix(State vstate, ALCcontext *Context, const ALuint SamplesToDo)
|
||||
for(ALuint chan{0};chan < NumChannels;chan++)
|
||||
{
|
||||
ChannelData &chandata = mChans[chan];
|
||||
DirectParams &parms = chandata.mDryParams;
|
||||
if(!(mFlags&VOICE_HAS_HRTF))
|
||||
std::copy(std::begin(parms.Gains.Target), std::end(parms.Gains.Target),
|
||||
std::begin(parms.Gains.Current));
|
||||
else
|
||||
parms.Hrtf.Old = parms.Hrtf.Target;
|
||||
{
|
||||
DirectParams &parms = chandata.mDryParams;
|
||||
if(!(mFlags&VOICE_HAS_HRTF))
|
||||
std::copy(std::begin(parms.Gains.Target), std::end(parms.Gains.Target),
|
||||
std::begin(parms.Gains.Current));
|
||||
else
|
||||
parms.Hrtf.Old = parms.Hrtf.Target;
|
||||
}
|
||||
for(ALuint send{0};send < NumSends;++send)
|
||||
{
|
||||
if(mSend[send].Buffer.empty())
|
||||
|
||||
@@ -1737,7 +1737,7 @@ static int ProcessSources(TokenReaderT *tr, HrirDataT *hData)
|
||||
hData->mHrirsBase.resize(channels * hData->mIrCount * hData->mIrSize);
|
||||
double *hrirs = hData->mHrirsBase.data();
|
||||
std::vector<double> hrir(hData->mIrPoints);
|
||||
uint line, col, fi, ei, ai, ti;
|
||||
uint line, col, fi, ei, ai;
|
||||
int count;
|
||||
|
||||
printf("Loading sources...");
|
||||
@@ -1827,8 +1827,7 @@ static int ProcessSources(TokenReaderT *tr, HrirDataT *hData)
|
||||
for(fi = 0;fi < hData->mFdCount;fi++)
|
||||
{
|
||||
double delta = aer[2] - hData->mFds[fi].mDistance;
|
||||
if(std::abs(delta) < 0.001)
|
||||
break;
|
||||
if(std::abs(delta) < 0.001) break;
|
||||
}
|
||||
if(fi >= hData->mFdCount)
|
||||
continue;
|
||||
@@ -1892,7 +1891,6 @@ static int ProcessSources(TokenReaderT *tr, HrirDataT *hData)
|
||||
for(;;)
|
||||
{
|
||||
SourceRefT src;
|
||||
uint ti = 0;
|
||||
|
||||
if(!ReadSourceRef(tr, &src))
|
||||
return 0;
|
||||
@@ -1907,6 +1905,7 @@ static int ProcessSources(TokenReaderT *tr, HrirDataT *hData)
|
||||
if(!LoadSource(&src, hData->mIrRate, hData->mIrPoints, hrir.data()))
|
||||
return 0;
|
||||
|
||||
uint ti{0};
|
||||
if(hData->mChannelType == CT_STEREO)
|
||||
{
|
||||
char ident[MAX_IDENT_LEN+1];
|
||||
@@ -1976,7 +1975,7 @@ static int ProcessSources(TokenReaderT *tr, HrirDataT *hData)
|
||||
}
|
||||
}
|
||||
}
|
||||
for(ti = 0;ti < channels;ti++)
|
||||
for(uint ti{0};ti < channels;ti++)
|
||||
{
|
||||
for(fi = 0;fi < hData->mFdCount;fi++)
|
||||
{
|
||||
|
||||
@@ -101,7 +101,6 @@ static float GetUniformStepSize(const double epsilon, const uint m, const float
|
||||
{
|
||||
auto steps = std::vector<float>(m, 0.0f);
|
||||
auto counts = std::vector<uint>(m, 0u);
|
||||
float step{0.0f};
|
||||
uint count{0u};
|
||||
|
||||
for(uint stride{1u};stride < m/2;stride++)
|
||||
@@ -140,15 +139,12 @@ static float GetUniformStepSize(const double epsilon, const uint m, const float
|
||||
count = 1;
|
||||
|
||||
if(counts[0] > m/2)
|
||||
{
|
||||
step = steps[0];
|
||||
return step;
|
||||
}
|
||||
return steps[0];
|
||||
}
|
||||
|
||||
if(counts[0] > 5)
|
||||
step = steps[0];
|
||||
return step;
|
||||
return steps[0];
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
/* Attempts to produce a compatible layout. Most data sets tend to be
|
||||
|
||||
+3
-7
@@ -136,7 +136,6 @@ static float GetUniformStepSize(const float epsilon, const uint m, const float *
|
||||
{
|
||||
std::vector<float> steps(m, 0.0f);
|
||||
std::vector<uint> counts(m, 0u);
|
||||
float step{0.0f};
|
||||
uint count{0u};
|
||||
|
||||
for(uint stride{1u};stride < m/2;stride++)
|
||||
@@ -175,15 +174,12 @@ static float GetUniformStepSize(const float epsilon, const uint m, const float *
|
||||
count = 1;
|
||||
|
||||
if(counts[0] > m/2)
|
||||
{
|
||||
step = steps[0];
|
||||
return step;
|
||||
}
|
||||
return steps[0];
|
||||
}
|
||||
|
||||
if(counts[0] > 5)
|
||||
step = steps[0];
|
||||
return step;
|
||||
return steps[0];
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
/* Attempts to produce a compatible layout. Most data sets tend to be
|
||||
|
||||
Reference in New Issue
Block a user