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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 vector<float*> v(audio_data.size()); | 76 vector<float*> v(audio_data.size()); |
77 for (size_t i = 0; i < audio_data.size(); ++i) | 77 for (size_t i = 0; i < audio_data.size(); ++i) |
78 v[i] = audio_data[i]; | 78 v[i] = audio_data[i]; |
79 | 79 |
80 // TODO(crogers): figure out if we should volume scale here or in common | 80 // 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. | 81 // WebAudio code. In any case we need to take care of volume. |
82 renderer_->Render(v, number_of_frames, 0); | 82 renderer_->Render(v, number_of_frames, 0); |
83 } else { | 83 } else { |
84 // Provide silence if the source is not running. | 84 // Provide silence if the source is not running. |
85 for (size_t i = 0; i < audio_data.size(); ++i) | 85 for (size_t i = 0; i < audio_data.size(); ++i) |
86 memset(audio_data[i], 0, sizeof(float) * number_of_frames); | 86 memset(audio_data[i], 0, sizeof(audio_data[0]) * number_of_frames); |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 void RenderAudioSourceProvider::Start() { | 90 void RenderAudioSourceProvider::Start() { |
91 base::AutoLock auto_lock(sink_lock_); | 91 base::AutoLock auto_lock(sink_lock_); |
92 if (!client_) | 92 if (!client_) |
93 default_sink_->Start(); | 93 default_sink_->Start(); |
94 is_running_ = true; | 94 is_running_ = true; |
95 } | 95 } |
96 | 96 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 if (client_) { | 144 if (client_) { |
145 // Inform WebKit about the audio stream format. | 145 // Inform WebKit about the audio stream format. |
146 client_->setFormat(channels_, sample_rate_); | 146 client_->setFormat(channels_, sample_rate_); |
147 } | 147 } |
148 | 148 |
149 is_initialized_ = true; | 149 is_initialized_ = true; |
150 } | 150 } |
151 | 151 |
152 RenderAudioSourceProvider::~RenderAudioSourceProvider() {} | 152 RenderAudioSourceProvider::~RenderAudioSourceProvider() {} |
OLD | NEW |