diff options
author | Chris Robinson <[email protected]> | 2019-08-07 11:43:53 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-08-07 11:43:53 -0700 |
commit | 5b33b4aa970b9ec7791d3cee34fe107038e7a8ca (patch) | |
tree | d120cf800b788c880bba25420fc4687d768b1f04 /alc | |
parent | 7c069e29ee721b2d1294dea72aa48d73d45d2009 (diff) |
Make the post-process methods member functions
Diffstat (limited to 'alc')
-rw-r--r-- | alc/alcmain.h | 13 | ||||
-rw-r--r-- | alc/alu.cpp | 44 | ||||
-rw-r--r-- | alc/alu.h | 5 | ||||
-rw-r--r-- | alc/panning.cpp | 10 |
4 files changed, 35 insertions, 37 deletions
diff --git a/alc/alcmain.h b/alc/alcmain.h index 464febcc..910e3279 100644 --- a/alc/alcmain.h +++ b/alc/alcmain.h @@ -188,8 +188,6 @@ struct RealMixParams { al::span<FloatBufferLine> Buffer; }; -using POSTPROCESS = void(*)(ALCdevice *device, const ALsizei SamplesToDo); - enum { // Frequency was requested by the app or config file FrequencyRequest, @@ -305,7 +303,8 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> { /* Stereo-to-binaural filter */ std::unique_ptr<bs2b> Bs2b; - POSTPROCESS PostProcess{}; + using PostProc = void(ALCdevice::*)(const ALsizei SamplesToDo); + PostProc PostProcess{nullptr}; std::unique_ptr<FrontStablizer> Stablizer; @@ -345,6 +344,14 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> { ALsizei channelsFromFmt() const noexcept { return ChannelsFromDevFmt(FmtChans, mAmbiOrder); } ALsizei frameSizeFromFmt() const noexcept { return bytesFromFmt() * channelsFromFmt(); } + void ProcessHrtf(const ALsizei SamplesToDo); + void ProcessAmbiDec(const ALsizei SamplesToDo); + void ProcessUhj(const ALsizei SamplesToDo); + void ProcessBs2b(const ALsizei SamplesToDo); + + inline void postProcess(const ALsizei SamplesToDo) + { if LIKELY(PostProcess) (this->*PostProcess)(SamplesToDo); } + DEF_NEWDEL(ALCdevice) }; diff --git a/alc/alu.cpp b/alc/alu.cpp index b50927e2..8cef4228 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -147,51 +147,47 @@ void aluInit(void) } -void ProcessHrtf(ALCdevice *device, const ALsizei SamplesToDo) +void ALCdevice::ProcessHrtf(const ALsizei SamplesToDo) { /* HRTF is stereo output only. */ - const int lidx{device->RealOut.ChannelIndex[FrontLeft]}; - const int ridx{device->RealOut.ChannelIndex[FrontRight]}; + const int lidx{RealOut.ChannelIndex[FrontLeft]}; + const int ridx{RealOut.ChannelIndex[FrontRight]}; ASSUME(lidx >= 0 && ridx >= 0); - DirectHrtfState *state{device->mHrtfState.get()}; - MixDirectHrtf(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx], device->Dry.Buffer, - device->HrtfAccumData, state, SamplesToDo); + MixDirectHrtf(RealOut.Buffer[lidx], RealOut.Buffer[ridx], Dry.Buffer, HrtfAccumData, + mHrtfState.get(), SamplesToDo); } -void ProcessAmbiDec(ALCdevice *device, const ALsizei SamplesToDo) +void ALCdevice::ProcessAmbiDec(const ALsizei SamplesToDo) { - BFormatDec *ambidec{device->AmbiDecoder.get()}; - ambidec->process(device->RealOut.Buffer, device->Dry.Buffer.data(), SamplesToDo); + AmbiDecoder->process(RealOut.Buffer, Dry.Buffer.data(), SamplesToDo); } -void ProcessUhj(ALCdevice *device, const ALsizei SamplesToDo) +void ALCdevice::ProcessUhj(const ALsizei SamplesToDo) { /* UHJ is stereo output only. */ - const int lidx{device->RealOut.ChannelIndex[FrontLeft]}; - const int ridx{device->RealOut.ChannelIndex[FrontRight]}; + const int lidx{RealOut.ChannelIndex[FrontLeft]}; + const int ridx{RealOut.ChannelIndex[FrontRight]}; ASSUME(lidx >= 0 && ridx >= 0); /* Encode to stereo-compatible 2-channel UHJ output. */ - Uhj2Encoder *uhj2enc{device->Uhj_Encoder.get()}; - uhj2enc->encode(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx], - device->Dry.Buffer.data(), SamplesToDo); + Uhj_Encoder->encode(RealOut.Buffer[lidx], RealOut.Buffer[ridx], Dry.Buffer.data(), + SamplesToDo); } -void ProcessBs2b(ALCdevice *device, const ALsizei SamplesToDo) +void ALCdevice::ProcessBs2b(const ALsizei SamplesToDo) { /* First, decode the ambisonic mix to the "real" output. */ - BFormatDec *ambidec{device->AmbiDecoder.get()}; - ambidec->process(device->RealOut.Buffer, device->Dry.Buffer.data(), SamplesToDo); + AmbiDecoder->process(RealOut.Buffer, Dry.Buffer.data(), SamplesToDo); /* BS2B is stereo output only. */ - const int lidx{device->RealOut.ChannelIndex[FrontLeft]}; - const int ridx{device->RealOut.ChannelIndex[FrontRight]}; + const int lidx{RealOut.ChannelIndex[FrontLeft]}; + const int ridx{RealOut.ChannelIndex[FrontRight]}; ASSUME(lidx >= 0 && ridx >= 0); /* Now apply the BS2B binaural/crossfeed filter. */ - bs2b_cross_feed(device->Bs2b.get(), device->RealOut.Buffer[lidx].data(), - device->RealOut.Buffer[ridx].data(), SamplesToDo); + bs2b_cross_feed(Bs2b.get(), RealOut.Buffer[lidx].data(), RealOut.Buffer[ridx].data(), + SamplesToDo); } @@ -1665,8 +1661,8 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples) /* Apply any needed post-process for finalizing the Dry mix to the * RealOut (Ambisonic decode, UHJ encode, etc). */ - if LIKELY(device->PostProcess) - device->PostProcess(device, SamplesToDo); + device->postProcess(SamplesToDo); + const al::span<FloatBufferLine> RealOut{device->RealOut.Buffer}; /* Apply front image stablization for surround sound, if applicable. */ @@ -380,11 +380,6 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr void aluInitEffectPanning(ALeffectslot *slot, ALCdevice *device); -void ProcessHrtf(ALCdevice *device, const ALsizei SamplesToDo); -void ProcessAmbiDec(ALCdevice *device, const ALsizei SamplesToDo); -void ProcessUhj(ALCdevice *device, const ALsizei SamplesToDo); -void ProcessBs2b(ALCdevice *device, const ALsizei SamplesToDo); - /** * Calculates ambisonic encoder coefficients using the X, Y, and Z direction * components, which must represent a normalized (unit length) vector, and the diff --git a/alc/panning.cpp b/alc/panning.cpp index 55af4747..d946d1fc 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -721,7 +721,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr InitCustomPanning(device, !!hqdec, pconf, speakermap); } if(device->AmbiDecoder) - device->PostProcess = ProcessAmbiDec; + device->PostProcess = &ALCdevice::ProcessAmbiDec; return; } @@ -802,7 +802,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr old_hrtf = nullptr; InitHrtfPanning(device); - device->PostProcess = ProcessHrtf; + device->PostProcess = &ALCdevice::ProcessHrtf; return; } device->HrtfStatus = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; @@ -824,7 +824,7 @@ no_hrtf: bs2b_set_params(device->Bs2b.get(), *cflevopt, device->Frequency); TRACE("BS2B enabled\n"); InitPanning(device); - device->PostProcess = ProcessBs2b; + device->PostProcess = &ALCdevice::ProcessBs2b; return; } } @@ -843,13 +843,13 @@ no_hrtf: device->Uhj_Encoder = al::make_unique<Uhj2Encoder>(); TRACE("UHJ enabled\n"); InitUhjPanning(device); - device->PostProcess = ProcessUhj; + device->PostProcess = &ALCdevice::ProcessUhj; return; } TRACE("Stereo rendering\n"); InitPanning(device); - device->PostProcess = ProcessAmbiDec; + device->PostProcess = &ALCdevice::ProcessAmbiDec; } |