Commit ef6017ef authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Fix some 64 bit truncations in webaudio.

Channel count in the IDL is a 32 bit integer. Ensure we use that
and not a 64 bit integer in C++.

BUG=879657

Change-Id: I6415d2d0965f8b4dbd2aa79d831ef8dfc1f49038
Reviewed-on: https://chromium-review.googlesource.com/c/1348969Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611370}
parent 857bec79
......@@ -48,7 +48,7 @@ AudioDestinationHandler& AudioDestinationNode::GetAudioDestinationHandler()
return static_cast<AudioDestinationHandler&>(Handler());
}
unsigned long AudioDestinationNode::maxChannelCount() const {
uint32_t AudioDestinationNode::maxChannelCount() const {
return GetAudioDestinationHandler().MaxChannelCount();
}
......
......@@ -62,7 +62,7 @@ class AudioDestinationHandler : public AudioHandler {
}
virtual double SampleRate() const = 0;
virtual unsigned long MaxChannelCount() const = 0;
virtual uint32_t MaxChannelCount() const = 0;
void ContextDestroyed() { is_execution_context_destroyed_ = true; }
bool IsExecutionContextDestroyed() const {
......@@ -92,7 +92,7 @@ class AudioDestinationNode : public AudioNode {
DEFINE_WRAPPERTYPEINFO();
public:
unsigned long maxChannelCount() const;
uint32_t maxChannelCount() const;
// Returns its own handler object instead of a generic one from
// AudioNode::Handler().
......
......@@ -199,7 +199,7 @@ AudioNodeOutput& AudioHandler::Output(unsigned i) {
return *outputs_[i];
}
unsigned long AudioHandler::ChannelCount() {
unsigned AudioHandler::ChannelCount() {
return channel_count_;
}
......@@ -214,7 +214,7 @@ void AudioHandler::SetInternalChannelInterpretation(
new_channel_interpretation_ = interpretation;
}
void AudioHandler::SetChannelCount(unsigned long channel_count,
void AudioHandler::SetChannelCount(unsigned channel_count,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
BaseAudioContext::GraphAutoLocker locker(Context());
......@@ -1023,11 +1023,11 @@ unsigned AudioNode::numberOfOutputs() const {
return Handler().NumberOfOutputs();
}
unsigned long AudioNode::channelCount() const {
unsigned AudioNode::channelCount() const {
return Handler().ChannelCount();
}
void AudioNode::setChannelCount(unsigned long count,
void AudioNode::setChannelCount(unsigned count,
ExceptionState& exception_state) {
Handler().SetChannelCount(count, exception_state);
}
......
......@@ -222,8 +222,8 @@ class MODULES_EXPORT AudioHandler : public ThreadSafeRefCounted<AudioHandler> {
void DisableOutputsIfNecessary();
void DisableOutputs();
unsigned long ChannelCount();
virtual void SetChannelCount(unsigned long, ExceptionState&);
unsigned ChannelCount();
virtual void SetChannelCount(unsigned, ExceptionState&);
String GetChannelCountMode();
virtual void SetChannelCountMode(const String&, ExceptionState&);
......@@ -339,8 +339,8 @@ class MODULES_EXPORT AudioNode : public EventTargetWithInlineData {
BaseAudioContext* context() const;
unsigned numberOfInputs() const;
unsigned numberOfOutputs() const;
unsigned long channelCount() const;
void setChannelCount(unsigned long, ExceptionState&);
unsigned channelCount() const;
void setChannelCount(unsigned, ExceptionState&);
String channelCountMode() const;
void setChannelCountMode(const String&, ExceptionState&);
String channelInterpretation() const;
......
......@@ -26,7 +26,7 @@ class AudioParamMap final : public ScriptWrappable,
const HeapHashMap<String, Member<AudioParam>>& parameter_map);
// IDL attributes / methods
size_t size() const { return parameter_map_.size(); }
uint32_t size() const { return parameter_map_.size(); }
AudioParam* At(String name) { return parameter_map_.at(name); }
bool Contains(String name) { return parameter_map_.Contains(name); }
......
......@@ -94,7 +94,7 @@ void ChannelMergerHandler::Process(size_t frames_to_process) {
}
}
void ChannelMergerHandler::SetChannelCount(unsigned long channel_count,
void ChannelMergerHandler::SetChannelCount(unsigned channel_count,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
BaseAudioContext::GraphAutoLocker locker(Context());
......
......@@ -44,7 +44,7 @@ class ChannelMergerHandler final : public AudioHandler {
unsigned number_of_inputs);
void Process(size_t frames_to_process) override;
void SetChannelCount(unsigned long, ExceptionState&) final;
void SetChannelCount(unsigned, ExceptionState&) final;
void SetChannelCountMode(const String&, ExceptionState&) final;
double TailTime() const override { return 0; }
......
......@@ -83,7 +83,7 @@ void ChannelSplitterHandler::Process(size_t frames_to_process) {
}
}
void ChannelSplitterHandler::SetChannelCount(unsigned long channel_count,
void ChannelSplitterHandler::SetChannelCount(unsigned channel_count,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
BaseAudioContext::GraphAutoLocker locker(Context());
......
......@@ -41,7 +41,7 @@ class ChannelSplitterHandler final : public AudioHandler {
// AudioHandler
void Process(size_t frames_to_process) override;
void SetChannelCount(unsigned long, ExceptionState&) final;
void SetChannelCount(unsigned, ExceptionState&) final;
void SetChannelCountMode(const String&, ExceptionState&) final;
void SetChannelInterpretation(const String&, ExceptionState&) final;
......
......@@ -202,7 +202,7 @@ unsigned ConvolverHandler::ComputeNumberOfOutputChannels(
return clampTo(std::max(input_channels, response_channels), 1, 2);
}
void ConvolverHandler::SetChannelCount(unsigned long channel_count,
void ConvolverHandler::SetChannelCount(unsigned channel_count,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
BaseAudioContext::GraphAutoLocker locker(Context());
......
......@@ -58,7 +58,7 @@ class MODULES_EXPORT ConvolverHandler final : public AudioHandler {
bool Normalize() const { return normalize_; }
void SetNormalize(bool normalize) { normalize_ = normalize; }
void SetChannelCount(unsigned long, ExceptionState&) final;
void SetChannelCount(unsigned, ExceptionState&) final;
void SetChannelCountMode(const String&, ExceptionState&) final;
private:
......
......@@ -86,7 +86,7 @@ void DefaultAudioDestinationHandler::Uninitialize() {
}
void DefaultAudioDestinationHandler::SetChannelCount(
unsigned long channel_count,
unsigned channel_count,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
......@@ -134,7 +134,7 @@ void DefaultAudioDestinationHandler::RestartRendering() {
StartRendering();
}
unsigned long DefaultAudioDestinationHandler::MaxChannelCount() const {
uint32_t DefaultAudioDestinationHandler::MaxChannelCount() const {
return AudioDestination::MaxChannelCount();
}
......
......@@ -50,7 +50,7 @@ class DefaultAudioDestinationHandler final : public AudioDestinationHandler,
void Dispose() override;
void Initialize() override;
void Uninitialize() override;
void SetChannelCount(unsigned long, ExceptionState&) override;
void SetChannelCount(unsigned, ExceptionState&) override;
double LatencyTime() const override { return 0; }
double TailTime() const override { return 0; }
bool RequiresTailProcessing() const final { return false; }
......@@ -59,7 +59,7 @@ class DefaultAudioDestinationHandler final : public AudioDestinationHandler,
void StartRendering() override;
void StopRendering() override;
void RestartRendering() override;
unsigned long MaxChannelCount() const override;
uint32_t MaxChannelCount() const override;
double SampleRate() const override;
// For AudioIOCallback. This is invoked by the platform audio destination to
......
......@@ -141,7 +141,7 @@ double DynamicsCompressorHandler::LatencyTime() const {
}
void DynamicsCompressorHandler::SetChannelCount(
unsigned long channel_count,
unsigned channel_count,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
BaseAudioContext::GraphAutoLocker locker(Context());
......
......@@ -58,7 +58,7 @@ class MODULES_EXPORT DynamicsCompressorHandler final : public AudioHandler {
float ReductionValue() const { return NoBarrierLoad(&reduction_); }
void SetChannelCount(unsigned long, ExceptionState&) final;
void SetChannelCount(unsigned, ExceptionState&) final;
void SetChannelCountMode(const String&, ExceptionState&) final;
private:
......
......@@ -110,7 +110,7 @@ void MediaStreamAudioDestinationHandler::Process(size_t number_of_frames) {
}
void MediaStreamAudioDestinationHandler::SetChannelCount(
unsigned long channel_count,
unsigned channel_count,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
......
......@@ -47,7 +47,7 @@ class MediaStreamAudioDestinationHandler final
// AudioHandler.
void Process(size_t frames_to_process) override;
void SetChannelCount(unsigned long, ExceptionState&) override;
void SetChannelCount(unsigned, ExceptionState&) override;
unsigned long MaxChannelCount() const;
......
......@@ -268,7 +268,8 @@ ScriptPromise OfflineAudioContext::suspendContext(ScriptState* script_state,
// The specified suspend time is in the past; reject the promise.
if (frame < CurrentSampleFrame()) {
size_t current_frame_clamped = std::min(CurrentSampleFrame(), length());
size_t current_frame_clamped =
std::min(CurrentSampleFrame(), static_cast<size_t>(length()));
double current_time_clamped =
std::min(currentTime(), length() / static_cast<double>(sampleRate()));
resolver->Reject(DOMException::Create(
......
......@@ -59,7 +59,7 @@ class MODULES_EXPORT OfflineAudioContext final : public BaseAudioContext {
void Trace(blink::Visitor*) override;
size_t length() const { return total_render_frames_; }
uint32_t length() const { return total_render_frames_; }
ScriptPromise startOfflineRendering(ScriptState*);
......@@ -129,7 +129,7 @@ class MODULES_EXPORT OfflineAudioContext final : public BaseAudioContext {
bool is_rendering_started_;
// Total render sample length.
size_t total_render_frames_;
uint32_t total_render_frames_;
};
} // namespace blink
......
......@@ -103,7 +103,7 @@ OfflineAudioContext* OfflineAudioDestinationHandler::Context() const {
return static_cast<OfflineAudioContext*>(AudioDestinationHandler::Context());
}
unsigned long OfflineAudioDestinationHandler::MaxChannelCount() const {
uint32_t OfflineAudioDestinationHandler::MaxChannelCount() const {
return channel_count_;
}
......
......@@ -62,7 +62,7 @@ class OfflineAudioDestinationHandler final : public AudioDestinationHandler {
// AudioDestinationHandler
void StartRendering() override;
void StopRendering() override;
unsigned long MaxChannelCount() const override;
uint32_t MaxChannelCount() const override;
void RestartRendering() override;
......
......@@ -577,7 +577,7 @@ void PannerHandler::MarkPannerAsDirty(unsigned dirty) {
is_distance_cone_gain_dirty_ = true;
}
void PannerHandler::SetChannelCount(unsigned long channel_count,
void PannerHandler::SetChannelCount(unsigned channel_count,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
BaseAudioContext::GraphAutoLocker locker(Context());
......
......@@ -118,7 +118,7 @@ class PannerHandler final : public AudioHandler {
}
bool RequiresTailProcessing() const final;
void SetChannelCount(unsigned long, ExceptionState&) final;
void SetChannelCount(unsigned, ExceptionState&) final;
void SetChannelCountMode(const String&, ExceptionState&) final;
private:
......
......@@ -334,7 +334,7 @@ double ScriptProcessorHandler::LatencyTime() const {
return std::numeric_limits<double>::infinity();
}
void ScriptProcessorHandler::SetChannelCount(unsigned long channel_count,
void ScriptProcessorHandler::SetChannelCount(unsigned channel_count,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
BaseAudioContext::GraphAutoLocker locker(Context());
......@@ -512,7 +512,7 @@ ScriptProcessorNode* ScriptProcessorNode::Create(
return node;
}
size_t ScriptProcessorNode::bufferSize() const {
uint32_t ScriptProcessorNode::bufferSize() const {
return static_cast<ScriptProcessorHandler&>(Handler()).BufferSize();
}
......
......@@ -63,9 +63,9 @@ class ScriptProcessorHandler final : public AudioHandler {
void Process(size_t frames_to_process) override;
void Initialize() override;
size_t BufferSize() const { return buffer_size_; }
uint32_t BufferSize() const { return static_cast<uint32_t>(buffer_size_); }
void SetChannelCount(unsigned long, ExceptionState&) override;
void SetChannelCount(unsigned, ExceptionState&) override;
void SetChannelCountMode(const String&, ExceptionState&) override;
unsigned NumberOfOutputChannels() const override {
......@@ -146,7 +146,7 @@ class ScriptProcessorNode final
unsigned number_of_output_channels);
DEFINE_ATTRIBUTE_EVENT_LISTENER(audioprocess, kAudioprocess);
size_t bufferSize() const;
uint32_t bufferSize() const;
// ScriptWrappable
bool HasPendingActivity() const final;
......
......@@ -90,7 +90,7 @@ void StereoPannerHandler::Initialize() {
AudioHandler::Initialize();
}
void StereoPannerHandler::SetChannelCount(unsigned long channel_count,
void StereoPannerHandler::SetChannelCount(unsigned channel_count,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
BaseAudioContext::GraphAutoLocker locker(Context());
......
......@@ -30,7 +30,7 @@ class StereoPannerHandler final : public AudioHandler {
void ProcessOnlyAudioParams(size_t frames_to_process) override;
void Initialize() override;
void SetChannelCount(unsigned long, ExceptionState&) final;
void SetChannelCount(unsigned, ExceptionState&) final;
void SetChannelCountMode(const String&, ExceptionState&) final;
double TailTime() const override { return 0; }
......
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