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_device_manager.h" | 5 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 71 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
72 // Generate a new id for this device. | 72 // Generate a new id for this device. |
73 int session_id = next_capture_session_id_++; | 73 int session_id = next_capture_session_id_++; |
74 | 74 |
75 // base::Unretained(this) is safe, because AudioInputDeviceManager is | 75 // base::Unretained(this) is safe, because AudioInputDeviceManager is |
76 // destroyed not earlier than on the IO message loop destruction. | 76 // destroyed not earlier than on the IO message loop destruction. |
77 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 77 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
78 switches::kUseFakeDeviceForMediaStream)) { | 78 switches::kUseFakeDeviceForMediaStream)) { |
79 audio_system_->GetAssociatedOutputDeviceID( | 79 audio_system_->GetAssociatedOutputDeviceID( |
80 device.id, | 80 device.id, |
81 base::Bind(&AudioInputDeviceManager::OpenedOnIOThread, | 81 base::BindOnce(&AudioInputDeviceManager::OpenedOnIOThread, |
82 base::Unretained(this), session_id, device, | 82 base::Unretained(this), session_id, device, |
83 base::TimeTicks::Now(), | 83 base::TimeTicks::Now(), |
84 media::AudioParameters::UnavailableDeviceParams(), | 84 media::AudioParameters::UnavailableDeviceParams(), |
85 media::AudioParameters::UnavailableDeviceParams())); | 85 media::AudioParameters::UnavailableDeviceParams())); |
86 } else { | 86 } else { |
87 // TODO(tommi): As is, we hit this code path when device.type is | 87 // TODO(tommi): As is, we hit this code path when device.type is |
88 // MEDIA_TAB_AUDIO_CAPTURE and the device id is not a device that | 88 // MEDIA_TAB_AUDIO_CAPTURE and the device id is not a device that |
89 // the AudioManager can know about. This currently does not fail because | 89 // the AudioManager can know about. This currently does not fail because |
90 // the implementation of GetInputStreamParameters returns valid parameters | 90 // the implementation of GetInputStreamParameters returns valid parameters |
91 // by default for invalid devices. That behavior is problematic because it | 91 // by default for invalid devices. That behavior is problematic because it |
92 // causes other parts of the code to attempt to open truly invalid or | 92 // causes other parts of the code to attempt to open truly invalid or |
93 // missing devices and falling back on alternate devices (and likely fail | 93 // missing devices and falling back on alternate devices (and likely fail |
94 // twice in a row). Tab audio capture should not pass through here and | 94 // twice in a row). Tab audio capture should not pass through here and |
95 // GetInputStreamParameters should return invalid parameters for invalid | 95 // GetInputStreamParameters should return invalid parameters for invalid |
96 // devices. | 96 // devices. |
97 | 97 |
98 audio_system_->GetInputDeviceInfo( | 98 audio_system_->GetInputDeviceInfo( |
99 device.id, base::Bind(&AudioInputDeviceManager::OpenedOnIOThread, | 99 device.id, base::BindOnce(&AudioInputDeviceManager::OpenedOnIOThread, |
100 base::Unretained(this), session_id, device, | 100 base::Unretained(this), session_id, device, |
101 base::TimeTicks::Now())); | 101 base::TimeTicks::Now())); |
102 } | 102 } |
103 | 103 |
104 return session_id; | 104 return session_id; |
105 } | 105 } |
106 | 106 |
107 void AudioInputDeviceManager::Close(int session_id) { | 107 void AudioInputDeviceManager::Close(int session_id) { |
108 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 108 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
109 StreamDeviceList::iterator device = GetDevice(session_id); | 109 StreamDeviceList::iterator device = GetDevice(session_id); |
110 if (device == devices_.end()) | 110 if (device == devices_.end()) |
111 return; | 111 return; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 #if defined(OS_CHROMEOS) | 214 #if defined(OS_CHROMEOS) |
215 void AudioInputDeviceManager::SetKeyboardMicStreamActiveOnUIThread( | 215 void AudioInputDeviceManager::SetKeyboardMicStreamActiveOnUIThread( |
216 bool active) { | 216 bool active) { |
217 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 217 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
218 chromeos::CrasAudioHandler::Get()->SetKeyboardMicActive(active); | 218 chromeos::CrasAudioHandler::Get()->SetKeyboardMicActive(active); |
219 } | 219 } |
220 #endif | 220 #endif |
221 | 221 |
222 } // namespace content | 222 } // namespace content |
OLD | NEW |