aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-05-19 05:46:01 -0700
committerChris Robinson <[email protected]>2014-05-19 05:46:01 -0700
commitcd983245f1967e04f833acc0ec27aefa94f061b0 (patch)
tree3bb462b9649026ac6676728d34b03f3737a8c740
parent8e04a8a0228aea5df0881f6b44d0fea61036d080 (diff)
Return a sample pointer from resamplers
Both resampling and filtering now avoid copying samples when they no-op.
-rw-r--r--Alc/mixer.c17
-rw-r--r--Alc/mixer_c.c15
-rw-r--r--Alc/mixer_defs.h8
-rw-r--r--OpenAL32/Include/alMain.h7
-rw-r--r--OpenAL32/Include/alu.h4
5 files changed, 27 insertions, 24 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c
index 86a0eef6..6ee76d1f 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -176,8 +176,8 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo)
for(chan = 0;chan < NumChannels;chan++)
{
- ALfloat *SrcData = Device->SampleData1;
- ALfloat *ResampledData = Device->SampleData2;
+ const ALfloat *ResampledData;
+ ALfloat *SrcData = Device->SourceData;
ALuint SrcDataSize = 0;
if(Source->SourceType == AL_STATIC)
@@ -341,16 +341,18 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo)
}
/* Now resample, then filter and mix to the appropriate outputs. */
- src->Resample(&SrcData[BufferPrePadding], DataPosFrac,
- increment, ResampledData, DstBufferSize);
-
+ ResampledData = src->Resample(
+ &SrcData[BufferPrePadding], DataPosFrac, increment,
+ Device->ResampledData, DstBufferSize
+ );
{
DirectParams *parms = &src->Direct;
const ALfloat *samples;
samples = DoFilters(
&parms->Filters[chan].LowPass, &parms->Filters[chan].HighPass,
- SrcData, ResampledData, DstBufferSize, parms->Filters[chan].ActiveType
+ Device->FilteredData, ResampledData, DstBufferSize,
+ parms->Filters[chan].ActiveType
);
if(!src->IsHrtf)
src->Dry.Mix(parms->OutBuffer, samples, &parms->Mix.Gains[chan],
@@ -375,7 +377,8 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo)
samples = DoFilters(
&parms->Filters[chan].LowPass, &parms->Filters[chan].HighPass,
- SrcData, ResampledData, DstBufferSize, parms->Filters[chan].ActiveType
+ Device->FilteredData, ResampledData, DstBufferSize,
+ parms->Filters[chan].ActiveType
);
src->WetMix(parms->OutBuffer, samples, &parms->Gain,
maxu(parms->Counter, OutPos) - OutPos,
diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c
index 4cc76a0f..389971e0 100644
--- a/Alc/mixer_c.c
+++ b/Alc/mixer_c.c
@@ -15,28 +15,27 @@ static inline ALfloat lerp32(const ALfloat *vals, ALuint frac)
static inline ALfloat cubic32(const ALfloat *vals, ALuint frac)
{ return cubic(vals[-1], vals[0], vals[1], vals[2], frac * (1.0f/FRACTIONONE)); }
-void Resample_copy32_C(const ALfloat *data, ALuint UNUSED(frac),
- ALuint increment, ALfloat *restrict OutBuffer, ALuint BufferSize)
+const ALfloat *Resample_copy32_C(const ALfloat *data, ALuint UNUSED(frac),
+ ALuint increment, ALfloat *restrict UNUSED(OutBuffer), ALuint UNUSED(BufferSize))
{
assert(increment==FRACTIONONE);
- memcpy(OutBuffer, data, BufferSize*sizeof(ALfloat));
+ return data;
}
#define DECL_TEMPLATE(Sampler) \
-void Resample_##Sampler##_C(const ALfloat *data, ALuint frac, \
+const ALfloat *Resample_##Sampler##_C(const ALfloat *data, ALuint frac, \
ALuint increment, ALfloat *restrict OutBuffer, ALuint BufferSize) \
{ \
- ALuint pos = 0; \
ALuint i; \
- \
for(i = 0;i < BufferSize;i++) \
{ \
- OutBuffer[i] = Sampler(data + pos, frac); \
+ OutBuffer[i] = Sampler(data, frac); \
\
frac += increment; \
- pos += frac>>FRACTIONBITS; \
+ data += frac>>FRACTIONBITS; \
frac &= FRACTIONMASK; \
} \
+ return OutBuffer; \
}
DECL_TEMPLATE(point32)
diff --git a/Alc/mixer_defs.h b/Alc/mixer_defs.h
index 130743c5..04fd1f53 100644
--- a/Alc/mixer_defs.h
+++ b/Alc/mixer_defs.h
@@ -12,10 +12,10 @@ struct HrtfParams;
struct HrtfState;
/* C resamplers */
-void Resample_copy32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen);
-void Resample_point32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen);
-void Resample_lerp32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen);
-void Resample_cubic32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen);
+const ALfloat *Resample_copy32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen);
+const ALfloat *Resample_point32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen);
+const ALfloat *Resample_lerp32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen);
+const ALfloat *Resample_cubic32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen);
/* C mixers */
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 2f1eb850..63787251 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -677,9 +677,10 @@ struct ALCdevice_struct
ALuint64 ClockBase;
ALuint SamplesDone;
- /* Temp storage used for mixing. */
- alignas(16) ALfloat SampleData1[BUFFERSIZE];
- alignas(16) ALfloat SampleData2[BUFFERSIZE];
+ /* Temp storage used for each source when mixing. */
+ alignas(16) ALfloat SourceData[BUFFERSIZE];
+ alignas(16) ALfloat ResampledData[BUFFERSIZE];
+ alignas(16) ALfloat FilteredData[BUFFERSIZE];
// Dry path buffer mix
alignas(16) ALfloat DryBuffer[MaxChannels][BUFFERSIZE];
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 7fdb75cc..df0e923d 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -120,8 +120,8 @@ typedef struct SendParams {
} SendParams;
-typedef void (*ResamplerFunc)(const ALfloat *src, ALuint frac, ALuint increment,
- ALfloat *restrict dst, ALuint dstlen);
+typedef const ALfloat* (*ResamplerFunc)(const ALfloat *src, ALuint frac, ALuint increment,
+ ALfloat *restrict dst, ALuint dstlen);
typedef void (*DryMixerFunc)(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
MixGains *Gains, ALuint Counter, ALuint OutPos,