#include "media/renderers/audio_renderer_impl.h"
#include <math.h>
#include <stddef.h>
#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/power_monitor/power_monitor.h"
#include "base/ranges/algorithm.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/default_tick_clock.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "media/audio/null_audio_sink.h"
#include "media/base/audio_buffer.h"
#include "media/base/audio_buffer_converter.h"
#include "media/base/audio_latency.h"
#include "media/base/audio_parameters.h"
#include "media/base/channel_mixing_matrix.h"
#include "media/base/demuxer_stream.h"
#include "media/base/media_client.h"
#include "media/base/media_log.h"
#include "media/base/media_switches.h"
#include "media/base/media_util.h"
#include "media/base/renderer_client.h"
#include "media/base/timestamp_constants.h"
#include "media/filters/audio_clock.h"
#include "media/filters/decrypting_demuxer_stream.h"
namespace media {
AudioRendererImpl::AudioRendererImpl(
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
AudioRendererSink* sink,
const CreateAudioDecodersCB& create_audio_decoders_cb,
MediaLog* media_log,
MediaPlayerLoggingID media_player_id,
SpeechRecognitionClient* speech_recognition_client)
: … { … }
AudioRendererImpl::~AudioRendererImpl() { … }
void AudioRendererImpl::StartTicking() { … }
void AudioRendererImpl::StartRendering_Locked() { … }
void AudioRendererImpl::StopTicking() { … }
void AudioRendererImpl::StopRendering_Locked() { … }
void AudioRendererImpl::SetMediaTime(base::TimeDelta time) { … }
base::TimeDelta AudioRendererImpl::CurrentMediaTime() { … }
bool AudioRendererImpl::GetWallClockTimes(
const std::vector<base::TimeDelta>& media_timestamps,
std::vector<base::TimeTicks>* wall_clock_times) { … }
TimeSource* AudioRendererImpl::GetTimeSource() { … }
void AudioRendererImpl::Flush(base::OnceClosure callback) { … }
void AudioRendererImpl::DoFlush_Locked() { … }
void AudioRendererImpl::ResetDecoderDone() { … }
void AudioRendererImpl::StartPlaying() { … }
void AudioRendererImpl::Initialize(DemuxerStream* stream,
CdmContext* cdm_context,
RendererClient* client,
PipelineStatusCallback init_cb) { … }
void AudioRendererImpl::OnDeviceInfoReceived(
DemuxerStream* stream,
CdmContext* cdm_context,
OutputDeviceInfo output_device_info) { … }
void AudioRendererImpl::OnAudioDecoderStreamInitialized(bool success) { … }
void AudioRendererImpl::FinishInitialization(PipelineStatus status) { … }
void AudioRendererImpl::FinishFlush() { … }
void AudioRendererImpl::OnPlaybackError(PipelineStatus error) { … }
void AudioRendererImpl::OnPlaybackEnded() { … }
void AudioRendererImpl::OnStatisticsUpdate(const PipelineStatistics& stats) { … }
void AudioRendererImpl::OnBufferingStateChange(BufferingState buffering_state) { … }
void AudioRendererImpl::OnWaiting(WaitingReason reason) { … }
void AudioRendererImpl::SetVolume(float volume) { … }
void AudioRendererImpl::SetLatencyHint(
std::optional<base::TimeDelta> latency_hint) { … }
void AudioRendererImpl::SetPreservesPitch(bool preserves_pitch) { … }
void AudioRendererImpl::SetWasPlayedWithUserActivation(
bool was_played_with_user_activation) { … }
void AudioRendererImpl::OnSuspend() { … }
void AudioRendererImpl::OnResume() { … }
void AudioRendererImpl::SetPlayDelayCBForTesting(PlayDelayCBForTesting cb) { … }
void AudioRendererImpl::DecodedAudioReady(
AudioDecoderStream::ReadResult result) { … }
bool AudioRendererImpl::HandleDecodedBuffer_Locked(
scoped_refptr<AudioBuffer> buffer) { … }
void AudioRendererImpl::AttemptRead() { … }
void AudioRendererImpl::AttemptRead_Locked() { … }
bool AudioRendererImpl::CanRead_Locked() { … }
void AudioRendererImpl::SetPlaybackRate(double playback_rate) { … }
bool AudioRendererImpl::IsBeforeStartTime(const AudioBuffer& buffer) { … }
int AudioRendererImpl::Render(base::TimeDelta delay,
base::TimeTicks delay_timestamp,
const AudioGlitchInfo& glitch_info,
AudioBus* audio_bus) { … }
void AudioRendererImpl::OnRenderError() { … }
void AudioRendererImpl::HandleAbortedReadOrDecodeError(PipelineStatus status) { … }
void AudioRendererImpl::ChangeState_Locked(State new_state) { … }
void AudioRendererImpl::OnConfigChange(const AudioDecoderConfig& config) { … }
void AudioRendererImpl::SetBufferingState_Locked(
BufferingState buffering_state) { … }
void AudioRendererImpl::ConfigureChannelMask() { … }
void AudioRendererImpl::EnableSpeechRecognition() { … }
void AudioRendererImpl::TranscribeAudio(
scoped_refptr<media::AudioBuffer> buffer) { … }
base::TimeDelta AudioRendererImpl::CalculateClockAndAlgorithmDrift() const { … }
}