Fix: device input name matching
This commit is contained in:
@@ -247,16 +247,16 @@ pub(super) fn handle_engine_page(ctx: &mut InputContext, key: KeyEvent) -> Input
|
|||||||
DevicesFocus::Output => {
|
DevicesFocus::Output => {
|
||||||
let cursor = ctx.app.audio.output_list.cursor;
|
let cursor = ctx.app.audio.output_list.cursor;
|
||||||
if cursor < ctx.app.audio.output_devices.len() {
|
if cursor < ctx.app.audio.output_devices.len() {
|
||||||
let index = ctx.app.audio.output_devices[cursor].index;
|
let name = ctx.app.audio.output_devices[cursor].name.clone();
|
||||||
ctx.dispatch(AppCommand::SetOutputDevice(index.to_string()));
|
ctx.dispatch(AppCommand::SetOutputDevice(name));
|
||||||
ctx.app.save_settings(ctx.link);
|
ctx.app.save_settings(ctx.link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DevicesFocus::Input => {
|
DevicesFocus::Input => {
|
||||||
let cursor = ctx.app.audio.input_list.cursor;
|
let cursor = ctx.app.audio.input_list.cursor;
|
||||||
if cursor < ctx.app.audio.input_devices.len() {
|
if cursor < ctx.app.audio.input_devices.len() {
|
||||||
let index = ctx.app.audio.input_devices[cursor].index;
|
let name = ctx.app.audio.input_devices[cursor].name.clone();
|
||||||
ctx.dispatch(AppCommand::SetInputDevice(index.to_string()));
|
ctx.dispatch(AppCommand::SetInputDevice(name));
|
||||||
ctx.app.save_settings(ctx.link);
|
ctx.app.save_settings(ctx.link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -532,17 +532,21 @@ impl AudioSettings {
|
|||||||
pub fn current_output_device_index(&self) -> usize {
|
pub fn current_output_device_index(&self) -> usize {
|
||||||
match &self.config.output_device {
|
match &self.config.output_device {
|
||||||
Some(spec) => {
|
Some(spec) => {
|
||||||
if let Ok(idx) = spec.parse::<usize>() {
|
let spec_lower = spec.to_lowercase();
|
||||||
self.output_devices
|
self.output_devices
|
||||||
.iter()
|
.iter()
|
||||||
.position(|d| d.index == idx)
|
.position(|d| d.name == *spec)
|
||||||
.unwrap_or(0)
|
.or_else(|| {
|
||||||
} else {
|
self.output_devices
|
||||||
self.output_devices
|
.iter()
|
||||||
.iter()
|
.position(|d| d.name.to_lowercase() == spec_lower)
|
||||||
.position(|d| &d.name == spec)
|
})
|
||||||
.unwrap_or(0)
|
.or_else(|| {
|
||||||
}
|
spec.parse::<usize>().ok().and_then(|idx| {
|
||||||
|
self.output_devices.iter().position(|d| d.index == idx)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.unwrap_or(0)
|
||||||
}
|
}
|
||||||
None => self
|
None => self
|
||||||
.output_devices
|
.output_devices
|
||||||
@@ -555,17 +559,21 @@ impl AudioSettings {
|
|||||||
pub fn current_input_device_index(&self) -> usize {
|
pub fn current_input_device_index(&self) -> usize {
|
||||||
match &self.config.input_device {
|
match &self.config.input_device {
|
||||||
Some(spec) => {
|
Some(spec) => {
|
||||||
if let Ok(idx) = spec.parse::<usize>() {
|
let spec_lower = spec.to_lowercase();
|
||||||
self.input_devices
|
self.input_devices
|
||||||
.iter()
|
.iter()
|
||||||
.position(|d| d.index == idx)
|
.position(|d| d.name == *spec)
|
||||||
.unwrap_or(0)
|
.or_else(|| {
|
||||||
} else {
|
self.input_devices
|
||||||
self.input_devices
|
.iter()
|
||||||
.iter()
|
.position(|d| d.name.to_lowercase() == spec_lower)
|
||||||
.position(|d| &d.name == spec)
|
})
|
||||||
.unwrap_or(0)
|
.or_else(|| {
|
||||||
}
|
spec.parse::<usize>().ok().and_then(|idx| {
|
||||||
|
self.input_devices.iter().position(|d| d.index == idx)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.unwrap_or(0)
|
||||||
}
|
}
|
||||||
None => self
|
None => self
|
||||||
.input_devices
|
.input_devices
|
||||||
|
|||||||
Reference in New Issue
Block a user