Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/config/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ impl Names {

pub fn default_endpoint() -> Vec<NameTemplate> {
vec![
"{node:node.nick}".parse().unwrap(),
"{device:device.nick}".parse().unwrap(),
"{node:node.description}".parse().unwrap(),
]
Expand Down
50 changes: 39 additions & 11 deletions src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,28 +365,56 @@ impl Device {
.profiles
.values()
.map(|profile| {
let title = if profile.available {
profile.description.clone()
let profile_devices: Vec<i32> = profile
.classes
.iter()
.flat_map(|(_, devices)| devices.iter().copied())
.collect();
let matching_routes: Vec<_> = device
.enum_routes
.values()
.filter(|route| {
route
.devices
.iter()
.any(|d| profile_devices.contains(d))
})
.collect();
let monitor_name = if matching_routes.len() == 1 {
matching_routes[0].product_name.as_deref()
} else {
format!("{} (unavailable)", profile.description)
None
};
let title = match (profile.available, monitor_name) {
(true, Some(name)) => {
format!("{} \u{2014} {}", profile.description, name)
}
(false, Some(name)) => format!(
"{} \u{2014} {} (unavailable)",
profile.description, name
),
(true, None) => profile.description.clone(),
(false, None) => {
format!("{} (unavailable)", profile.description)
}
};
(profile.index, title)
})
.collect();
profiles.sort_by_key(|&(index, _)| index);
let profiles = profiles
let profiles: Vec<(Target, String)> = profiles
.into_iter()
.map(|(index, title)| (Target::Profile(object_id, index), title))
.collect();

let target_profile = device.profiles.get(&device.profile_index?)?;
let target_title = if target_profile.available {
target_profile.description.clone()
} else {
format!("{} (unavailable)", target_profile.description)
};
let profile_index = device.profile_index?;
let target_title = profiles
.iter()
.find(|(t, _)| *t == Target::Profile(object_id, profile_index))
.map(|(_, title)| title.clone())
.unwrap_or_default();

let target = Some(Target::Profile(object_id, device.profile_index?));
let target = Some(Target::Profile(object_id, profile_index));

let object_serial = *device.props.object_serial()?;

Expand Down
21 changes: 21 additions & 0 deletions src/wirehose/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fn device_enum_route(object_id: ObjectId, param: Object) -> Option<StateEvent> {
let mut available = None;
let mut profiles = None;
let mut devices = None;
let mut product_name = None;

for prop in param.properties {
match prop.key {
Expand Down Expand Up @@ -129,6 +130,25 @@ fn device_enum_route(object_id: ObjectId, param: Object) -> Option<StateEvent> {
devices = Some(value);
}
}
libspa_sys::SPA_PARAM_ROUTE_info => {
if let Value::Struct(info_struct) = prop.value {
let skip = match info_struct.first() {
Some(Value::Int(_)) => 1,
_ => 0,
};
let mut iter = info_struct.into_iter().skip(skip);
while let (
Some(Value::String(key)),
Some(Value::String(val)),
) = (iter.next(), iter.next())
{
if key == "device.product.name" {
product_name = Some(val);
break;
}
}
}
}
_ => {}
}
}
Expand All @@ -140,6 +160,7 @@ fn device_enum_route(object_id: ObjectId, param: Object) -> Option<StateEvent> {
available: available?,
profiles: profiles?,
devices: devices?,
product_name,
})
}

Expand Down
1 change: 1 addition & 0 deletions src/wirehose/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub enum StateEvent {
available: bool,
profiles: Vec<i32>,
devices: Vec<i32>,
product_name: Option<String>,
},
DeviceEnumProfile {
object_id: ObjectId,
Expand Down
3 changes: 3 additions & 0 deletions src/wirehose/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct EnumRoute {
pub available: bool,
pub profiles: Vec<i32>,
pub devices: Vec<i32>,
pub product_name: Option<String>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -162,6 +163,7 @@ impl State {
available,
profiles,
devices,
product_name,
} => {
self.device_entry(object_id).enum_routes.insert(
index,
Expand All @@ -171,6 +173,7 @@ impl State {
available,
profiles,
devices,
product_name,
},
);
}
Expand Down
2 changes: 1 addition & 1 deletion wiremix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ keybindings = [
# Streams in the Playback/Recording tabs
stream = [ "{node:node.name}: {node:media.name}" ]
# Endpoints in the Input/Output Devices tabs
endpoint = [ "{device:device.nick}", "{node:node.description}" ]
endpoint = [ "{node:node.nick}", "{device:device.nick}", "{node:node.description}" ]
# Devices in the Configuration tab
device = [ "{device:device.nick}", "{device:device.description}" ]

Expand Down
Loading