OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "media/audio/audio_system_impl.h" | 5 #include "media/audio/audio_system_impl.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/task_runner_util.h" | 9 #include "base/task_runner_util.h" |
10 #include "media/audio/audio_device_description.h" | 10 #include "media/audio/audio_device_description.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 base::Bind(on_has_devices_cb, audio_manager_->HasAudioInputDevices())); | 114 base::Bind(on_has_devices_cb, audio_manager_->HasAudioInputDevices())); |
115 return; | 115 return; |
116 } | 116 } |
117 base::PostTaskAndReplyWithResult( | 117 base::PostTaskAndReplyWithResult( |
118 GetTaskRunner(), FROM_HERE, | 118 GetTaskRunner(), FROM_HERE, |
119 base::Bind(&AudioManager::HasAudioInputDevices, | 119 base::Bind(&AudioManager::HasAudioInputDevices, |
120 base::Unretained(audio_manager_)), | 120 base::Unretained(audio_manager_)), |
121 std::move(on_has_devices_cb)); | 121 std::move(on_has_devices_cb)); |
122 } | 122 } |
123 | 123 |
| 124 void AudioSystemImpl::HasOutputDevices(OnBoolCallback on_has_devices_cb) const { |
| 125 if (GetTaskRunner()->BelongsToCurrentThread()) { |
| 126 GetTaskRunner()->PostTask( |
| 127 FROM_HERE, |
| 128 base::Bind(on_has_devices_cb, audio_manager_->HasAudioOutputDevices())); |
| 129 return; |
| 130 } |
| 131 base::PostTaskAndReplyWithResult( |
| 132 GetTaskRunner(), FROM_HERE, |
| 133 base::Bind(&AudioManager::HasAudioOutputDevices, |
| 134 base::Unretained(audio_manager_)), |
| 135 std::move(on_has_devices_cb)); |
| 136 } |
| 137 |
124 void AudioSystemImpl::GetDeviceDescriptions( | 138 void AudioSystemImpl::GetDeviceDescriptions( |
125 OnDeviceDescriptionsCallback on_descriptions_cp, | 139 OnDeviceDescriptionsCallback on_descriptions_cp, |
126 bool for_input) { | 140 bool for_input) { |
127 if (GetTaskRunner()->BelongsToCurrentThread()) { | 141 if (GetTaskRunner()->BelongsToCurrentThread()) { |
128 GetTaskRunner()->PostTask( | 142 GetTaskRunner()->PostTask( |
129 FROM_HERE, base::Bind(on_descriptions_cp, | 143 FROM_HERE, base::Bind(on_descriptions_cp, |
130 base::Passed(GetDeviceDescriptionsOnDeviceThread( | 144 base::Passed(GetDeviceDescriptionsOnDeviceThread( |
131 audio_manager_, for_input)))); | 145 audio_manager_, for_input)))); |
132 return; | 146 return; |
133 } | 147 } |
134 | 148 |
135 base::PostTaskAndReplyWithResult( | 149 base::PostTaskAndReplyWithResult( |
136 GetTaskRunner(), FROM_HERE, | 150 GetTaskRunner(), FROM_HERE, |
137 base::Bind(&GetDeviceDescriptionsOnDeviceThread, | 151 base::Bind(&GetDeviceDescriptionsOnDeviceThread, |
138 base::Unretained(audio_manager_), for_input), | 152 base::Unretained(audio_manager_), for_input), |
139 std::move(on_descriptions_cp)); | 153 std::move(on_descriptions_cp)); |
140 } | 154 } |
141 | 155 |
142 AudioManager* AudioSystemImpl::GetAudioManager() const { | 156 AudioManager* AudioSystemImpl::GetAudioManager() const { |
143 return audio_manager_; | 157 return audio_manager_; |
144 } | 158 } |
145 | 159 |
146 base::SingleThreadTaskRunner* AudioSystemImpl::GetTaskRunner() const { | 160 base::SingleThreadTaskRunner* AudioSystemImpl::GetTaskRunner() const { |
147 return audio_manager_->GetTaskRunner(); | 161 return audio_manager_->GetTaskRunner(); |
148 } | 162 } |
149 | 163 |
150 } // namespace media | 164 } // namespace media |
OLD | NEW |