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/browser/renderer_host/media/audio_input_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/process.h" | 9 #include "base/process.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 << ", render_view_id=" << render_view_id | 206 << ", render_view_id=" << render_view_id |
207 << ", session_id=" << session_id << ")"; | 207 << ", session_id=" << session_id << ")"; |
208 DCHECK_GT(render_view_id, 0); | 208 DCHECK_GT(render_view_id, 0); |
209 | 209 |
210 // media::AudioParameters is validated in the deserializer. | 210 // media::AudioParameters is validated in the deserializer. |
211 if (LookupById(stream_id) != NULL) { | 211 if (LookupById(stream_id) != NULL) { |
212 SendErrorMessage(stream_id); | 212 SendErrorMessage(stream_id); |
213 return; | 213 return; |
214 } | 214 } |
215 | 215 |
| 216 media::AudioParameters audio_params(config.params); |
| 217 if (media_stream_manager_->audio_input_device_manager()-> |
| 218 ShouldUseFakeDevice()) { |
| 219 audio_params.Reset( |
| 220 media::AudioParameters::AUDIO_FAKE, |
| 221 config.params.channel_layout(), config.params.channels(), 0, |
| 222 config.params.sample_rate(), config.params.bits_per_sample(), |
| 223 config.params.frames_per_buffer()); |
| 224 } |
| 225 |
216 // Check if we have the permission to open the device and which device to use. | 226 // Check if we have the permission to open the device and which device to use. |
217 std::string device_id = media::AudioManagerBase::kDefaultDeviceId; | 227 std::string device_id = media::AudioManagerBase::kDefaultDeviceId; |
218 if (session_id != AudioInputDeviceManager::kFakeOpenSessionId) { | 228 if (audio_params.format() != media::AudioParameters::AUDIO_FAKE) { |
219 const StreamDeviceInfo* info = media_stream_manager_-> | 229 const StreamDeviceInfo* info = media_stream_manager_-> |
220 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id); | 230 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id); |
221 if (!info) { | 231 if (!info) { |
222 SendErrorMessage(stream_id); | 232 SendErrorMessage(stream_id); |
223 DLOG(WARNING) << "No permission has been granted to input stream with " | 233 DLOG(WARNING) << "No permission has been granted to input stream with " |
224 << "session_id=" << session_id; | 234 << "session_id=" << session_id; |
225 return; | 235 return; |
226 } | 236 } |
227 | 237 |
228 device_id = info->device.id; | 238 device_id = info->device.id; |
229 } | 239 } |
230 | 240 |
231 media::AudioParameters audio_params(config.params); | |
232 if (media_stream_manager_->audio_input_device_manager()-> | |
233 ShouldUseFakeDevice()) { | |
234 audio_params.Reset( | |
235 media::AudioParameters::AUDIO_FAKE, | |
236 config.params.channel_layout(), config.params.channels(), 0, | |
237 config.params.sample_rate(), config.params.bits_per_sample(), | |
238 config.params.frames_per_buffer()); | |
239 } | |
240 | |
241 // Create a new AudioEntry structure. | 241 // Create a new AudioEntry structure. |
242 scoped_ptr<AudioEntry> entry(new AudioEntry()); | 242 scoped_ptr<AudioEntry> entry(new AudioEntry()); |
243 | 243 |
244 const uint32 segment_size = (sizeof(media::AudioInputBufferParameters) + | 244 const uint32 segment_size = (sizeof(media::AudioInputBufferParameters) + |
245 audio_params.GetBytesPerBuffer()); | 245 audio_params.GetBytesPerBuffer()); |
246 entry->shared_memory_segment_count = config.shared_memory_count; | 246 entry->shared_memory_segment_count = config.shared_memory_count; |
247 | 247 |
248 // Create the shared memory and share it with the renderer process | 248 // Create the shared memory and share it with the renderer process |
249 // using a new SyncWriter object. | 249 // using a new SyncWriter object. |
250 if (!entry->shared_memory.CreateAndMapAnonymous( | 250 if (!entry->shared_memory.CreateAndMapAnonymous( |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 // TODO(hclam): Implement a faster look up method. | 395 // TODO(hclam): Implement a faster look up method. |
396 for (AudioEntryMap::iterator i = audio_entries_.begin(); | 396 for (AudioEntryMap::iterator i = audio_entries_.begin(); |
397 i != audio_entries_.end(); ++i) { | 397 i != audio_entries_.end(); ++i) { |
398 if (controller == i->second->controller.get()) | 398 if (controller == i->second->controller.get()) |
399 return i->second; | 399 return i->second; |
400 } | 400 } |
401 return NULL; | 401 return NULL; |
402 } | 402 } |
403 | 403 |
404 } // namespace content | 404 } // namespace content |
OLD | NEW |