chromium/media/filters/audio_renderer_algorithm_unittest.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// The format of these tests are to enqueue a known amount of data and then
// request the exact amount we expect in order to dequeue the known amount of
// data.  This ensures that for any rate we are consuming input data at the
// correct rate.  We always pass in a very large destination buffer with the
// expectation that FillBuffer() will fill as much as it can but no more.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "media/filters/audio_renderer_algorithm.h"

#include <stddef.h>
#include <stdint.h>

#include <algorithm>  // For std::min().
#include <cmath>
#include <memory>
#include <vector>

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "media/base/audio_buffer.h"
#include "media/base/audio_bus.h"
#include "media/base/audio_timestamp_helper.h"
#include "media/base/channel_layout.h"
#include "media/base/media_util.h"
#include "media/base/test_helpers.h"
#include "media/base/timestamp_constants.h"
#include "media/filters/wsola_internals.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace media {

const int kFrameSize =;
const int kSamplesPerSecond =;
const int kOutputDurationInSec =;

static void FillWithSquarePulseTrain(
    int half_pulse_width, int offset, int num_samples, float* data) {}

static void FillWithSquarePulseTrain(
    int half_pulse_width, int offset, int channel, AudioBus* audio_bus) {}

class AudioRendererAlgorithmTest : public testing::Test {};

TEST_F(AudioRendererAlgorithmTest, InitializeWithLargeParameters) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_Bitstream) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_NormalRate) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_NearlyNormalFasterRate) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_NearlyNormalSlowerRate) {}

// This test verifies that the resampling based time stretch algorithms works.
// The range of playback rates in which we use resampling is [0.95, 1.06].
TEST_F(AudioRendererAlgorithmTest, FillBuffer_ResamplingRates) {}

// This test verifies that we use the right underlying algorithms based on
// the preserves pitch flag and the playback rate.
TEST_F(AudioRendererAlgorithmTest, FillBuffer_FillModes) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_WithOffset) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_UnderFlow) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_OneAndAQuarterRate) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_OneAndAHalfRate) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_DoubleRate) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_EightTimesRate) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_ThreeQuartersRate) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_HalfRate) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_QuarterRate) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_Pause) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_SlowDown) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_SpeedUp) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_JumpAroundSpeeds) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_SmallBufferSize) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_LargeBufferSize) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_LowerQualityAudio) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_HigherQualityAudio) {}

TEST_F(AudioRendererAlgorithmTest, DotProduct) {}

TEST_F(AudioRendererAlgorithmTest, MovingBlockEnergy) {}

TEST_F(AudioRendererAlgorithmTest, FullAndDecimatedSearch) {}

TEST_F(AudioRendererAlgorithmTest, QuadraticInterpolation) {}

TEST_F(AudioRendererAlgorithmTest, QuadraticInterpolation_Colinear) {}

TEST_F(AudioRendererAlgorithmTest, WsolaSlowdown) {}

TEST_F(AudioRendererAlgorithmTest, WsolaSpeedup) {}

TEST_F(AudioRendererAlgorithmTest, FillBufferOffset) {}

TEST_F(AudioRendererAlgorithmTest, FillBuffer_ChannelMask) {}

// The |plabyack_threshold_| should == |capacity_| by default, when no
// |latency_hint_| is set.
TEST_F(AudioRendererAlgorithmTest, NoLatencyHint) {}

// The |playback_threshold_| should be < |capacity_| when a latency hint is
// set to reduce the playback delay.
TEST_F(AudioRendererAlgorithmTest, LowLatencyHint) {}

// Note: the behavior of FlushBuffers() that is not specific to high vs low
// latency hints. Testing it with "high" is slightly more interesting. Testing
// with both "high" and "low" is excessive.
TEST_F(AudioRendererAlgorithmTest, HighLatencyHint) {}

// Algorithm should clam specified hint to a reasonable min/max.
TEST_F(AudioRendererAlgorithmTest, ClampLatencyHint) {}

}  // namespace media