| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
| 6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "media/base/fake_audio_render_callback.h" | 10 #include "media/base/fake_audio_render_callback.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 last_frames_delayed_ = static_cast<int>(frames_delayed); | 29 last_frames_delayed_ = static_cast<int>(frames_delayed); |
| 30 | 30 |
| 31 last_channel_count_ = audio_bus->channels(); | 31 last_channel_count_ = audio_bus->channels(); |
| 32 | 32 |
| 33 int number_of_frames = audio_bus->frames(); | 33 int number_of_frames = audio_bus->frames(); |
| 34 if (half_fill_) | 34 if (half_fill_) |
| 35 number_of_frames /= 2; | 35 number_of_frames /= 2; |
| 36 | 36 |
| 37 // Fill first channel with a sine wave. | 37 // Fill first channel with a sine wave. |
| 38 for (int i = 0; i < number_of_frames; ++i) | 38 for (int i = 0; i < number_of_frames; ++i) |
| 39 audio_bus->channel(0)[i] = sin(2 * M_PI * (x_ + step_ * i)); | 39 audio_bus->channel(0)[i] = sin(2 * M_PI * (x_ + step_ * i)) * volume_; |
| 40 x_ += number_of_frames * step_; | 40 x_ += number_of_frames * step_; |
| 41 | 41 |
| 42 // Copy first channel into the rest of the channels. | 42 // Copy first channel into the rest of the channels. |
| 43 for (int i = 1; i < audio_bus->channels(); ++i) | 43 for (int i = 1; i < audio_bus->channels(); ++i) { |
| 44 memcpy(audio_bus->channel(i), audio_bus->channel(0), | 44 memcpy(audio_bus->channel(i), audio_bus->channel(0), |
| 45 number_of_frames * sizeof(*audio_bus->channel(i))); | 45 number_of_frames * sizeof(*audio_bus->channel(i))); |
| 46 } |
| 46 | 47 |
| 47 return number_of_frames; | 48 return number_of_frames; |
| 48 } | 49 } |
| 49 | 50 |
| 50 double FakeAudioRenderCallback::ProvideInput(AudioBus* audio_bus, | 51 double FakeAudioRenderCallback::ProvideInput(AudioBus* audio_bus, |
| 51 uint32_t frames_delayed) { | 52 uint32_t frames_delayed) { |
| 52 Render(audio_bus, frames_delayed, 0); | 53 Render(audio_bus, frames_delayed, 0); |
| 53 return volume_; | 54 return volume_; |
| 54 } | 55 } |
| 55 | 56 |
| 56 } // namespace media | 57 } // namespace media |
| OLD | NEW |