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

Able to query an active device on LaCrOS

Make lacros-chrome able to query the id of an active device.

BUG=b:173113548

Change-Id: I0169592ddf95d8cadca6806ac1a671eb06bc87fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536662
Commit-Queue: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828555}
parent cf353d54
...@@ -157,12 +157,18 @@ AudioParameters AudioManagerCras::GetPreferredOutputStreamParameters( ...@@ -157,12 +157,18 @@ AudioParameters AudioManagerCras::GetPreferredOutputStreamParameters(
} }
uint64_t AudioManagerCras::GetPrimaryActiveInputNode() { uint64_t AudioManagerCras::GetPrimaryActiveInputNode() {
DCHECK(GetTaskRunner()->BelongsToCurrentThread()); for (const auto& device : CrasGetAudioDevices(DeviceType::kInput)) {
if (device.active)
return device.id;
}
return 0; return 0;
} }
uint64_t AudioManagerCras::GetPrimaryActiveOutputNode() { uint64_t AudioManagerCras::GetPrimaryActiveOutputNode() {
DCHECK(GetTaskRunner()->BelongsToCurrentThread()); for (const auto& device : CrasGetAudioDevices(DeviceType::kOutput)) {
if (device.active)
return device.id;
}
return 0; return 0;
} }
......
...@@ -68,6 +68,7 @@ CrasDevice::CrasDevice(const cras_ionode_info* node, ...@@ -68,6 +68,7 @@ CrasDevice::CrasDevice(const cras_ionode_info* node,
DeviceType type) DeviceType type)
: type(type) { : type(type) {
id = cras_make_node_id(node->iodev_idx, node->ionode_idx); id = cras_make_node_id(node->iodev_idx, node->ionode_idx);
active = node->active;
name = std::string(node->name); name = std::string(node->name);
// If the name of node is not meaningful, use the device name instead. // If the name of node is not meaningful, use the device name instead.
if (name.empty() || name == "(default)") if (name.empty() || name == "(default)")
...@@ -101,6 +102,8 @@ CrasDevice::CrasDevice(const std::vector<cras_ionode_info>& nodes, ...@@ -101,6 +102,8 @@ CrasDevice::CrasDevice(const std::vector<cras_ionode_info>& nodes,
} else { } else {
LOG(WARNING) << "Failed to create virtual device for " << dev->name; LOG(WARNING) << "Failed to create virtual device for " << dev->name;
} }
active = nodes[0].active || nodes[1].active;
} }
std::vector<CrasDevice> CrasGetAudioDevices(DeviceType type) { std::vector<CrasDevice> CrasGetAudioDevices(DeviceType type) {
......
...@@ -25,6 +25,7 @@ struct CrasDevice { ...@@ -25,6 +25,7 @@ struct CrasDevice {
DeviceType type); DeviceType type);
DeviceType type; DeviceType type;
uint64_t id; uint64_t id;
int32_t active;
std::string name; std::string name;
}; };
......
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