#include "third_party/blink/renderer/modules/webaudio/base_audio_context.h"
#include <algorithm>
#include "base/metrics/histogram_functions.h"
#include "build/build_config.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom-blink.h"
#include "third_party/blink/public/mojom/frame/lifecycle.mojom-shared.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_periodic_wave_constraints.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/html/media/html_media_element.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/modules/webaudio/analyser_node.h"
#include "third_party/blink/renderer/modules/webaudio/audio_buffer.h"
#include "third_party/blink/renderer/modules/webaudio/audio_buffer_source_node.h"
#include "third_party/blink/renderer/modules/webaudio/audio_context.h"
#include "third_party/blink/renderer/modules/webaudio/audio_graph_tracer.h"
#include "third_party/blink/renderer/modules/webaudio/audio_listener.h"
#include "third_party/blink/renderer/modules/webaudio/audio_node_input.h"
#include "third_party/blink/renderer/modules/webaudio/audio_node_output.h"
#include "third_party/blink/renderer/modules/webaudio/audio_worklet.h"
#include "third_party/blink/renderer/modules/webaudio/audio_worklet_global_scope.h"
#include "third_party/blink/renderer/modules/webaudio/audio_worklet_messaging_proxy.h"
#include "third_party/blink/renderer/modules/webaudio/biquad_filter_node.h"
#include "third_party/blink/renderer/modules/webaudio/channel_merger_node.h"
#include "third_party/blink/renderer/modules/webaudio/channel_splitter_node.h"
#include "third_party/blink/renderer/modules/webaudio/constant_source_node.h"
#include "third_party/blink/renderer/modules/webaudio/convolver_node.h"
#include "third_party/blink/renderer/modules/webaudio/cross_thread_audio_worklet_processor_info.h"
#include "third_party/blink/renderer/modules/webaudio/delay_node.h"
#include "third_party/blink/renderer/modules/webaudio/dynamics_compressor_node.h"
#include "third_party/blink/renderer/modules/webaudio/gain_node.h"
#include "third_party/blink/renderer/modules/webaudio/iir_filter_node.h"
#include "third_party/blink/renderer/modules/webaudio/inspector_web_audio_agent.h"
#include "third_party/blink/renderer/modules/webaudio/offline_audio_completion_event.h"
#include "third_party/blink/renderer/modules/webaudio/offline_audio_context.h"
#include "third_party/blink/renderer/modules/webaudio/offline_audio_destination_node.h"
#include "third_party/blink/renderer/modules/webaudio/oscillator_node.h"
#include "third_party/blink/renderer/modules/webaudio/panner_node.h"
#include "third_party/blink/renderer/modules/webaudio/periodic_wave.h"
#include "third_party/blink/renderer/modules/webaudio/realtime_audio_destination_node.h"
#include "third_party/blink/renderer/modules/webaudio/script_processor_node.h"
#include "third_party/blink/renderer/modules/webaudio/stereo_panner_node.h"
#include "third_party/blink/renderer/modules/webaudio/wave_shaper_node.h"
#include "third_party/blink/renderer/platform/audio/fft_frame.h"
#include "third_party/blink/renderer/platform/audio/hrtf_database_loader.h"
#include "third_party/blink/renderer/platform/audio/iir_filter.h"
#include "third_party/blink/renderer/platform/audio/vector_math.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/uuid.h"
namespace blink {
BaseAudioContext::BaseAudioContext(LocalDOMWindow* window,
enum ContextType context_type)
: … { … }
BaseAudioContext::~BaseAudioContext() { … }
void BaseAudioContext::Initialize() { … }
void BaseAudioContext::Clear() { … }
void BaseAudioContext::Uninitialize() { … }
void BaseAudioContext::Dispose() { … }
void BaseAudioContext::ContextLifecycleStateChanged(
mojom::FrameLifecycleState state) { … }
void BaseAudioContext::ContextDestroyed() { … }
bool BaseAudioContext::HasPendingActivity() const { … }
AudioDestinationNode* BaseAudioContext::destination() const { … }
void BaseAudioContext::WarnIfContextClosed(const AudioHandler* handler) const { … }
void BaseAudioContext::WarnForConnectionIfContextClosed() const { … }
AudioBuffer* BaseAudioContext::createBuffer(uint32_t number_of_channels,
uint32_t number_of_frames,
float sample_rate,
ExceptionState& exception_state) { … }
ScriptPromise<AudioBuffer> BaseAudioContext::decodeAudioData(
ScriptState* script_state,
DOMArrayBuffer* audio_data,
ExceptionState& exception_state) { … }
ScriptPromise<AudioBuffer> BaseAudioContext::decodeAudioData(
ScriptState* script_state,
DOMArrayBuffer* audio_data,
V8DecodeSuccessCallback* success_callback,
ExceptionState& exception_state) { … }
ScriptPromise<AudioBuffer> BaseAudioContext::decodeAudioData(
ScriptState* script_state,
DOMArrayBuffer* audio_data,
V8DecodeSuccessCallback* success_callback,
V8DecodeErrorCallback* error_callback,
ExceptionState& exception_state) { … }
void BaseAudioContext::HandleDecodeAudioData(
AudioBuffer* audio_buffer,
ScriptPromiseResolver<AudioBuffer>* resolver,
V8DecodeSuccessCallback* success_callback,
V8DecodeErrorCallback* error_callback,
ExceptionContext exception_context) { … }
AudioBufferSourceNode* BaseAudioContext::createBufferSource(
ExceptionState& exception_state) { … }
ConstantSourceNode* BaseAudioContext::createConstantSource(
ExceptionState& exception_state) { … }
ScriptProcessorNode* BaseAudioContext::createScriptProcessor(
ExceptionState& exception_state) { … }
ScriptProcessorNode* BaseAudioContext::createScriptProcessor(
uint32_t buffer_size,
ExceptionState& exception_state) { … }
ScriptProcessorNode* BaseAudioContext::createScriptProcessor(
uint32_t buffer_size,
uint32_t number_of_input_channels,
ExceptionState& exception_state) { … }
ScriptProcessorNode* BaseAudioContext::createScriptProcessor(
uint32_t buffer_size,
uint32_t number_of_input_channels,
uint32_t number_of_output_channels,
ExceptionState& exception_state) { … }
StereoPannerNode* BaseAudioContext::createStereoPanner(
ExceptionState& exception_state) { … }
BiquadFilterNode* BaseAudioContext::createBiquadFilter(
ExceptionState& exception_state) { … }
WaveShaperNode* BaseAudioContext::createWaveShaper(
ExceptionState& exception_state) { … }
PannerNode* BaseAudioContext::createPanner(ExceptionState& exception_state) { … }
ConvolverNode* BaseAudioContext::createConvolver(
ExceptionState& exception_state) { … }
DynamicsCompressorNode* BaseAudioContext::createDynamicsCompressor(
ExceptionState& exception_state) { … }
AnalyserNode* BaseAudioContext::createAnalyser(
ExceptionState& exception_state) { … }
GainNode* BaseAudioContext::createGain(ExceptionState& exception_state) { … }
DelayNode* BaseAudioContext::createDelay(ExceptionState& exception_state) { … }
DelayNode* BaseAudioContext::createDelay(double max_delay_time,
ExceptionState& exception_state) { … }
ChannelSplitterNode* BaseAudioContext::createChannelSplitter(
ExceptionState& exception_state) { … }
ChannelSplitterNode* BaseAudioContext::createChannelSplitter(
uint32_t number_of_outputs,
ExceptionState& exception_state) { … }
ChannelMergerNode* BaseAudioContext::createChannelMerger(
ExceptionState& exception_state) { … }
ChannelMergerNode* BaseAudioContext::createChannelMerger(
uint32_t number_of_inputs,
ExceptionState& exception_state) { … }
OscillatorNode* BaseAudioContext::createOscillator(
ExceptionState& exception_state) { … }
PeriodicWave* BaseAudioContext::createPeriodicWave(
const Vector<float>& real,
const Vector<float>& imag,
ExceptionState& exception_state) { … }
PeriodicWave* BaseAudioContext::createPeriodicWave(
const Vector<float>& real,
const Vector<float>& imag,
const PeriodicWaveConstraints* options,
ExceptionState& exception_state) { … }
IIRFilterNode* BaseAudioContext::createIIRFilter(
Vector<double> feedforward_coef,
Vector<double> feedback_coef,
ExceptionState& exception_state) { … }
PeriodicWave* BaseAudioContext::GetPeriodicWave(int type) { … }
String BaseAudioContext::state() const { … }
void BaseAudioContext::SetContextState(AudioContextState new_state) { … }
void BaseAudioContext::NotifyStateChange() { … }
void BaseAudioContext::NotifySourceNodeFinishedProcessing(
AudioHandler* handler) { … }
LocalDOMWindow* BaseAudioContext::GetWindow() const { … }
void BaseAudioContext::NotifySourceNodeStartedProcessing(AudioNode* node) { … }
void BaseAudioContext::ReleaseActiveSourceNodes() { … }
void BaseAudioContext::HandleStoppableSourceNodes() { … }
void BaseAudioContext::PerformCleanupOnMainThread() { … }
void BaseAudioContext::ScheduleMainThreadCleanup() { … }
void BaseAudioContext::RejectPendingDecodeAudioDataResolvers() { … }
void BaseAudioContext::RejectPendingResolvers() { … }
const AtomicString& BaseAudioContext::InterfaceName() const { … }
ExecutionContext* BaseAudioContext::GetExecutionContext() const { … }
void BaseAudioContext::StartRendering() { … }
void BaseAudioContext::Trace(Visitor* visitor) const { … }
const SecurityOrigin* BaseAudioContext::GetSecurityOrigin() const { … }
AudioWorklet* BaseAudioContext::audioWorklet() const { … }
void BaseAudioContext::NotifyWorkletIsReady() { … }
void BaseAudioContext::UpdateWorkletGlobalScopeOnRenderingThread() { … }
int32_t BaseAudioContext::MaxChannelCount() { … }
int32_t BaseAudioContext::CallbackBufferSize() { … }
void BaseAudioContext::ReportDidCreate() { … }
void BaseAudioContext::ReportWillBeDestroyed() { … }
bool BaseAudioContext::CheckExecutionContextAndThrowIfNecessary(
ExceptionState& exception_state) { … }
}