#include "content/renderer/media/renderer_webaudiodevice_impl.h"
#include <stddef.h>
#include <memory>
#include <string>
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/notreached.h"
#include "base/strings/stringprintf.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "content/public/renderer/render_frame.h"
#include "media/audio/null_audio_sink.h"
#include "media/base/audio_glitch_info.h"
#include "media/base/audio_timestamp_helper.h"
#include "media/base/limits.h"
#include "media/base/media_switches.h"
#include "media/base/output_device_info.h"
#include "media/base/silent_sink_suspender.h"
#include "media/base/speech_recognition_client.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/audio/web_audio_device_source_type.h"
#include "third_party/blink/public/platform/modules/webrtc/webrtc_logging.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/web/modules/media/audio/audio_device_factory.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_view.h"
AudioDeviceFactory;
WebAudioDevice;
WebAudioLatencyHint;
WebAudioSinkDescriptor;
WebLocalFrame;
WebView;
namespace content {
namespace {
blink::WebAudioDeviceSourceType GetLatencyHintSourceType(
WebAudioLatencyHint::AudioContextLatencyCategory latency_category) { … }
int GetOutputBufferSize(const blink::WebAudioLatencyHint& latency_hint,
media::AudioLatency::Type latency,
const media::AudioParameters& hardware_params) { … }
media::AudioParameters GetOutputDeviceParameters(
const blink::LocalFrameToken& frame_token,
const std::string& device_id) { … }
scoped_refptr<media::AudioRendererSink> GetNullAudioSink(
const scoped_refptr<base::SequencedTaskRunner>& task_runner) { … }
}
std::unique_ptr<RendererWebAudioDeviceImpl> RendererWebAudioDeviceImpl::Create(
const WebAudioSinkDescriptor& sink_descriptor,
int number_of_output_channels,
const blink::WebAudioLatencyHint& latency_hint,
media::AudioRendererSink::RenderCallback* callback) { … }
RendererWebAudioDeviceImpl::RendererWebAudioDeviceImpl(
const WebAudioSinkDescriptor& sink_descriptor,
media::ChannelLayoutConfig layout_config,
const blink::WebAudioLatencyHint& latency_hint,
media::AudioRendererSink::RenderCallback* callback,
OutputDeviceParamsCallback device_params_cb,
CreateSilentSinkCallback create_silent_sink_cb)
: … { … }
RendererWebAudioDeviceImpl::~RendererWebAudioDeviceImpl() { … }
void RendererWebAudioDeviceImpl::Start() { … }
void RendererWebAudioDeviceImpl::Pause() { … }
void RendererWebAudioDeviceImpl::Resume() { … }
void RendererWebAudioDeviceImpl::Stop() { … }
double RendererWebAudioDeviceImpl::SampleRate() { … }
int RendererWebAudioDeviceImpl::FramesPerBuffer() { … }
int RendererWebAudioDeviceImpl::MaxChannelCount() { … }
void RendererWebAudioDeviceImpl::SetDetectSilence(
bool enable_silence_detection) { … }
int RendererWebAudioDeviceImpl::Render(
base::TimeDelta delay,
base::TimeTicks delay_timestamp,
const media::AudioGlitchInfo& glitch_info,
media::AudioBus* dest) { … }
void RendererWebAudioDeviceImpl::OnRenderError() { … }
void RendererWebAudioDeviceImpl::NotifyRenderError() { … }
void RendererWebAudioDeviceImpl::SetSilentSinkTaskRunnerForTesting(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) { … }
scoped_refptr<base::SingleThreadTaskRunner>
RendererWebAudioDeviceImpl::GetSilentSinkTaskRunner() { … }
void RendererWebAudioDeviceImpl::SendLogMessage(const std::string& message) { … }
void RendererWebAudioDeviceImpl::CreateAudioRendererSink() { … }
media::OutputDeviceStatus
RendererWebAudioDeviceImpl::MaybeCreateSinkAndGetStatus() { … }
}