fix: retain M13 media availability when a player is unresponsive
Verify: private_bus_extended regression failed before native availability reporting; dbus-run-session -- cargo test -p fader_master --lib private_bus -- --ignored: 2 passed after fix; cargo fmt --all passed. Session-bus availability is independent of successful player discovery.
This commit is contained in:
parent
a31929ec08
commit
0f59b25fc9
|
|
@ -11,6 +11,9 @@ use std::{
|
|||
};
|
||||
|
||||
trait Adapter {
|
||||
fn available(&self) -> bool {
|
||||
false
|
||||
}
|
||||
fn discover(&mut self) -> Result<Vec<Player>, String>;
|
||||
fn execute(&mut self, player: &Player, action: &Action) -> Result<(), String>;
|
||||
}
|
||||
|
|
@ -94,6 +97,7 @@ impl MediaRuntime {
|
|||
Err(mpsc::RecvTimeoutError::Disconnected) => break,
|
||||
};
|
||||
if let Ok(mut state) = latest.lock() {
|
||||
state.available |= adapter.available();
|
||||
match result {
|
||||
Ok(players) => {
|
||||
if is_command {
|
||||
|
|
|
|||
|
|
@ -128,6 +128,10 @@ impl DbusAdapter {
|
|||
}
|
||||
|
||||
impl Adapter for DbusAdapter {
|
||||
fn available(&self) -> bool {
|
||||
self.connection.is_some()
|
||||
}
|
||||
|
||||
fn discover(&mut self) -> Result<Vec<Player>, String> {
|
||||
let connection = self.connection()?;
|
||||
let bus = connection.with_proxy("org.freedesktop.DBus", "/org/freedesktop/DBus", TIMEOUT);
|
||||
|
|
@ -478,6 +482,7 @@ mod tests {
|
|||
fixture.state.lock().unwrap().silent = true;
|
||||
let started = Instant::now();
|
||||
assert!(execute_selected(&mut adapter, &selector, &Action::Play).is_err());
|
||||
assert!(adapter.available()); // A broken player does not mean D-Bus support is absent.
|
||||
assert!(started.elapsed() < Duration::from_secs(3));
|
||||
fixture.state.lock().unwrap().silent = false;
|
||||
assert!(execute_selected(&mut adapter, &selector, &Action::Play).is_ok());
|
||||
|
|
|
|||
Loading…
Reference in New Issue