Loading media/libaaudio/src/Android.bp +13 −1 Original line number Diff line number Diff line Loading @@ -207,10 +207,14 @@ cc_library { "binding/RingBufferParcelable.cpp", "binding/SharedMemoryParcelable.cpp", "binding/SharedRegionParcelable.cpp", "flowgraph/AudioProcessorBase.cpp", "flowgraph/ChannelCountConverter.cpp", "flowgraph/ClipToRange.cpp", "flowgraph/FlowGraphNode.cpp", "flowgraph/ManyToMultiConverter.cpp", "flowgraph/MonoToMultiConverter.cpp", "flowgraph/MultiToMonoConverter.cpp", "flowgraph/RampLinear.cpp", "flowgraph/SampleRateConverter.cpp", "flowgraph/SinkFloat.cpp", "flowgraph/SinkI16.cpp", "flowgraph/SinkI24.cpp", Loading @@ -219,6 +223,14 @@ cc_library { "flowgraph/SourceI16.cpp", "flowgraph/SourceI24.cpp", "flowgraph/SourceI32.cpp", "flowgraph/resampler/IntegerRatio.cpp", "flowgraph/resampler/LinearResampler.cpp", "flowgraph/resampler/MultiChannelResampler.cpp", "flowgraph/resampler/PolyphaseResampler.cpp", "flowgraph/resampler/PolyphaseResamplerMono.cpp", "flowgraph/resampler/PolyphaseResamplerStereo.cpp", "flowgraph/resampler/SincResampler.cpp", "flowgraph/resampler/SincResamplerStereo.cpp", ], sanitize: { integer_overflow: true, Loading media/libaaudio/src/client/AAudioFlowGraph.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ aaudio_result_t AAudioFlowGraph::configure(audio_format_t sourceFormat, int32_t sourceChannelCount, audio_format_t sinkFormat, int32_t sinkChannelCount) { AudioFloatOutputPort *lastOutput = nullptr; FlowGraphPortFloatOutput *lastOutput = nullptr; // TODO change back to ALOGD ALOGI("%s() source format = 0x%08x, channels = %d, sink format = 0x%08x, channels = %d", Loading media/libaaudio/src/client/AAudioFlowGraph.h +5 −5 Original line number Diff line number Diff line Loading @@ -53,11 +53,11 @@ public: void setRampLengthInFrames(int32_t numFrames); private: std::unique_ptr<flowgraph::AudioSource> mSource; std::unique_ptr<flowgraph::FlowGraphSourceBuffered> mSource; std::unique_ptr<flowgraph::RampLinear> mVolumeRamp; std::unique_ptr<flowgraph::ClipToRange> mClipper; std::unique_ptr<flowgraph::MonoToMultiConverter> mChannelConverter; std::unique_ptr<flowgraph::AudioSink> mSink; std::unique_ptr<flowgraph::FlowGraphSink> mSink; }; Loading media/libaaudio/src/flowgraph/ChannelCountConverter.cpp 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <unistd.h> #include "FlowGraphNode.h" #include "ChannelCountConverter.h" using namespace flowgraph; ChannelCountConverter::ChannelCountConverter( int32_t inputChannelCount, int32_t outputChannelCount) : input(*this, inputChannelCount) , output(*this, outputChannelCount) { } ChannelCountConverter::~ChannelCountConverter() = default; int32_t ChannelCountConverter::onProcess(int32_t numFrames) { const float *inputBuffer = input.getBuffer(); float *outputBuffer = output.getBuffer(); int32_t inputChannelCount = input.getSamplesPerFrame(); int32_t outputChannelCount = output.getSamplesPerFrame(); for (int i = 0; i < numFrames; i++) { int inputChannel = 0; for (int outputChannel = 0; outputChannel < outputChannelCount; outputChannel++) { // Copy input channels to output channels. // Wrap if we run out of inputs. // Discard if we run out of outputs. outputBuffer[outputChannel] = inputBuffer[inputChannel]; inputChannel = (inputChannel == inputChannelCount) ? 0 : inputChannel + 1; } inputBuffer += inputChannelCount; outputBuffer += outputChannelCount; } return numFrames; } media/libaaudio/src/flowgraph/ChannelCountConverter.h 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef FLOWGRAPH_CHANNEL_COUNT_CONVERTER_H #define FLOWGRAPH_CHANNEL_COUNT_CONVERTER_H #include <unistd.h> #include <sys/types.h> #include "FlowGraphNode.h" namespace flowgraph { /** * Change the number of number of channels without mixing. * When increasing the channel count, duplicate input channels. * When decreasing the channel count, drop input channels. */ class ChannelCountConverter : public FlowGraphNode { public: explicit ChannelCountConverter( int32_t inputChannelCount, int32_t outputChannelCount); virtual ~ChannelCountConverter(); int32_t onProcess(int32_t numFrames) override; const char *getName() override { return "ChannelCountConverter"; } FlowGraphPortFloatInput input; FlowGraphPortFloatOutput output; }; } /* namespace flowgraph */ #endif //FLOWGRAPH_CHANNEL_COUNT_CONVERTER_H Loading
media/libaaudio/src/Android.bp +13 −1 Original line number Diff line number Diff line Loading @@ -207,10 +207,14 @@ cc_library { "binding/RingBufferParcelable.cpp", "binding/SharedMemoryParcelable.cpp", "binding/SharedRegionParcelable.cpp", "flowgraph/AudioProcessorBase.cpp", "flowgraph/ChannelCountConverter.cpp", "flowgraph/ClipToRange.cpp", "flowgraph/FlowGraphNode.cpp", "flowgraph/ManyToMultiConverter.cpp", "flowgraph/MonoToMultiConverter.cpp", "flowgraph/MultiToMonoConverter.cpp", "flowgraph/RampLinear.cpp", "flowgraph/SampleRateConverter.cpp", "flowgraph/SinkFloat.cpp", "flowgraph/SinkI16.cpp", "flowgraph/SinkI24.cpp", Loading @@ -219,6 +223,14 @@ cc_library { "flowgraph/SourceI16.cpp", "flowgraph/SourceI24.cpp", "flowgraph/SourceI32.cpp", "flowgraph/resampler/IntegerRatio.cpp", "flowgraph/resampler/LinearResampler.cpp", "flowgraph/resampler/MultiChannelResampler.cpp", "flowgraph/resampler/PolyphaseResampler.cpp", "flowgraph/resampler/PolyphaseResamplerMono.cpp", "flowgraph/resampler/PolyphaseResamplerStereo.cpp", "flowgraph/resampler/SincResampler.cpp", "flowgraph/resampler/SincResamplerStereo.cpp", ], sanitize: { integer_overflow: true, Loading
media/libaaudio/src/client/AAudioFlowGraph.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ aaudio_result_t AAudioFlowGraph::configure(audio_format_t sourceFormat, int32_t sourceChannelCount, audio_format_t sinkFormat, int32_t sinkChannelCount) { AudioFloatOutputPort *lastOutput = nullptr; FlowGraphPortFloatOutput *lastOutput = nullptr; // TODO change back to ALOGD ALOGI("%s() source format = 0x%08x, channels = %d, sink format = 0x%08x, channels = %d", Loading
media/libaaudio/src/client/AAudioFlowGraph.h +5 −5 Original line number Diff line number Diff line Loading @@ -53,11 +53,11 @@ public: void setRampLengthInFrames(int32_t numFrames); private: std::unique_ptr<flowgraph::AudioSource> mSource; std::unique_ptr<flowgraph::FlowGraphSourceBuffered> mSource; std::unique_ptr<flowgraph::RampLinear> mVolumeRamp; std::unique_ptr<flowgraph::ClipToRange> mClipper; std::unique_ptr<flowgraph::MonoToMultiConverter> mChannelConverter; std::unique_ptr<flowgraph::AudioSink> mSink; std::unique_ptr<flowgraph::FlowGraphSink> mSink; }; Loading
media/libaaudio/src/flowgraph/ChannelCountConverter.cpp 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <unistd.h> #include "FlowGraphNode.h" #include "ChannelCountConverter.h" using namespace flowgraph; ChannelCountConverter::ChannelCountConverter( int32_t inputChannelCount, int32_t outputChannelCount) : input(*this, inputChannelCount) , output(*this, outputChannelCount) { } ChannelCountConverter::~ChannelCountConverter() = default; int32_t ChannelCountConverter::onProcess(int32_t numFrames) { const float *inputBuffer = input.getBuffer(); float *outputBuffer = output.getBuffer(); int32_t inputChannelCount = input.getSamplesPerFrame(); int32_t outputChannelCount = output.getSamplesPerFrame(); for (int i = 0; i < numFrames; i++) { int inputChannel = 0; for (int outputChannel = 0; outputChannel < outputChannelCount; outputChannel++) { // Copy input channels to output channels. // Wrap if we run out of inputs. // Discard if we run out of outputs. outputBuffer[outputChannel] = inputBuffer[inputChannel]; inputChannel = (inputChannel == inputChannelCount) ? 0 : inputChannel + 1; } inputBuffer += inputChannelCount; outputBuffer += outputChannelCount; } return numFrames; }
media/libaaudio/src/flowgraph/ChannelCountConverter.h 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef FLOWGRAPH_CHANNEL_COUNT_CONVERTER_H #define FLOWGRAPH_CHANNEL_COUNT_CONVERTER_H #include <unistd.h> #include <sys/types.h> #include "FlowGraphNode.h" namespace flowgraph { /** * Change the number of number of channels without mixing. * When increasing the channel count, duplicate input channels. * When decreasing the channel count, drop input channels. */ class ChannelCountConverter : public FlowGraphNode { public: explicit ChannelCountConverter( int32_t inputChannelCount, int32_t outputChannelCount); virtual ~ChannelCountConverter(); int32_t onProcess(int32_t numFrames) override; const char *getName() override { return "ChannelCountConverter"; } FlowGraphPortFloatInput input; FlowGraphPortFloatOutput output; }; } /* namespace flowgraph */ #endif //FLOWGRAPH_CHANNEL_COUNT_CONVERTER_H