Commit 78f78a38 authored by Yu-Hsuan Hsu's avatar Yu-Hsuan Hsu Committed by Commit Bot

Support GetAssociatedOutputDeviceID on LaCrOS

Support GetAssociatedOutputDeviceID on lacros-chrome, which returns the
output device ID having the same device name as the given input ID.

BUG=b:173113548

Change-Id: I8530e4d80a40010cd38e7183ed95ea5c06e55e7f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536664
Commit-Queue: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828605}
parent 9c1bd002
......@@ -149,6 +149,27 @@ std::string AudioManagerCras::GetGroupIDOutput(const std::string& device_id) {
return "";
}
std::string AudioManagerCras::GetAssociatedOutputDeviceID(
const std::string& input_device_id) {
if (AudioDeviceDescription::IsDefaultDevice(input_device_id)) {
// Note: the default input should not be associated to any output, as this
// may lead to accidental uses of a pinned stream.
return "";
}
std::string device_name = GetGroupIDInput(input_device_id);
if (device_name.empty())
return "";
// Now search for an output device with the same device name.
for (const auto& device : CrasGetAudioDevices(DeviceType::kOutput)) {
if (device.dev_name == device_name)
return base::NumberToString(device.id);
}
return "";
}
AudioParameters AudioManagerCras::GetPreferredOutputStreamParameters(
const std::string& output_device_id,
const AudioParameters& input_params) {
......
......@@ -35,6 +35,8 @@ class MEDIA_EXPORT AudioManagerCras : public AudioManagerCrasBase {
std::string GetDefaultOutputDeviceID() override;
std::string GetGroupIDInput(const std::string& device_id) override;
std::string GetGroupIDOutput(const std::string& device_id) override;
std::string GetAssociatedOutputDeviceID(
const std::string& input_device_id) override;
// AudioManagerCrasBase implementation.
bool IsDefault(const std::string& device_id, bool is_input) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment