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/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 : stream_id(0), | 44 : stream_id(0), |
45 shared_memory_segment_count(0), | 45 shared_memory_segment_count(0), |
46 pending_close(false) { | 46 pending_close(false) { |
47 } | 47 } |
48 | 48 |
49 AudioInputRendererHost::AudioEntry::~AudioEntry() {} | 49 AudioInputRendererHost::AudioEntry::~AudioEntry() {} |
50 | 50 |
51 AudioInputRendererHost::AudioInputRendererHost( | 51 AudioInputRendererHost::AudioInputRendererHost( |
52 media::AudioManager* audio_manager, | 52 media::AudioManager* audio_manager, |
53 MediaStreamManager* media_stream_manager, | 53 MediaStreamManager* media_stream_manager, |
54 AudioMirroringManager* audio_mirroring_manager) | 54 AudioMirroringManager* audio_mirroring_manager, |
| 55 media::UserInputMonitor* user_input_monitor) |
55 : audio_manager_(audio_manager), | 56 : audio_manager_(audio_manager), |
56 media_stream_manager_(media_stream_manager), | 57 media_stream_manager_(media_stream_manager), |
57 audio_mirroring_manager_(audio_mirroring_manager) { | 58 audio_mirroring_manager_(audio_mirroring_manager), |
58 } | 59 user_input_monitor_(user_input_monitor) {} |
59 | 60 |
60 AudioInputRendererHost::~AudioInputRendererHost() { | 61 AudioInputRendererHost::~AudioInputRendererHost() { |
61 DCHECK(audio_entries_.empty()); | 62 DCHECK(audio_entries_.empty()); |
62 } | 63 } |
63 | 64 |
64 void AudioInputRendererHost::OnChannelClosing() { | 65 void AudioInputRendererHost::OnChannelClosing() { |
65 BrowserMessageFilter::OnChannelClosing(); | 66 BrowserMessageFilter::OnChannelClosing(); |
66 | 67 |
67 // Since the IPC channel is gone, close all requested audio streams. | 68 // Since the IPC channel is gone, close all requested audio streams. |
68 DeleteEntries(); | 69 DeleteEntries(); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 return; | 266 return; |
266 } | 267 } |
267 | 268 |
268 // If we have successfully created the SyncWriter then assign it to the | 269 // If we have successfully created the SyncWriter then assign it to the |
269 // entry and construct an AudioInputController. | 270 // entry and construct an AudioInputController. |
270 entry->writer.reset(writer.release()); | 271 entry->writer.reset(writer.release()); |
271 if (WebContentsCaptureUtil::IsWebContentsDeviceId(device_id)) { | 272 if (WebContentsCaptureUtil::IsWebContentsDeviceId(device_id)) { |
272 entry->controller = media::AudioInputController::CreateForStream( | 273 entry->controller = media::AudioInputController::CreateForStream( |
273 audio_manager_->GetMessageLoop(), | 274 audio_manager_->GetMessageLoop(), |
274 this, | 275 this, |
275 WebContentsAudioInputStream::Create( | 276 WebContentsAudioInputStream::Create(device_id, |
276 device_id, audio_params, audio_manager_->GetWorkerLoop(), | 277 audio_params, |
277 audio_mirroring_manager_), | 278 audio_manager_->GetWorkerLoop(), |
278 entry->writer.get()); | 279 audio_mirroring_manager_), |
| 280 entry->writer.get(), |
| 281 user_input_monitor_); |
279 } else { | 282 } else { |
280 // TODO(henrika): replace CreateLowLatency() with Create() as soon | 283 // TODO(henrika): replace CreateLowLatency() with Create() as soon |
281 // as satish has ensured that Speech Input also uses the default low- | 284 // as satish has ensured that Speech Input also uses the default low- |
282 // latency path. See crbug.com/112472 for details. | 285 // latency path. See crbug.com/112472 for details. |
283 entry->controller = media::AudioInputController::CreateLowLatency( | 286 entry->controller = |
284 audio_manager_, | 287 media::AudioInputController::CreateLowLatency(audio_manager_, |
285 this, | 288 this, |
286 audio_params, | 289 audio_params, |
287 device_id, | 290 device_id, |
288 entry->writer.get()); | 291 entry->writer.get(), |
| 292 user_input_monitor_); |
289 } | 293 } |
290 | 294 |
291 if (!entry->controller.get()) { | 295 if (!entry->controller.get()) { |
292 SendErrorMessage(stream_id); | 296 SendErrorMessage(stream_id); |
293 return; | 297 return; |
294 } | 298 } |
295 | 299 |
296 // Set the initial AGC state for the audio input stream. Note that, the AGC | 300 // Set the initial AGC state for the audio input stream. Note that, the AGC |
297 // is only supported in AUDIO_PCM_LOW_LATENCY mode. | 301 // is only supported in AUDIO_PCM_LOW_LATENCY mode. |
298 if (config.params.format() == media::AudioParameters::AUDIO_PCM_LOW_LATENCY) | 302 if (config.params.format() == media::AudioParameters::AUDIO_PCM_LOW_LATENCY) |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 // TODO(hclam): Implement a faster look up method. | 402 // TODO(hclam): Implement a faster look up method. |
399 for (AudioEntryMap::iterator i = audio_entries_.begin(); | 403 for (AudioEntryMap::iterator i = audio_entries_.begin(); |
400 i != audio_entries_.end(); ++i) { | 404 i != audio_entries_.end(); ++i) { |
401 if (controller == i->second->controller.get()) | 405 if (controller == i->second->controller.get()) |
402 return i->second; | 406 return i->second; |
403 } | 407 } |
404 return NULL; | 408 return NULL; |
405 } | 409 } |
406 | 410 |
407 } // namespace content | 411 } // namespace content |
OLD | NEW |