[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/google/oboe/main/tests/testStreamFramesProcessed.cpp [Back]  [Original]

/*
 * 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 
#include 

#include 

using namespace oboe;

class FramesProcessedCallback : public AudioStreamDataCallback {
public:
    DataCallbackResult onAudioReady(AudioStream *oboeStream, void *audioData, int32_t numFrames) override {
        return DataCallbackResult::Continue;
    }
};

using StreamFramesProcessedParams = std::tuple;

class StreamFramesProcessed : public ::testing::Test,
                              public ::testing::WithParamInterface {

protected:
    void TearDown() override;

    static constexpr int PROCESS_TIME_SECONDS = 5;

    AudioStreamBuilder mBuilder;
    std::shared_ptr mStream;
};

void StreamFramesProcessed::TearDown() {
    if (mStream) {
        mStream->close();
    }
}

TEST_P(StreamFramesProcessed, VerifyFramesProcessed) {
    const Direction direction = std::get(GetParam());
    const int32_t sampleRate = std::get(GetParam());
    const bool useOboeSampleRateConversion = std::get(GetParam());

    SampleRateConversionQuality srcQuality = useOboeSampleRateConversion ?
            SampleRateConversionQuality::Medium : SampleRateConversionQuality::None;

    AudioStreamDataCallback *callback = new FramesProcessedCallback();
    mBuilder.setDirection(direction)
            ->setFormat(AudioFormat::I16)
            ->setSampleRate(sampleRate)
            ->setSampleRateConversionQuality(srcQuality)
            ->setPerformanceMode(PerformanceMode::LowLatency)
            ->setSharingMode(SharingMode::Exclusive)
            ->setDataCallback(callback);
    Result r = mBuilder.openStream(mStream);
    ASSERT_EQ(r, Result::OK) 

Web Proxy Viewer  |  New URL  |  Original Page