Index: media/audio/audio_system_impl.cc |
diff --git a/media/audio/audio_system_impl.cc b/media/audio/audio_system_impl.cc |
index 00ea330761b28861dc27bd55cdc39f9ffc1c8337..0a0789c1161f97876553566b9007b543e2643497 100644 |
--- a/media/audio/audio_system_impl.cc |
+++ b/media/audio/audio_system_impl.cc |
@@ -9,6 +9,7 @@ |
#include "base/task_runner_util.h" |
#include "media/audio/audio_device_description.h" |
#include "media/audio/audio_manager.h" |
+#include "media/base/bind_to_current_loop.h" |
// Using base::Unretained for |audio_manager_| is safe since it is deleted after |
// its task runner, and AudioSystemImpl is deleted on the UI thread after the IO |
@@ -57,6 +58,23 @@ AudioDeviceDescriptions GetDeviceDescriptionsOnDeviceThread( |
return descriptions; |
} |
+void GetInputDeviceInfoOnDeviceThread( |
+ AudioManager* audio_manager, |
+ const std::string& input_device_id, |
+ AudioSystem::OnInputDeviceInfoCallback on_input_device_info_cb) { |
+ DCHECK(audio_manager->GetTaskRunner()->BelongsToCurrentThread()); |
+ const std::string associated_output_device_id = |
+ audio_manager->GetAssociatedOutputDeviceID(input_device_id); |
+ |
+ on_input_device_info_cb.Run( |
+ GetInputParametersOnDeviceThread(audio_manager, input_device_id), |
+ associated_output_device_id.empty() |
+ ? AudioParameters() |
+ : GetOutputParametersOnDeviceThread(audio_manager, |
+ associated_output_device_id), |
+ associated_output_device_id); |
+} |
+ |
} // namespace |
AudioSystemImpl::AudioSystemImpl(AudioManager* audio_manager) |
@@ -122,11 +140,11 @@ void AudioSystemImpl::HasInputDevices(OnBoolCallback on_has_devices_cb) const { |
} |
void AudioSystemImpl::GetDeviceDescriptions( |
- OnDeviceDescriptionsCallback on_descriptions_cp, |
+ OnDeviceDescriptionsCallback on_descriptions_cb, |
bool for_input) { |
if (GetTaskRunner()->BelongsToCurrentThread()) { |
GetTaskRunner()->PostTask( |
- FROM_HERE, base::Bind(on_descriptions_cp, |
+ FROM_HERE, base::Bind(on_descriptions_cb, |
base::Passed(GetDeviceDescriptionsOnDeviceThread( |
audio_manager_, for_input)))); |
return; |
@@ -136,15 +154,44 @@ void AudioSystemImpl::GetDeviceDescriptions( |
GetTaskRunner(), FROM_HERE, |
base::Bind(&GetDeviceDescriptionsOnDeviceThread, |
base::Unretained(audio_manager_), for_input), |
- std::move(on_descriptions_cp)); |
+ std::move(on_descriptions_cb)); |
} |
-AudioManager* AudioSystemImpl::GetAudioManager() const { |
- return audio_manager_; |
+void AudioSystemImpl::GetAssociatedOutputDeviceID( |
+ const std::string& input_device_id, |
+ OnDeviceIdCallback on_device_id_cb) { |
+ if (GetTaskRunner()->BelongsToCurrentThread()) { |
+ GetTaskRunner()->PostTask( |
+ FROM_HERE, |
+ base::Bind(on_device_id_cb, audio_manager_->GetAssociatedOutputDeviceID( |
+ input_device_id))); |
+ return; |
+ } |
+ base::PostTaskAndReplyWithResult( |
+ GetTaskRunner(), FROM_HERE, |
+ base::Bind(&AudioManager::GetAssociatedOutputDeviceID, |
+ base::Unretained(audio_manager_), input_device_id), |
+ std::move(on_device_id_cb)); |
+} |
+ |
+void AudioSystemImpl::GetInputDeviceInfo( |
+ const std::string& input_device_id, |
+ OnInputDeviceInfoCallback on_input_device_info_cb) { |
+ GetTaskRunner()->PostTask( |
DaleCurtis
2017/03/28 18:22:11
Hmm, seems like either the PostTask or BelongsToCu
o1ka
2017/03/30 15:11:53
We may be either already on the audio thread (for
|
+ FROM_HERE, base::Bind(&GetInputDeviceInfoOnDeviceThread, |
+ base::Unretained(audio_manager_), input_device_id, |
+ GetTaskRunner()->BelongsToCurrentThread() |
+ ? std::move(on_input_device_info_cb) |
+ : media::BindToCurrentLoop( |
+ std::move(on_input_device_info_cb)))); |
} |
base::SingleThreadTaskRunner* AudioSystemImpl::GetTaskRunner() const { |
return audio_manager_->GetTaskRunner(); |
} |
+AudioManager* AudioSystemImpl::GetAudioManager() const { |
+ return audio_manager_; |
+} |
+ |
} // namespace media |