Commit 589d63a3 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Fix 64 bit truncations in webaudio.

BUG=879657

Change-Id: I522fa35be26873436ed090990cbae1897acef6f7
Reviewed-on: https://chromium-review.googlesource.com/c/1355841Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612759}
parent 5ea7e168
......@@ -25,6 +25,7 @@
#include <algorithm>
#include "base/numerics/safe_conversions.h"
#include "third_party/blink/renderer/core/frame/use_counter.h"
#include "third_party/blink/renderer/modules/webaudio/audio_buffer_source_node.h"
#include "third_party/blink/renderer/modules/webaudio/audio_buffer_source_options.h"
......@@ -227,9 +228,10 @@ bool AudioBufferSourceHandler::RenderFromBuffer(
// Avoid converting from time to sample-frames twice by computing
// the grain end time first before computing the sample frame.
unsigned end_frame =
is_grain_ ? audio_utilities::TimeToSampleFrame(
grain_offset_ + grain_duration_, buffer_sample_rate)
: buffer_length;
is_grain_
? base::saturated_cast<uint32_t>(audio_utilities::TimeToSampleFrame(
grain_offset_ + grain_duration_, buffer_sample_rate))
: buffer_length;
// Do some sanity checking.
if (end_frame > buffer_length)
......
......@@ -204,7 +204,7 @@ void BaseAudioContext::ThrowExceptionForClosedState(
"AudioContext has been closed.");
}
AudioBuffer* BaseAudioContext::createBuffer(unsigned number_of_channels,
AudioBuffer* BaseAudioContext::createBuffer(uint32_t number_of_channels,
uint32_t number_of_frames,
float sample_rate,
ExceptionState& exception_state) {
......@@ -369,7 +369,7 @@ ScriptProcessorNode* BaseAudioContext::createScriptProcessor(
}
ScriptProcessorNode* BaseAudioContext::createScriptProcessor(
size_t buffer_size,
uint32_t buffer_size,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
......@@ -377,8 +377,8 @@ ScriptProcessorNode* BaseAudioContext::createScriptProcessor(
}
ScriptProcessorNode* BaseAudioContext::createScriptProcessor(
size_t buffer_size,
size_t number_of_input_channels,
uint32_t buffer_size,
uint32_t number_of_input_channels,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
......@@ -387,9 +387,9 @@ ScriptProcessorNode* BaseAudioContext::createScriptProcessor(
}
ScriptProcessorNode* BaseAudioContext::createScriptProcessor(
size_t buffer_size,
size_t number_of_input_channels,
size_t number_of_output_channels,
uint32_t buffer_size,
uint32_t number_of_input_channels,
uint32_t number_of_output_channels,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
......@@ -473,7 +473,7 @@ ChannelSplitterNode* BaseAudioContext::createChannelSplitter(
}
ChannelSplitterNode* BaseAudioContext::createChannelSplitter(
size_t number_of_outputs,
uint32_t number_of_outputs,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
......@@ -488,7 +488,7 @@ ChannelMergerNode* BaseAudioContext::createChannelMerger(
}
ChannelMergerNode* BaseAudioContext::createChannelMerger(
size_t number_of_inputs,
uint32_t number_of_inputs,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
......@@ -697,8 +697,8 @@ static bool IsAudible(const AudioBus* rendered_data) {
// for the total energy.
float energy = 0;
unsigned data_size = rendered_data->length();
for (unsigned k = 0; k < rendered_data->NumberOfChannels(); ++k) {
uint32_t data_size = rendered_data->length();
for (uint32_t k = 0; k < rendered_data->NumberOfChannels(); ++k) {
const float* data = rendered_data->Channel(k)->Data();
float channel_energy;
vector_math::Vsvesq(data, 1, &channel_energy, data_size);
......@@ -790,11 +790,11 @@ void BaseAudioContext::PerformCleanupOnMainThread() {
}
// Break the connection and release active nodes that have finished
// playing.
unsigned remove_count = 0;
wtf_size_t remove_count = 0;
Vector<bool> removables;
removables.resize(active_source_nodes_.size());
for (AudioHandler* handler : finished_handlers) {
for (unsigned i = 0; i < active_source_nodes_.size(); ++i) {
for (wtf_size_t i = 0; i < active_source_nodes_.size(); ++i) {
if (handler == &active_source_nodes_[i]->Handler()) {
handler->BreakConnectionWithLock();
removables[i] = true;
......@@ -808,11 +808,11 @@ void BaseAudioContext::PerformCleanupOnMainThread() {
if (remove_count > 0) {
HeapVector<Member<AudioNode>> actives;
DCHECK_GE(active_source_nodes_.size(), remove_count);
size_t initial_capacity =
wtf_size_t initial_capacity =
std::min(active_source_nodes_.size() - remove_count,
active_source_nodes_.size());
actives.ReserveInitialCapacity(initial_capacity);
for (unsigned i = 0; i < removables.size(); ++i) {
for (wtf_size_t i = 0; i < removables.size(); ++i) {
if (!removables[i])
actives.push_back(active_source_nodes_[i]);
}
......
......@@ -137,7 +137,7 @@ class MODULES_EXPORT BaseAudioContext
AudioContextState ContextState() const { return context_state_; }
void ThrowExceptionForClosedState(ExceptionState&);
AudioBuffer* createBuffer(unsigned number_of_channels,
AudioBuffer* createBuffer(uint32_t number_of_channels,
uint32_t number_of_frames,
float sample_rate,
ExceptionState&);
......@@ -184,21 +184,21 @@ class MODULES_EXPORT BaseAudioContext
DynamicsCompressorNode* createDynamicsCompressor(ExceptionState&);
AnalyserNode* createAnalyser(ExceptionState&);
ScriptProcessorNode* createScriptProcessor(ExceptionState&);
ScriptProcessorNode* createScriptProcessor(size_t buffer_size,
ScriptProcessorNode* createScriptProcessor(uint32_t buffer_size,
ExceptionState&);
ScriptProcessorNode* createScriptProcessor(size_t buffer_size,
size_t number_of_input_channels,
ScriptProcessorNode* createScriptProcessor(uint32_t buffer_size,
uint32_t number_of_input_channels,
ExceptionState&);
ScriptProcessorNode* createScriptProcessor(size_t buffer_size,
size_t number_of_input_channels,
size_t number_of_output_channels,
ScriptProcessorNode* createScriptProcessor(uint32_t buffer_size,
uint32_t number_of_input_channels,
uint32_t number_of_output_channels,
ExceptionState&);
StereoPannerNode* createStereoPanner(ExceptionState&);
ChannelSplitterNode* createChannelSplitter(ExceptionState&);
ChannelSplitterNode* createChannelSplitter(size_t number_of_outputs,
ChannelSplitterNode* createChannelSplitter(uint32_t number_of_outputs,
ExceptionState&);
ChannelMergerNode* createChannelMerger(ExceptionState&);
ChannelMergerNode* createChannelMerger(size_t number_of_inputs,
ChannelMergerNode* createChannelMerger(uint32_t number_of_inputs,
ExceptionState&);
OscillatorNode* createOscillator(ExceptionState&);
PeriodicWave* createPeriodicWave(const Vector<float>& real,
......@@ -255,7 +255,7 @@ class MODULES_EXPORT BaseAudioContext
using GraphAutoLocker = DeferredTaskHandler::GraphAutoLocker;
// Returns the maximum numuber of channels we can support.
static unsigned MaxNumberOfChannels() { return kMaxNumberOfChannels; }
static uint32_t MaxNumberOfChannels() { return kMaxNumberOfChannels; }
// EventTarget
const AtomicString& InterfaceName() const final;
......
......@@ -110,7 +110,7 @@ void ConvolverHandler::SetBuffer(AudioBuffer* buffer,
}
unsigned number_of_channels = buffer->numberOfChannels();
size_t buffer_length = buffer->length();
uint32_t buffer_length = buffer->length();
// The current implementation supports only 1-, 2-, or 4-channel impulse
// responses, with the 4-channel response being interpreted as true-stereo
......
......@@ -202,7 +202,7 @@ void DefaultAudioDestinationHandler::Render(
Context()->UpdateWorkletGlobalScopeOnRenderingThread();
}
size_t DefaultAudioDestinationHandler::GetCallbackBufferSize() const {
uint32_t DefaultAudioDestinationHandler::GetCallbackBufferSize() const {
DCHECK(IsMainThread());
DCHECK(IsInitialized());
......
......@@ -70,7 +70,7 @@ class DefaultAudioDestinationHandler final : public AudioDestinationHandler,
const AudioIOPosition& output_position) final;
// Returns a hadrware callback buffer size from audio infra.
size_t GetCallbackBufferSize() const;
uint32_t GetCallbackBufferSize() const;
// Returns a given frames-per-buffer size from audio infra.
int GetFramesPerBuffer() const;
......
......@@ -220,7 +220,7 @@ unsigned PeriodicWave::NumberOfPartialsForRange(unsigned range_index) const {
// Tell V8 about the memory we're using so it can properly schedule garbage
// collects.
void PeriodicWave::AdjustV8ExternalMemory(int delta) {
void PeriodicWave::AdjustV8ExternalMemory(int64_t delta) {
v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(delta);
v8_external_memory_ += delta;
}
......
......@@ -111,7 +111,7 @@ class PeriodicWave final : public ScriptWrappable {
unsigned NumberOfPartialsForRange(unsigned range_index) const;
void AdjustV8ExternalMemory(int delta);
void AdjustV8ExternalMemory(int64_t delta);
// Creates tables based on numberOfComponents Fourier coefficients.
void CreateBandLimitedTables(const float* real,
......
......@@ -46,9 +46,9 @@ namespace blink {
ScriptProcessorHandler::ScriptProcessorHandler(
AudioNode& node,
float sample_rate,
size_t buffer_size,
unsigned number_of_input_channels,
unsigned number_of_output_channels)
uint32_t buffer_size,
uint32_t number_of_input_channels,
uint32_t number_of_output_channels)
: AudioHandler(kNodeTypeScriptProcessor, node, sample_rate),
double_buffer_index_(0),
input_buffers_(MakeGarbageCollected<HeapVector<Member<AudioBuffer>>>()),
......@@ -85,9 +85,9 @@ ScriptProcessorHandler::ScriptProcessorHandler(
scoped_refptr<ScriptProcessorHandler> ScriptProcessorHandler::Create(
AudioNode& node,
float sample_rate,
size_t buffer_size,
unsigned number_of_input_channels,
unsigned number_of_output_channels) {
uint32_t buffer_size,
uint32_t number_of_input_channels,
uint32_t number_of_output_channels) {
return base::AdoptRef(new ScriptProcessorHandler(
node, sample_rate, buffer_size, number_of_input_channels,
number_of_output_channels));
......@@ -106,7 +106,7 @@ void ScriptProcessorHandler::Initialize() {
// Create double buffers on both the input and output sides.
// These AudioBuffers will be directly accessed in the main thread by
// JavaScript.
for (unsigned i = 0; i < 2; ++i) {
for (uint32_t i = 0; i < 2; ++i) {
AudioBuffer* input_buffer =
number_of_input_channels_
? AudioBuffer::Create(number_of_input_channels_, BufferSize(),
......@@ -140,7 +140,7 @@ void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
// Get input and output buffers. We double-buffer both the input and output
// sides.
unsigned double_buffer_index = this->DoubleBufferIndex();
uint32_t double_buffer_index = this->DoubleBufferIndex();
bool is_double_buffer_index_good =
double_buffer_index < 2 && double_buffer_index < input_buffers_->size() &&
double_buffer_index < output_buffers_->size();
......@@ -152,7 +152,7 @@ void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
AudioBuffer* output_buffer = output_buffers_->at(double_buffer_index).Get();
// Check the consistency of input and output buffers.
unsigned number_of_input_channels = internal_input_bus_->NumberOfChannels();
uint32_t number_of_input_channels = internal_input_bus_->NumberOfChannels();
bool buffers_are_good =
output_buffer && BufferSize() == output_buffer->length() &&
buffer_read_write_index_ + frames_to_process <= BufferSize();
......@@ -175,7 +175,7 @@ void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
if (!is_frames_to_process_good)
return;
unsigned number_of_output_channels = output_bus->NumberOfChannels();
uint32_t number_of_output_channels = output_bus->NumberOfChannels();
bool channels_are_good =
(number_of_input_channels == number_of_input_channels_) &&
......@@ -184,7 +184,7 @@ void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
if (!channels_are_good)
return;
for (unsigned i = 0; i < number_of_input_channels; ++i)
for (uint32_t i = 0; i < number_of_input_channels; ++i)
internal_input_bus_->SetChannelMemory(
i,
input_buffer->getChannelData(i).View()->Data() +
......@@ -195,7 +195,7 @@ void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
internal_input_bus_->CopyFrom(*input_bus);
// Copy from the output buffer to the output.
for (unsigned i = 0; i < number_of_output_channels; ++i) {
for (uint32_t i = 0; i < number_of_output_channels; ++i) {
memcpy(output_bus->Channel(i)->MutableData(),
output_buffer->getChannelData(i).View()->Data() +
buffer_read_write_index_,
......@@ -253,7 +253,7 @@ void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
}
}
void ScriptProcessorHandler::FireProcessEvent(unsigned double_buffer_index) {
void ScriptProcessorHandler::FireProcessEvent(uint32_t double_buffer_index) {
DCHECK(IsMainThread());
if (!Context() || !Context()->GetExecutionContext())
......@@ -288,7 +288,7 @@ void ScriptProcessorHandler::FireProcessEvent(unsigned double_buffer_index) {
}
void ScriptProcessorHandler::FireProcessEventForOfflineAudioContext(
unsigned double_buffer_index,
uint32_t double_buffer_index,
WaitableEvent* waitable_event) {
DCHECK(IsMainThread());
......@@ -334,7 +334,7 @@ double ScriptProcessorHandler::LatencyTime() const {
return std::numeric_limits<double>::infinity();
}
void ScriptProcessorHandler::SetChannelCount(unsigned channel_count,
void ScriptProcessorHandler::SetChannelCount(uint32_t channel_count,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
BaseAudioContext::GraphAutoLocker locker(Context());
......@@ -365,22 +365,22 @@ void ScriptProcessorHandler::SetChannelCountMode(
ScriptProcessorNode::ScriptProcessorNode(BaseAudioContext& context,
float sample_rate,
size_t buffer_size,
unsigned number_of_input_channels,
unsigned number_of_output_channels)
uint32_t buffer_size,
uint32_t number_of_input_channels,
uint32_t number_of_output_channels)
: AudioNode(context) {
SetHandler(ScriptProcessorHandler::Create(*this, sample_rate, buffer_size,
number_of_input_channels,
number_of_output_channels));
}
static size_t ChooseBufferSize(size_t callback_buffer_size) {
static uint32_t ChooseBufferSize(uint32_t callback_buffer_size) {
// Choose a buffer size based on the audio hardware buffer size. Arbitarily
// make it a power of two that is 4 times greater than the hardware buffer
// size.
// TODO(crbug.com/855758): What is the best way to choose this?
size_t buffer_size =
1 << static_cast<unsigned>(log2(4 * callback_buffer_size) + 0.5);
uint32_t buffer_size =
1 << static_cast<uint32_t>(log2(4 * callback_buffer_size) + 0.5);
if (buffer_size < 256)
return 256;
......@@ -402,7 +402,7 @@ ScriptProcessorNode* ScriptProcessorNode::Create(
ScriptProcessorNode* ScriptProcessorNode::Create(
BaseAudioContext& context,
size_t requested_buffer_size,
uint32_t requested_buffer_size,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
......@@ -412,8 +412,8 @@ ScriptProcessorNode* ScriptProcessorNode::Create(
ScriptProcessorNode* ScriptProcessorNode::Create(
BaseAudioContext& context,
size_t requested_buffer_size,
unsigned number_of_input_channels,
uint32_t requested_buffer_size,
uint32_t number_of_input_channels,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
......@@ -424,9 +424,9 @@ ScriptProcessorNode* ScriptProcessorNode::Create(
ScriptProcessorNode* ScriptProcessorNode::Create(
BaseAudioContext& context,
size_t requested_buffer_size,
unsigned number_of_input_channels,
unsigned number_of_output_channels,
uint32_t requested_buffer_size,
uint32_t number_of_input_channels,
uint32_t number_of_output_channels,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
......@@ -461,7 +461,7 @@ ScriptProcessorNode* ScriptProcessorNode::Create(
}
// Sanitize user-supplied buffer size.
size_t buffer_size;
uint32_t buffer_size;
switch (requested_buffer_size) {
case 0:
// Choose an appropriate size. For an AudioContext, we need to
......
......@@ -54,52 +54,52 @@ class ScriptProcessorHandler final : public AudioHandler {
static scoped_refptr<ScriptProcessorHandler> Create(
AudioNode&,
float sample_rate,
size_t buffer_size,
unsigned number_of_input_channels,
unsigned number_of_output_channels);
uint32_t buffer_size,
uint32_t number_of_input_channels,
uint32_t number_of_output_channels);
~ScriptProcessorHandler() override;
// AudioHandler
void Process(uint32_t frames_to_process) override;
void Initialize() override;
uint32_t BufferSize() const { return static_cast<uint32_t>(buffer_size_); }
uint32_t BufferSize() const { return buffer_size_; }
void SetChannelCount(unsigned, ExceptionState&) override;
void SetChannelCount(uint32_t, ExceptionState&) override;
void SetChannelCountMode(const String&, ExceptionState&) override;
unsigned NumberOfOutputChannels() const override {
uint32_t NumberOfOutputChannels() const override {
return number_of_output_channels_;
}
private:
ScriptProcessorHandler(AudioNode&,
float sample_rate,
size_t buffer_size,
unsigned number_of_input_channels,
unsigned number_of_output_channels);
uint32_t buffer_size,
uint32_t number_of_input_channels,
uint32_t number_of_output_channels);
double TailTime() const override;
double LatencyTime() const override;
bool RequiresTailProcessing() const final;
void FireProcessEvent(unsigned);
void FireProcessEventForOfflineAudioContext(unsigned, WaitableEvent*);
void FireProcessEvent(uint32_t);
void FireProcessEventForOfflineAudioContext(uint32_t, WaitableEvent*);
// Double buffering
unsigned DoubleBufferIndex() const { return double_buffer_index_; }
uint32_t DoubleBufferIndex() const { return double_buffer_index_; }
void SwapBuffers() { double_buffer_index_ = 1 - double_buffer_index_; }
unsigned double_buffer_index_;
uint32_t double_buffer_index_;
// These Persistent don't make reference cycles including the owner
// ScriptProcessorNode.
CrossThreadPersistent<HeapVector<Member<AudioBuffer>>> input_buffers_;
CrossThreadPersistent<HeapVector<Member<AudioBuffer>>> output_buffers_;
size_t buffer_size_;
unsigned buffer_read_write_index_;
uint32_t buffer_size_;
uint32_t buffer_read_write_index_;
unsigned number_of_input_channels_;
unsigned number_of_output_channels_;
uint32_t number_of_input_channels_;
uint32_t number_of_output_channels_;
scoped_refptr<AudioBus> internal_input_bus_;
// Synchronize process() with fireProcessEvent().
......@@ -127,23 +127,23 @@ class ScriptProcessorNode final
// The value chosen must carefully balance between latency and audio quality.
static ScriptProcessorNode* Create(BaseAudioContext&, ExceptionState&);
static ScriptProcessorNode* Create(BaseAudioContext&,
size_t requested_buffer_size,
uint32_t requested_buffer_size,
ExceptionState&);
static ScriptProcessorNode* Create(BaseAudioContext&,
size_t requested_buffer_size,
unsigned number_of_input_channels,
uint32_t requested_buffer_size,
uint32_t number_of_input_channels,
ExceptionState&);
static ScriptProcessorNode* Create(BaseAudioContext&,
size_t requested_buffer_size,
unsigned number_of_input_channels,
unsigned number_of_output_channels,
uint32_t requested_buffer_size,
uint32_t number_of_input_channels,
uint32_t number_of_output_channels,
ExceptionState&);
ScriptProcessorNode(BaseAudioContext&,
float sample_rate,
size_t buffer_size,
unsigned number_of_input_channels,
unsigned number_of_output_channels);
uint32_t buffer_size,
uint32_t number_of_input_channels,
uint32_t number_of_output_channels);
DEFINE_ATTRIBUTE_EVENT_LISTENER(audioprocess, kAudioprocess);
uint32_t bufferSize() const;
......
......@@ -49,7 +49,7 @@ using namespace vector_math;
const unsigned kMaxBusChannels = 32;
scoped_refptr<AudioBus> AudioBus::Create(unsigned number_of_channels,
size_t length,
uint32_t length,
bool allocate) {
DCHECK_LE(number_of_channels, kMaxBusChannels);
if (number_of_channels > kMaxBusChannels)
......@@ -58,7 +58,7 @@ scoped_refptr<AudioBus> AudioBus::Create(unsigned number_of_channels,
return base::AdoptRef(new AudioBus(number_of_channels, length, allocate));
}
AudioBus::AudioBus(unsigned number_of_channels, size_t length, bool allocate)
AudioBus::AudioBus(unsigned number_of_channels, uint32_t length, bool allocate)
: length_(length), sample_rate_(0) {
channels_.ReserveInitialCapacity(number_of_channels);
......@@ -74,7 +74,7 @@ AudioBus::AudioBus(unsigned number_of_channels, size_t length, bool allocate)
void AudioBus::SetChannelMemory(unsigned channel_index,
float* storage,
size_t length) {
uint32_t length) {
if (channel_index < channels_.size()) {
Channel(channel_index)->Set(storage, length);
// FIXME: verify that this length matches all the other channel lengths
......@@ -82,7 +82,7 @@ void AudioBus::SetChannelMemory(unsigned channel_index,
}
}
void AudioBus::ResizeSmaller(size_t new_length) {
void AudioBus::ResizeSmaller(uint32_t new_length) {
DCHECK_LE(new_length, length_);
if (new_length <= length_)
length_ = new_length;
......@@ -190,7 +190,7 @@ scoped_refptr<AudioBus> AudioBus::CreateBufferFromRange(
const AudioBus* source_buffer,
unsigned start_frame,
unsigned end_frame) {
size_t number_of_source_frames = source_buffer->length();
uint32_t number_of_source_frames = source_buffer->length();
unsigned number_of_channels = source_buffer->NumberOfChannels();
// Sanity checking
......@@ -200,7 +200,7 @@ scoped_refptr<AudioBus> AudioBus::CreateBufferFromRange(
if (!is_range_safe)
return nullptr;
size_t range_length = end_frame - start_frame;
uint32_t range_length = end_frame - start_frame;
scoped_refptr<AudioBus> audio_bus = Create(number_of_channels, range_length);
audio_bus->SetSampleRate(source_buffer->SampleRate());
......
......@@ -70,11 +70,13 @@ class PLATFORM_EXPORT AudioBus : public ThreadSafeRefCounted<AudioBus> {
// is false then setChannelMemory() has to be called later on for each
// channel before the AudioBus is useable...
static scoped_refptr<AudioBus> Create(unsigned number_of_channels,
size_t length,
uint32_t length,
bool allocate = true);
// Tells the given channel to use an externally allocated buffer.
void SetChannelMemory(unsigned channel_index, float* storage, size_t length);
void SetChannelMemory(unsigned channel_index,
float* storage,
uint32_t length);
// Channels
unsigned NumberOfChannels() const { return channels_.size(); }
......@@ -87,11 +89,11 @@ class PLATFORM_EXPORT AudioBus : public ThreadSafeRefCounted<AudioBus> {
const AudioChannel* ChannelByType(unsigned type) const;
// Number of sample-frames
size_t length() const { return length_; }
uint32_t length() const { return length_; }
// resizeSmaller() can only be called with a new length <= the current length.
// The data stored in the bus will remain undisturbed.
void ResizeSmaller(size_t new_length);
void ResizeSmaller(uint32_t new_length);
// Sample-rate : 0.0 if unknown or "don't care"
float SampleRate() const { return sample_rate_; }
......@@ -167,7 +169,7 @@ class PLATFORM_EXPORT AudioBus : public ThreadSafeRefCounted<AudioBus> {
protected:
AudioBus() = default;
AudioBus(unsigned number_of_channels, size_t length, bool allocate);
AudioBus(unsigned number_of_channels, uint32_t length, bool allocate);
void DiscreteSumFrom(const AudioBus&);
......@@ -176,7 +178,7 @@ class PLATFORM_EXPORT AudioBus : public ThreadSafeRefCounted<AudioBus> {
void SumFromByUpMixing(const AudioBus&);
void SumFromByDownMixing(const AudioBus&);
size_t length_;
uint32_t length_;
Vector<std::unique_ptr<AudioChannel>> channels_;
int layout_;
float sample_rate_; // 0.0 if unknown or N/A
......
......@@ -246,7 +246,7 @@ void AudioDestination::Resume() {
}
}
size_t AudioDestination::CallbackBufferSize() const {
uint32_t AudioDestination::CallbackBufferSize() const {
DCHECK(IsMainThread());
return callback_buffer_size_;
}
......
......@@ -99,7 +99,7 @@ class PLATFORM_EXPORT AudioDestination
scoped_refptr<base::SingleThreadTaskRunner> worklet_task_runner);
// Getters must be accessed from the main thread.
size_t CallbackBufferSize() const;
uint32_t CallbackBufferSize() const;
bool IsPlaying();
// TODO(hongchan): this should not be called by the rendering thread.
......@@ -124,7 +124,7 @@ class PLATFORM_EXPORT AudioDestination
// Accessed by the main thread.
std::unique_ptr<WebAudioDevice> web_audio_device_;
const unsigned number_of_output_channels_;
size_t callback_buffer_size_;
uint32_t callback_buffer_size_;
PlayState play_state_;
// The task runner for AudioWorklet operation. This is only valid when
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment