OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/webaudio/AudioWorkletGlobalScope.h" | 5 #include "modules/webaudio/AudioWorkletGlobalScope.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptSourceCode.h" | 7 #include "bindings/core/v8/ScriptSourceCode.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
10 #include "bindings/core/v8/SourceLocation.h" | 10 #include "bindings/core/v8/SourceLocation.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 )JS")); | 211 )JS")); |
212 | 212 |
213 AudioWorkletProcessor* processor = | 213 AudioWorkletProcessor* processor = |
214 global_scope->CreateInstance("testProcessor"); | 214 global_scope->CreateInstance("testProcessor"); |
215 EXPECT_TRUE(processor); | 215 EXPECT_TRUE(processor); |
216 | 216 |
217 AudioBuffer* input_buffer = | 217 AudioBuffer* input_buffer = |
218 AudioBuffer::Create(1, kRenderQuantumFrames, kTestingSampleRate); | 218 AudioBuffer::Create(1, kRenderQuantumFrames, kTestingSampleRate); |
219 AudioBuffer* output_buffer = | 219 AudioBuffer* output_buffer = |
220 AudioBuffer::Create(1, kRenderQuantumFrames, kTestingSampleRate); | 220 AudioBuffer::Create(1, kRenderQuantumFrames, kTestingSampleRate); |
221 DOMFloat32Array* input_channel_data = input_buffer->getChannelData(0); | 221 DOMFloat32Array* input_channel_data = |
| 222 input_buffer->getChannelData(0).View(); |
222 float* input_array_data = input_channel_data->Data(); | 223 float* input_array_data = input_channel_data->Data(); |
223 EXPECT_TRUE(input_array_data); | 224 EXPECT_TRUE(input_array_data); |
224 DOMFloat32Array* output_channel_data = output_buffer->getChannelData(0); | 225 DOMFloat32Array* output_channel_data = |
| 226 output_buffer->getChannelData(0).View(); |
225 float* output_array_data = output_channel_data->Data(); | 227 float* output_array_data = output_channel_data->Data(); |
226 EXPECT_TRUE(output_array_data); | 228 EXPECT_TRUE(output_array_data); |
227 | 229 |
228 // Fill |inputBuffer| with 1 and zero out |outputBuffer|. | 230 // Fill |inputBuffer| with 1 and zero out |outputBuffer|. |
229 std::fill(input_array_data, input_array_data + input_buffer->length(), 1); | 231 std::fill(input_array_data, input_array_data + input_buffer->length(), 1); |
230 output_buffer->Zero(); | 232 output_buffer->Zero(); |
231 | 233 |
232 // Then invoke the process() method to perform JS buffer manipulation. The | 234 // Then invoke the process() method to perform JS buffer manipulation. The |
233 // output buffer should contain a constant value of 2. | 235 // output buffer should contain a constant value of 2. |
234 processor->Process(input_buffer, output_buffer); | 236 processor->Process(input_buffer, output_buffer); |
(...skipping 20 matching lines...) Expand all Loading... |
255 thread->TerminateAndWait(); | 257 thread->TerminateAndWait(); |
256 } | 258 } |
257 | 259 |
258 TEST_F(AudioWorkletGlobalScopeTest, BufferProcessing) { | 260 TEST_F(AudioWorkletGlobalScopeTest, BufferProcessing) { |
259 std::unique_ptr<AudioWorkletThread> thread = CreateAudioWorkletThread(); | 261 std::unique_ptr<AudioWorkletThread> thread = CreateAudioWorkletThread(); |
260 RunSimpleProcessTest(thread.get()); | 262 RunSimpleProcessTest(thread.get()); |
261 thread->TerminateAndWait(); | 263 thread->TerminateAndWait(); |
262 } | 264 } |
263 | 265 |
264 } // namespace blink | 266 } // namespace blink |
OLD | NEW |