Merge pull request #997 from WhyNotHugo/avoid-unwrap-disco

Avoid crash when Avahi is not available
This commit is contained in:
Roderick van Domburg 2022-05-20 11:19:36 +02:00 committed by GitHub
commit be9a393b2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 10 deletions

View file

@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [playback] Adhere to ReplayGain spec when calculating gain normalisation factor. - [playback] Adhere to ReplayGain spec when calculating gain normalisation factor.
- [playback] `alsa`: Use `--volume-range` overrides for softvol controls - [playback] `alsa`: Use `--volume-range` overrides for softvol controls
- [connect] Don't panic when activating shuffle without previous interaction. - [connect] Don't panic when activating shuffle without previous interaction.
- [main] Fix crash when built with Avahi support but Avahi is locally unavailable.
### Removed ### Removed
- [playback] `alsamixer`: previously deprecated option `mixer-card` has been removed. - [playback] `alsamixer`: previously deprecated option `mixer-card` has been removed.

View file

@ -111,8 +111,7 @@ impl Builder {
None, None,
port, port,
&["VERSION=1.0", "CPath=/"], &["VERSION=1.0", "CPath=/"],
) ).map_err(|e| Error::DnsSdError(io::Error::new(io::ErrorKind::Unsupported, e)))?;
.unwrap();
} else { } else {
let responder = libmdns::Responder::spawn(&tokio::runtime::Handle::current())?; let responder = libmdns::Responder::spawn(&tokio::runtime::Handle::current())?;

View file

@ -1581,19 +1581,15 @@ async fn main() {
if setup.enable_discovery { if setup.enable_discovery {
let device_id = setup.session_config.device_id.clone(); let device_id = setup.session_config.device_id.clone();
match librespot::discovery::Discovery::builder(device_id)
discovery = match librespot::discovery::Discovery::builder(device_id)
.name(setup.connect_config.name.clone()) .name(setup.connect_config.name.clone())
.device_type(setup.connect_config.device_type) .device_type(setup.connect_config.device_type)
.port(setup.zeroconf_port) .port(setup.zeroconf_port)
.launch() .launch()
{ {
Ok(d) => Some(d), Ok(d) => discovery = Some(d),
Err(e) => { Err(err) => warn!("Could not initialise discovery: {}.", err),
error!("Discovery Error: {}", e); };
exit(1);
}
}
} }
if let Some(credentials) = setup.credentials { if let Some(credentials) = setup.credentials {
@ -1606,6 +1602,11 @@ async fn main() {
) )
.fuse(), .fuse(),
); );
} else if discovery.is_none() {
error!(
"Discovery is unavailable and no credentials provided. Authentication is not possible."
);
exit(1);
} }
loop { loop {