| 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 = | 221 DOMFloat32Array* input_channel_data = input_buffer->getChannelData(0); |
| 222 input_buffer->getChannelData(0).View(); | |
| 223 float* input_array_data = input_channel_data->Data(); | 222 float* input_array_data = input_channel_data->Data(); |
| 224 EXPECT_TRUE(input_array_data); | 223 EXPECT_TRUE(input_array_data); |
| 225 DOMFloat32Array* output_channel_data = | 224 DOMFloat32Array* output_channel_data = output_buffer->getChannelData(0); |
| 226 output_buffer->getChannelData(0).View(); | |
| 227 float* output_array_data = output_channel_data->Data(); | 225 float* output_array_data = output_channel_data->Data(); |
| 228 EXPECT_TRUE(output_array_data); | 226 EXPECT_TRUE(output_array_data); |
| 229 | 227 |
| 230 // Fill |inputBuffer| with 1 and zero out |outputBuffer|. | 228 // Fill |inputBuffer| with 1 and zero out |outputBuffer|. |
| 231 std::fill(input_array_data, input_array_data + input_buffer->length(), 1); | 229 std::fill(input_array_data, input_array_data + input_buffer->length(), 1); |
| 232 output_buffer->Zero(); | 230 output_buffer->Zero(); |
| 233 | 231 |
| 234 // Then invoke the process() method to perform JS buffer manipulation. The | 232 // Then invoke the process() method to perform JS buffer manipulation. The |
| 235 // output buffer should contain a constant value of 2. | 233 // output buffer should contain a constant value of 2. |
| 236 processor->Process(input_buffer, output_buffer); | 234 processor->Process(input_buffer, output_buffer); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 257 thread->TerminateAndWait(); | 255 thread->TerminateAndWait(); |
| 258 } | 256 } |
| 259 | 257 |
| 260 TEST_F(AudioWorkletGlobalScopeTest, BufferProcessing) { | 258 TEST_F(AudioWorkletGlobalScopeTest, BufferProcessing) { |
| 261 std::unique_ptr<AudioWorkletThread> thread = CreateAudioWorkletThread(); | 259 std::unique_ptr<AudioWorkletThread> thread = CreateAudioWorkletThread(); |
| 262 RunSimpleProcessTest(thread.get()); | 260 RunSimpleProcessTest(thread.get()); |
| 263 thread->TerminateAndWait(); | 261 thread->TerminateAndWait(); |
| 264 } | 262 } |
| 265 | 263 |
| 266 } // namespace blink | 264 } // namespace blink |
| OLD | NEW |