chromium/media/renderers/audio_renderer_impl_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.

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

#include "media/renderers/audio_renderer_impl.h"

#include <memory>
#include <utility>
#include <vector>

#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "media/base/audio_buffer_converter.h"
#include "media/base/audio_bus.h"
#include "media/base/fake_audio_renderer_sink.h"
#include "media/base/media_client.h"
#include "media/base/media_switches.h"
#include "media/base/media_util.h"
#include "media/base/mock_audio_renderer_sink.h"
#include "media/base/mock_filters.h"
#include "media/base/mock_media_log.h"
#include "media/base/speech_recognition_client.h"
#include "media/base/test_helpers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

TimeDelta;
RunCallback;
RunOnceCallback;
_;
DoAll;
Return;
SaveArg;

namespace media {

namespace {

// Since AudioBufferConverter is used due to different input/output sample
// rates, define some helper types to differentiate between the two.
struct InputFrames {};

struct OutputFrames {};

}  // namespace

// Constants to specify the type of audio data used.
constexpr AudioCodec kCodec =;
constexpr SampleFormat kSampleFormat =;
constexpr ChannelLayout kChannelLayout =;
constexpr int kChannels =;

// Use a different output sample rate so the AudioBufferConverter is invoked.
constexpr int kInputSamplesPerSecond =;
constexpr int kOutputSamplesPerSecond =;
constexpr double kOutputMicrosPerFrame =;

// Arbitrarily chosen frame count for a typical input audio buffer.
// NOTE: Do not assume that N InputFrames in translates to N OutputFrames.
// Format differences between "in" vs "out" (reconciled by AudioBufferConverter)
// will cause the N InputFrames to generate M OutputFrames, such that N and M
// may be off by a significant factor.
constexpr int kInputFramesChunk =;

ACTION_P(EnterPendingDecoderInitStateAction, test) {}

ACTION_P(AssertNotYetEnded, test) {}

class AudioRendererImplTest : public ::testing::Test,
                              public RendererClient,
                              public SpeechRecognitionClient {};

TEST_F(AudioRendererImplTest, Initialize_Successful) {}

TEST_F(AudioRendererImplTest, Initialize_DecoderInitFailure) {}

TEST_F(AudioRendererImplTest, ReinitializeForDifferentStream) {}

TEST_F(AudioRendererImplTest, SignalConfigChange) {}

TEST_F(AudioRendererImplTest, Preroll) {}

TEST_F(AudioRendererImplTest, StartTicking) {}

TEST_F(AudioRendererImplTest, EndOfStream) {}

TEST_F(AudioRendererImplTest, DecoderUnderflow) {}

TEST_F(AudioRendererImplTest, DemuxerUnderflow) {}

TEST_F(AudioRendererImplTest, Underflow_CapacityResetsAfterFlush) {}

TEST_F(AudioRendererImplTest, Underflow_CapacityIncreasesBeforeHaveNothing) {}

TEST_F(AudioRendererImplTest, Underflow_OneCapacityIncreasePerUnderflow) {}

// Verify that the proper reduced search space is configured for playback rate
// changes when upmixing is applied to the input.
TEST_F(AudioRendererImplTest, ChannelMask) {}

// Verify that the proper channel mask is configured when downmixing is applied
// to the input with discrete layout. The default hardware layout is stereo.
TEST_F(AudioRendererImplTest, ChannelMask_DownmixDiscreteLayout) {}

TEST_F(AudioRendererImplTest, Underflow_Flush) {}

TEST_F(AudioRendererImplTest, PendingRead_Flush) {}

TEST_F(AudioRendererImplTest, PendingRead_Destroy) {}

TEST_F(AudioRendererImplTest, PendingFlush_Destroy) {}

TEST_F(AudioRendererImplTest, InitializeThenDestroy) {}

TEST_F(AudioRendererImplTest, InitializeThenDestroyDuringDecoderInit) {}

TEST_F(AudioRendererImplTest, CurrentMediaTimeBehavior) {}

TEST_F(AudioRendererImplTest, RenderingDelayedForEarlyStartTime) {}

TEST_F(AudioRendererImplTest, RenderingDelayedForSuspend) {}

TEST_F(AudioRendererImplTest, AbsurdRenderingDelayLog) {}

TEST_F(AudioRendererImplTest, RenderingDelayDoesNotOverflow) {}

TEST_F(AudioRendererImplTest, ImmediateEndOfStream) {}

TEST_F(AudioRendererImplTest, OnRenderErrorCausesDecodeError) {}

// Test for AudioRendererImpl calling Pause()/Play() on the sink when the
// playback rate is set to zero and non-zero.
TEST_F(AudioRendererImplTest, SetPlaybackRate) {}

TEST_F(AudioRendererImplTest, TimeSourceBehavior) {}

TEST_F(AudioRendererImplTest, MultipleRateChangesKeepSync) {}

TEST_F(AudioRendererImplTest, BitstreamEndOfStream) {}

TEST_F(AudioRendererImplTest, MutedPlaybackBadDeviceInfo) {}

TEST_F(AudioRendererImplTest, BasicMutedPlayback) {}

TEST_F(AudioRendererImplTest, SinkIsFlushed) {}

TEST_F(AudioRendererImplTest, LowLatencyHint) {}

TEST_F(AudioRendererImplTest, HighLatencyHint) {}

TEST_F(AudioRendererImplTest, PlayUnmuted) {}

TEST_F(AudioRendererImplTest, UnmuteWhilePlaying) {}

TEST_F(AudioRendererImplTest, DecodeAudioReadyPreemptsFlush) {}

#if !BUILDFLAG(IS_ANDROID)
TEST_F(AudioRendererImplTest,
       TranscribeAudioCallback_SpeechRecognitionDisabled) {}

TEST_F(AudioRendererImplTest,
       TranscribeAudioCallback_Muted_WithoutUserActivation) {}

TEST_F(AudioRendererImplTest,
       TranscribeAudioCallback_Unmuted_WithoutUserActivation) {}

TEST_F(AudioRendererImplTest,
       TranscribeAudioCallback_Muted_WithUserActivation) {}
#endif

}  // namespace media