Skip to content

Commit b79eb0b

Browse files
committed
fix: ignore all errors on getting the controls
1 parent 32f5d3a commit b79eb0b

2 files changed

Lines changed: 11 additions & 23 deletions

File tree

src/video/ir/enabler.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,9 @@ impl Enabler {
8181
}
8282

8383
/// Gets all the writable controls and not blacklisted controls from the device.
84-
fn controls(&self) -> Result<Vec<XuControl>> {
85-
let controls = self
86-
.device
84+
fn controls(&self) -> Vec<XuControl> {
85+
self.device
8786
.controls()
88-
.context("failed to get device controls")?
8987
.into_iter()
9088
.filter(|c| {
9189
if c.writable() && !self.configuration.is_blacklisted(c) {
@@ -95,8 +93,7 @@ impl Enabler {
9593
false
9694
}
9795
})
98-
.collect();
99-
Ok(controls)
96+
.collect()
10097
}
10198

10299
/// Tries to find a configuration for the controls that enables the IR emitter(s).
@@ -108,7 +105,7 @@ impl Enabler {
108105
bail!("the IR emitter is already working");
109106
}
110107

111-
let mut controls = self.controls()?;
108+
let mut controls = self.controls();
112109
self.send(Message::Controls(controls.clone())).await?;
113110

114111
for ctrl in &mut controls {

src/video/uvc/device.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::video::uvc::XuControl;
22

3-
use std::io::{Error, ErrorKind, Result};
3+
use std::io::{Error, Result};
44
use std::os::fd::AsFd;
55
use std::path::{Path, PathBuf};
66

@@ -80,23 +80,19 @@ impl Device {
8080
}
8181

8282
/// Tries to get all the control descriptions of the device.
83-
///
84-
/// An empty list will be returned if the device has no controls.
85-
pub fn controls(&self) -> Result<Vec<XuControl>> {
83+
/// An empty list will be returned if the device no controls can be found
84+
pub fn controls(&self) -> Vec<XuControl> {
8685
let mut controls = Vec::new();
8786
// Search for all possible combination of unit and selector
8887
for unit in 0..255 {
8988
for selector in 0..255 {
9089
match self.find_control(unit, selector) {
9190
Ok(control) => controls.push(control),
92-
Err(err) => match err.kind() {
93-
ErrorKind::NotFound | ErrorKind::PermissionDenied => {}
94-
_ => return Err(err),
95-
},
91+
Err(_) => {} // Ignore all errors
9692
}
9793
}
9894
}
99-
Ok(controls)
95+
controls
10096
}
10197

10298
/// Tries to apply the control to the device.
@@ -204,13 +200,8 @@ impl std::fmt::Display for Device {
204200
.as_ref()
205201
.map_or("unknown".into(), |p| p.display().to_string())
206202
)?;
207-
match self.controls() {
208-
Err(err) => writeln!(f, " Failed to get the controls: {err:?}")?,
209-
Ok(controls) => {
210-
for control in controls {
211-
writeln!(f, " {}", control)?;
212-
}
213-
}
203+
for control in self.controls() {
204+
writeln!(f, " {}", control)?;
214205
}
215206
Ok(())
216207
}

0 commit comments

Comments
 (0)