mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-04 02:09:26 +02:00
Avoid crashing when Avahi is not available
When librespot is built with Avahi turned on, it will crash if Avahi is later not available at runtime. This change avoids it crashing hard when Avahi is not available; librespot will merely warn of the issue. This affects some distribution packages too, where the maintainer might prefer leaving Avahi support enabled, but many setups don't (or can't) run Avahi. Co-authored-by: Nick Steel <nick@nsteel.co.uk>
This commit is contained in:
parent
7efc62b9ca
commit
c4af90f5fe
3 changed files with 11 additions and 10 deletions
17
src/main.rs
17
src/main.rs
|
@ -1581,19 +1581,15 @@ async fn main() {
|
|||
|
||||
if setup.enable_discovery {
|
||||
let device_id = setup.session_config.device_id.clone();
|
||||
|
||||
discovery = match librespot::discovery::Discovery::builder(device_id)
|
||||
match librespot::discovery::Discovery::builder(device_id)
|
||||
.name(setup.connect_config.name.clone())
|
||||
.device_type(setup.connect_config.device_type)
|
||||
.port(setup.zeroconf_port)
|
||||
.launch()
|
||||
{
|
||||
Ok(d) => Some(d),
|
||||
Err(e) => {
|
||||
error!("Discovery Error: {}", e);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
Ok(d) => discovery = Some(d),
|
||||
Err(err) => warn!("Could not initialise discovery: {}.", err),
|
||||
};
|
||||
}
|
||||
|
||||
if let Some(credentials) = setup.credentials {
|
||||
|
@ -1606,6 +1602,11 @@ async fn main() {
|
|||
)
|
||||
.fuse(),
|
||||
);
|
||||
} else if discovery.is_none() {
|
||||
error!(
|
||||
"Discovery is unavailable and no credentials provided. Authentication is not possible."
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
loop {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue