| Index: third_party/WebKit/Source/modules/webaudio/AudioBuffer.cpp
|
| diff --git a/third_party/WebKit/Source/modules/webaudio/AudioBuffer.cpp b/third_party/WebKit/Source/modules/webaudio/AudioBuffer.cpp
|
| index 71be1f1bf431239bb11971382e357c8037ee38d9..08f092de9f3d6be5fc55631ca511135c53a0e1cb 100644
|
| --- a/third_party/WebKit/Source/modules/webaudio/AudioBuffer.cpp
|
| +++ b/third_party/WebKit/Source/modules/webaudio/AudioBuffer.cpp
|
| @@ -185,84 +185,36 @@
|
| }
|
| }
|
|
|
| -NotShared<DOMFloat32Array> AudioBuffer::getChannelData(
|
| - unsigned channel_index,
|
| - ExceptionState& exception_state) {
|
| +DOMFloat32Array* AudioBuffer::getChannelData(unsigned channel_index,
|
| + ExceptionState& exception_state) {
|
| if (channel_index >= channels_.size()) {
|
| exception_state.ThrowDOMException(
|
| kIndexSizeError, "channel index (" + String::Number(channel_index) +
|
| ") exceeds number of channels (" +
|
| String::Number(channels_.size()) + ")");
|
| - return NotShared<DOMFloat32Array>(nullptr);
|
| + return nullptr;
|
| }
|
|
|
| return getChannelData(channel_index);
|
| }
|
|
|
| -NotShared<DOMFloat32Array> AudioBuffer::getChannelData(unsigned channel_index) {
|
| +DOMFloat32Array* AudioBuffer::getChannelData(unsigned channel_index) {
|
| if (channel_index >= channels_.size())
|
| - return NotShared<DOMFloat32Array>(nullptr);
|
| -
|
| - return NotShared<DOMFloat32Array>(channels_[channel_index].Get());
|
| -}
|
| -
|
| -void AudioBuffer::copyFromChannel(NotShared<DOMFloat32Array> destination,
|
| + return nullptr;
|
| +
|
| + return channels_[channel_index].Get();
|
| +}
|
| +
|
| +void AudioBuffer::copyFromChannel(DOMFloat32Array* destination,
|
| long channel_number,
|
| ExceptionState& exception_state) {
|
| return copyFromChannel(destination, channel_number, 0, exception_state);
|
| }
|
|
|
| -void AudioBuffer::copyFromChannel(NotShared<DOMFloat32Array> destination,
|
| +void AudioBuffer::copyFromChannel(DOMFloat32Array* destination,
|
| long channel_number,
|
| unsigned long start_in_channel,
|
| ExceptionState& exception_state) {
|
| - if (channel_number < 0 ||
|
| - channel_number >= static_cast<long>(channels_.size())) {
|
| - exception_state.ThrowDOMException(
|
| - kIndexSizeError, ExceptionMessages::IndexOutsideRange(
|
| - "channelNumber", channel_number, 0L,
|
| - ExceptionMessages::kInclusiveBound,
|
| - static_cast<long>(channels_.size() - 1),
|
| - ExceptionMessages::kInclusiveBound));
|
| -
|
| - return;
|
| - }
|
| -
|
| - DOMFloat32Array* channel_data = channels_[channel_number].Get();
|
| -
|
| - if (start_in_channel >= channel_data->length()) {
|
| - exception_state.ThrowDOMException(
|
| - kIndexSizeError, ExceptionMessages::IndexOutsideRange(
|
| - "startInChannel", start_in_channel, 0UL,
|
| - ExceptionMessages::kInclusiveBound,
|
| - static_cast<unsigned long>(channel_data->length()),
|
| - ExceptionMessages::kExclusiveBound));
|
| -
|
| - return;
|
| - }
|
| -
|
| - unsigned count = channel_data->length() - start_in_channel;
|
| - count = std::min(destination.View()->length(), count);
|
| -
|
| - const float* src = channel_data->Data();
|
| - float* dst = destination.View()->Data();
|
| -
|
| - DCHECK(src);
|
| - DCHECK(dst);
|
| -
|
| - memcpy(dst, src + start_in_channel, count * sizeof(*src));
|
| -}
|
| -
|
| -void AudioBuffer::copyToChannel(NotShared<DOMFloat32Array> source,
|
| - long channel_number,
|
| - ExceptionState& exception_state) {
|
| - return copyToChannel(source, channel_number, 0, exception_state);
|
| -}
|
| -
|
| -void AudioBuffer::copyToChannel(NotShared<DOMFloat32Array> source,
|
| - long channel_number,
|
| - unsigned long start_in_channel,
|
| - ExceptionState& exception_state) {
|
| if (channel_number < 0 ||
|
| channel_number >= static_cast<long>(channels_.size())) {
|
| exception_state.ThrowDOMException(
|
| @@ -288,21 +240,67 @@
|
| }
|
|
|
| unsigned count = channel_data->length() - start_in_channel;
|
| - count = std::min(source.View()->length(), count);
|
| -
|
| - const float* src = source.View()->Data();
|
| - float* dst = channel_data->Data();
|
| + count = std::min(destination->length(), count);
|
| +
|
| + const float* src = channel_data->Data();
|
| + float* dst = destination->Data();
|
|
|
| DCHECK(src);
|
| DCHECK(dst);
|
|
|
| + memcpy(dst, src + start_in_channel, count * sizeof(*src));
|
| +}
|
| +
|
| +void AudioBuffer::copyToChannel(DOMFloat32Array* source,
|
| + long channel_number,
|
| + ExceptionState& exception_state) {
|
| + return copyToChannel(source, channel_number, 0, exception_state);
|
| +}
|
| +
|
| +void AudioBuffer::copyToChannel(DOMFloat32Array* source,
|
| + long channel_number,
|
| + unsigned long start_in_channel,
|
| + ExceptionState& exception_state) {
|
| + if (channel_number < 0 ||
|
| + channel_number >= static_cast<long>(channels_.size())) {
|
| + exception_state.ThrowDOMException(
|
| + kIndexSizeError, ExceptionMessages::IndexOutsideRange(
|
| + "channelNumber", channel_number, 0L,
|
| + ExceptionMessages::kInclusiveBound,
|
| + static_cast<long>(channels_.size() - 1),
|
| + ExceptionMessages::kInclusiveBound));
|
| + return;
|
| + }
|
| +
|
| + DOMFloat32Array* channel_data = channels_[channel_number].Get();
|
| +
|
| + if (start_in_channel >= channel_data->length()) {
|
| + exception_state.ThrowDOMException(
|
| + kIndexSizeError, ExceptionMessages::IndexOutsideRange(
|
| + "startInChannel", start_in_channel, 0UL,
|
| + ExceptionMessages::kInclusiveBound,
|
| + static_cast<unsigned long>(channel_data->length()),
|
| + ExceptionMessages::kExclusiveBound));
|
| +
|
| + return;
|
| + }
|
| +
|
| + unsigned count = channel_data->length() - start_in_channel;
|
| + count = std::min(source->length(), count);
|
| +
|
| + const float* src = source->Data();
|
| + float* dst = channel_data->Data();
|
| +
|
| + DCHECK(src);
|
| + DCHECK(dst);
|
| +
|
| memcpy(dst + start_in_channel, src, count * sizeof(*dst));
|
| }
|
|
|
| void AudioBuffer::Zero() {
|
| for (unsigned i = 0; i < channels_.size(); ++i) {
|
| - if (NotShared<DOMFloat32Array> array = getChannelData(i)) {
|
| - float* data = array.View()->Data();
|
| + if (DOMFloat32Array* array = getChannelData(i)) {
|
| + float* data = array->Data();
|
| memset(data, 0, length() * sizeof(*data));
|
| }
|
| }
|
|
|