#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/filters/audio_renderer_algorithm.h"
#include <algorithm>
#include <cmath>
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "cc/base/math_util.h"
#include "media/base/audio_bus.h"
#include "media/base/audio_timestamp_helper.h"
#include "media/base/limits.h"
#include "media/base/media_switches.h"
#include "media/filters/wsola_internals.h"
namespace media {
constexpr base::TimeDelta kOlaWindowSize = …;
constexpr base::TimeDelta kWsolaSearchInterval = …;
constexpr base::TimeDelta kMaxCapacity = …;
constexpr base::TimeDelta kStartingCapacity = …;
constexpr base::TimeDelta kMinStartingCapacityForEncrypted = …;
AudioRendererAlgorithm::AudioRendererAlgorithm(MediaLog* media_log)
: … { … }
AudioRendererAlgorithm::AudioRendererAlgorithm(
MediaLog* media_log,
AudioRendererAlgorithmParameters params)
: … { … }
AudioRendererAlgorithm::~AudioRendererAlgorithm() = default;
void AudioRendererAlgorithm::Initialize(const AudioParameters& params,
bool is_encrypted) { … }
void AudioRendererAlgorithm::SetChannelMask(std::vector<bool> channel_mask) { … }
void AudioRendererAlgorithm::OnResamplerRead(int frame_delay,
AudioBus* audio_bus) { … }
void AudioRendererAlgorithm::MarkEndOfStream() { … }
int AudioRendererAlgorithm::ResampleAndFill(AudioBus* dest,
int dest_offset,
int requested_frames,
double playback_rate) { … }
int AudioRendererAlgorithm::RunWsolaAndFill(AudioBus* dest,
int dest_offset,
int requested_frames,
double playback_rate) { … }
int AudioRendererAlgorithm::FillBuffer(AudioBus* dest,
int dest_offset,
int requested_frames,
double playback_rate) { … }
AudioRendererAlgorithm::FillBufferMode AudioRendererAlgorithm::ChooseBufferMode(
double playback_rate) { … }
void AudioRendererAlgorithm::SetFillBufferMode(FillBufferMode mode) { … }
void AudioRendererAlgorithm::FlushBuffers() { … }
void AudioRendererAlgorithm::EnqueueBuffer(
scoped_refptr<AudioBuffer> buffer_in) { … }
void AudioRendererAlgorithm::SetLatencyHint(
std::optional<base::TimeDelta> latency_hint) { … }
bool AudioRendererAlgorithm::IsQueueAdequateForPlayback() { … }
bool AudioRendererAlgorithm::IsQueueFull() { … }
void AudioRendererAlgorithm::IncreasePlaybackThreshold() { … }
int64_t AudioRendererAlgorithm::GetMemoryUsage() const { … }
int AudioRendererAlgorithm::BufferedFrames() const { … }
double AudioRendererAlgorithm::DelayInFrames(double playback_rate) const { … }
std::optional<base::TimeDelta> AudioRendererAlgorithm::FrontTimestamp() const { … }
bool AudioRendererAlgorithm::CanPerformWsola() const { … }
bool AudioRendererAlgorithm::RunOneWsolaIteration(double playback_rate) { … }
void AudioRendererAlgorithm::UpdateOutputTime(double playback_rate,
double time_change) { … }
void AudioRendererAlgorithm::RemoveOldInputFrames(double playback_rate) { … }
int AudioRendererAlgorithm::WriteCompletedFramesTo(
int requested_frames, int dest_offset, AudioBus* dest) { … }
bool AudioRendererAlgorithm::TargetIsWithinSearchRegion() const { … }
void AudioRendererAlgorithm::GetOptimalBlock() { … }
void AudioRendererAlgorithm::PeekAudioWithZeroPrepend(
int read_offset_frames, AudioBus* dest) { … }
void AudioRendererAlgorithm::CreateSearchWrappers() { … }
void AudioRendererAlgorithm::SetPreservesPitch(bool preserves_pitch) { … }
}