From 6c655321e6b04b8648802e296bb5ca11d290ae68 Mon Sep 17 00:00:00 2001 From: swurl Date: Sat, 31 May 2025 02:33:02 -0400 Subject: Move dead submodules in-tree Signed-off-by: swurl --- .../app/src/main/cpp/FormatConverterBox.cpp | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 externals/oboe/apps/OboeTester/app/src/main/cpp/FormatConverterBox.cpp (limited to 'externals/oboe/apps/OboeTester/app/src/main/cpp/FormatConverterBox.cpp') diff --git a/externals/oboe/apps/OboeTester/app/src/main/cpp/FormatConverterBox.cpp b/externals/oboe/apps/OboeTester/app/src/main/cpp/FormatConverterBox.cpp new file mode 100644 index 0000000000..f380d0a04a --- /dev/null +++ b/externals/oboe/apps/OboeTester/app/src/main/cpp/FormatConverterBox.cpp @@ -0,0 +1,107 @@ +/* + * Copyright 2021 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 "FormatConverterBox.h" + +FormatConverterBox::FormatConverterBox(int32_t maxSamples, + oboe::AudioFormat inputFormat, + oboe::AudioFormat outputFormat) { + mInputFormat = inputFormat; + mOutputFormat = outputFormat; + + mMaxSamples = maxSamples; + mInputBuffer = std::make_unique(maxSamples * sizeof(int32_t)); + mOutputBuffer = std::make_unique(maxSamples * sizeof(int32_t)); + + mSource.reset(); + switch (mInputFormat) { + case oboe::AudioFormat::I16: + case oboe::AudioFormat::IEC61937: + mSource = std::make_unique(1); + break; + case oboe::AudioFormat::I24: + mSource = std::make_unique(1); + break; + case oboe::AudioFormat::I32: + mSource = std::make_unique(1); + break; + case oboe::AudioFormat::Float: + case oboe::AudioFormat::Invalid: + case oboe::AudioFormat::Unspecified: + mSource = std::make_unique(1); + break; + case oboe::AudioFormat::MP3: + case oboe::AudioFormat::AAC_LC: + case oboe::AudioFormat::AAC_HE_V1: + case oboe::AudioFormat::AAC_HE_V2: + case oboe::AudioFormat::AAC_ELD: + case oboe::AudioFormat::AAC_XHE: + case oboe::AudioFormat::OPUS: + break; + } + + mSink.reset(); + switch (mOutputFormat) { + case oboe::AudioFormat::I16: + case oboe::AudioFormat::IEC61937: + mSink = std::make_unique(1); + break; + case oboe::AudioFormat::I24: + mSink = std::make_unique(1); + break; + case oboe::AudioFormat::I32: + mSink = std::make_unique(1); + break; + case oboe::AudioFormat::Float: + case oboe::AudioFormat::Invalid: + case oboe::AudioFormat::Unspecified: + mSink = std::make_unique(1); + break; + case oboe::AudioFormat::MP3: + case oboe::AudioFormat::AAC_LC: + case oboe::AudioFormat::AAC_HE_V1: + case oboe::AudioFormat::AAC_HE_V2: + case oboe::AudioFormat::AAC_ELD: + case oboe::AudioFormat::AAC_XHE: + case oboe::AudioFormat::OPUS: + break; + } + + if (mSource && mSink) { + mSource->output.connect(&mSink->input); + mSink->pullReset(); + } +} + +int32_t FormatConverterBox::convertInternalBuffers(int32_t numSamples) { + assert(numSamples <= mMaxSamples); + return convert(getOutputBuffer(), numSamples, getInputBuffer()); +} + +int32_t FormatConverterBox::convertToInternalOutput(int32_t numSamples, const void *inputBuffer) { + assert(numSamples <= mMaxSamples); + return convert(getOutputBuffer(), numSamples, inputBuffer); +} + +int32_t FormatConverterBox::convertFromInternalInput(void *outputBuffer, int32_t numSamples) { + assert(numSamples <= mMaxSamples); + return convert(outputBuffer, numSamples, getInputBuffer()); +} + +int32_t FormatConverterBox::convert(void *outputBuffer, int32_t numSamples, const void *inputBuffer) { + mSource->setData(inputBuffer, numSamples); + return mSink->read(outputBuffer, numSamples); +} -- cgit v1.2.3