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 #include "content/renderer/media/render_audiosourceprovider.h" | 5 #include "content/renderer/media/render_audiosourceprovider.h" |
6 | 6 |
| 7 #include <vector> |
| 8 |
7 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
11 #include "content/renderer/media/audio_device_factory.h" | 13 #include "content/renderer/media/audio_device_factory.h" |
12 #include "content/renderer/media/audio_renderer_mixer_manager.h" | 14 #include "content/renderer/media/audio_renderer_mixer_manager.h" |
13 #include "content/renderer/render_thread_impl.h" | 15 #include "content/renderer/render_thread_impl.h" |
14 #include "media/base/audio_renderer_mixer_input.h" | 16 #include "media/base/audio_renderer_mixer_input.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide
rClient.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide
rClient.h" |
16 | 18 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 void RenderAudioSourceProvider::provideInput( | 72 void RenderAudioSourceProvider::provideInput( |
71 const WebVector<float*>& audio_data, size_t number_of_frames) { | 73 const WebVector<float*>& audio_data, size_t number_of_frames) { |
72 DCHECK(client_); | 74 DCHECK(client_); |
73 | 75 |
74 if (renderer_ && is_initialized_ && is_running_) { | 76 if (renderer_ && is_initialized_ && is_running_) { |
75 // Wrap WebVector as std::vector. | 77 // Wrap WebVector as std::vector. |
76 vector<float*> v(audio_data.size()); | 78 vector<float*> v(audio_data.size()); |
77 for (size_t i = 0; i < audio_data.size(); ++i) | 79 for (size_t i = 0; i < audio_data.size(); ++i) |
78 v[i] = audio_data[i]; | 80 v[i] = audio_data[i]; |
79 | 81 |
| 82 scoped_ptr<media::AudioBus> audio_bus = media::AudioBus::WrapVector( |
| 83 number_of_frames, v); |
| 84 |
80 // TODO(crogers): figure out if we should volume scale here or in common | 85 // TODO(crogers): figure out if we should volume scale here or in common |
81 // WebAudio code. In any case we need to take care of volume. | 86 // WebAudio code. In any case we need to take care of volume. |
82 renderer_->Render(v, number_of_frames, 0); | 87 renderer_->Render(audio_bus.get(), 0); |
83 } else { | 88 } else { |
84 // Provide silence if the source is not running. | 89 // Provide silence if the source is not running. |
85 for (size_t i = 0; i < audio_data.size(); ++i) | 90 for (size_t i = 0; i < audio_data.size(); ++i) |
86 memset(audio_data[i], 0, sizeof(*audio_data[0]) * number_of_frames); | 91 memset(audio_data[i], 0, sizeof(*audio_data[0]) * number_of_frames); |
87 } | 92 } |
88 } | 93 } |
89 | 94 |
90 void RenderAudioSourceProvider::Start() { | 95 void RenderAudioSourceProvider::Start() { |
91 base::AutoLock auto_lock(sink_lock_); | 96 base::AutoLock auto_lock(sink_lock_); |
92 if (!client_) | 97 if (!client_) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 142 |
138 if (client_) { | 143 if (client_) { |
139 // Inform WebKit about the audio stream format. | 144 // Inform WebKit about the audio stream format. |
140 client_->setFormat(channels_, sample_rate_); | 145 client_->setFormat(channels_, sample_rate_); |
141 } | 146 } |
142 | 147 |
143 is_initialized_ = true; | 148 is_initialized_ = true; |
144 } | 149 } |
145 | 150 |
146 RenderAudioSourceProvider::~RenderAudioSourceProvider() {} | 151 RenderAudioSourceProvider::~RenderAudioSourceProvider() {} |
OLD | NEW |