#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/modules/webaudio/audio_buffer_source_handler.h"
#include <algorithm>
#include "base/numerics/safe_conversions.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_audio_buffer_source_options.h"
#include "third_party/blink/renderer/modules/webaudio/audio_graph_tracer.h"
#include "third_party/blink/renderer/modules/webaudio/audio_node_output.h"
#include "third_party/blink/renderer/modules/webaudio/base_audio_context.h"
#include "third_party/blink/renderer/platform/audio/audio_utilities.h"
#include "third_party/blink/renderer/platform/bindings/exception_messages.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/fdlibm/ieee754.h"
namespace blink {
namespace {
constexpr double kDefaultGrainDuration = …;
constexpr double kMaxRate = …;
constexpr unsigned kDefaultNumberOfOutputChannels = …;
}
AudioBufferSourceHandler::AudioBufferSourceHandler(
AudioNode& node,
float sample_rate,
AudioParamHandler& playback_rate,
AudioParamHandler& detune)
: … { … }
scoped_refptr<AudioBufferSourceHandler> AudioBufferSourceHandler::Create(
AudioNode& node,
float sample_rate,
AudioParamHandler& playback_rate,
AudioParamHandler& detune) { … }
AudioBufferSourceHandler::~AudioBufferSourceHandler() { … }
void AudioBufferSourceHandler::Process(uint32_t frames_to_process) { … }
bool AudioBufferSourceHandler::RenderSilenceAndFinishIfNotLooping(
AudioBus*,
unsigned index,
uint32_t frames_to_process) { … }
bool AudioBufferSourceHandler::RenderFromBuffer(
AudioBus* bus,
unsigned destination_frame_offset,
uint32_t number_of_frames,
double start_time_offset) { … }
void AudioBufferSourceHandler::SetBuffer(AudioBuffer* buffer,
ExceptionState& exception_state) { … }
unsigned AudioBufferSourceHandler::NumberOfChannels() { … }
void AudioBufferSourceHandler::ClampGrainParameters(
const SharedAudioBuffer* buffer) { … }
base::WeakPtr<AudioScheduledSourceHandler>
AudioBufferSourceHandler::AsWeakPtr() { … }
void AudioBufferSourceHandler::Start(double when,
ExceptionState& exception_state) { … }
void AudioBufferSourceHandler::Start(double when,
double grain_offset,
ExceptionState& exception_state) { … }
void AudioBufferSourceHandler::Start(double when,
double grain_offset,
double grain_duration,
ExceptionState& exception_state) { … }
void AudioBufferSourceHandler::StartSource(double when,
double grain_offset,
double grain_duration,
bool is_duration_given,
ExceptionState& exception_state) { … }
void AudioBufferSourceHandler::SetLoop(bool looping) { … }
void AudioBufferSourceHandler::SetLoopStart(double loop_start) { … }
void AudioBufferSourceHandler::SetLoopEnd(double loop_end) { … }
double AudioBufferSourceHandler::ComputePlaybackRate() { … }
double AudioBufferSourceHandler::GetMinPlaybackRate() { … }
bool AudioBufferSourceHandler::PropagatesSilence() const { … }
void AudioBufferSourceHandler::HandleStoppableSourceNode() { … }
}