OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 bool AudioBuffer::CreatedSuccessfully( | 137 bool AudioBuffer::CreatedSuccessfully( |
138 unsigned desired_number_of_channels) const { | 138 unsigned desired_number_of_channels) const { |
139 return numberOfChannels() == desired_number_of_channels; | 139 return numberOfChannels() == desired_number_of_channels; |
140 } | 140 } |
141 | 141 |
142 DOMFloat32Array* AudioBuffer::CreateFloat32ArrayOrNull(size_t length) { | 142 DOMFloat32Array* AudioBuffer::CreateFloat32ArrayOrNull(size_t length) { |
143 RefPtr<WTF::Float32Array> buffer_view = | 143 RefPtr<WTF::Float32Array> buffer_view = |
144 WTF::Float32Array::CreateOrNull(length); | 144 WTF::Float32Array::CreateOrNull(length); |
145 if (!buffer_view) | 145 if (!buffer_view) |
146 return nullptr; | 146 return nullptr; |
147 return DOMFloat32Array::Create(buffer_view.Release()); | 147 return DOMFloat32Array::Create(std::move(buffer_view)); |
148 } | 148 } |
149 | 149 |
150 AudioBuffer::AudioBuffer(unsigned number_of_channels, | 150 AudioBuffer::AudioBuffer(unsigned number_of_channels, |
151 size_t number_of_frames, | 151 size_t number_of_frames, |
152 float sample_rate) | 152 float sample_rate) |
153 : sample_rate_(sample_rate), length_(number_of_frames) { | 153 : sample_rate_(sample_rate), length_(number_of_frames) { |
154 channels_.ReserveCapacity(number_of_channels); | 154 channels_.ReserveCapacity(number_of_channels); |
155 | 155 |
156 for (unsigned i = 0; i < number_of_channels; ++i) { | 156 for (unsigned i = 0; i < number_of_channels; ++i) { |
157 DOMFloat32Array* channel_data_array = CreateFloat32ArrayOrNull(length_); | 157 DOMFloat32Array* channel_data_array = CreateFloat32ArrayOrNull(length_); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 void AudioBuffer::Zero() { | 302 void AudioBuffer::Zero() { |
303 for (unsigned i = 0; i < channels_.size(); ++i) { | 303 for (unsigned i = 0; i < channels_.size(); ++i) { |
304 if (NotShared<DOMFloat32Array> array = getChannelData(i)) { | 304 if (NotShared<DOMFloat32Array> array = getChannelData(i)) { |
305 float* data = array.View()->Data(); | 305 float* data = array.View()->Data(); |
306 memset(data, 0, length() * sizeof(*data)); | 306 memset(data, 0, length() * sizeof(*data)); |
307 } | 307 } |
308 } | 308 } |
309 } | 309 } |
310 | 310 |
311 } // namespace blink | 311 } // namespace blink |
OLD | NEW |