Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable avahi support for discovery #201

Closed
wants to merge 2 commits into from
Closed

Re-enable avahi support for discovery #201

wants to merge 2 commits into from

Conversation

awiouy
Copy link
Contributor

@awiouy awiouy commented Jun 15, 2017

This pull request allows to select whether discovery is built based on mdns (by default) or on avahi.
I only streamlined Dockerfile and docker-build-avahi.sh.
Many thanks to @shanemeagher, who did the heavy lifting.

rust-mdns is still the default and can be specified explicitly with --with-rust-mdns switch.
Added --with-avahi switch to build librespot to use avahi for discovery using dns-sd package.
@awiouy
Copy link
Contributor Author

awiouy commented Jun 20, 2017

This works fine here: LibreELEC/LibreELEC.tv#1622

@marcelveldt
Copy link

you should probably extend the code some more because when one doesn't provide any of the discovery options, the code won't build. If you add a few checks more it will also build without any discovery, for example on windows.

e.g.:

#[cfg(any(feature = "with-rust-mdns", feature = "with-avahi"))]
use librespot::authentication::discovery::{discovery, DiscoveryStream};

@awiouy
Copy link
Contributor Author

awiouy commented Jun 25, 2017

Thanks for the heads-up @marcelveldt
My Rust is too basic to do it myself, though.
If you create a commit in your github, I will add it to this pull request.
Thanks in advance.

@shanemeagher
Copy link
Contributor

@awiouy @marcelveldt I've updated my commits so that rust-mdns is used by default, even if --no-default-features is set. This keeps current behaviour for building librespot the same (also, my rust wasn't sufficient to build librespot with discovery disabled completely).

If someone want's to build librespot to use with avahi now, the with-avahi feature replaces rust-mdns with dns-sd.

I've also rebased on master and squashed it to one commit: shanemeagher@6f515f4

Copy link
Owner

@plietar plietar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me like this would fail to build if both are enabled.

Instead it should pick one of the two, say the dns-sd one. You can use https://github.com/alexcrichton/cfg-if to make it easier


default = ["portaudio-backend"]
default = ["portaudio-backend","with-rust-mdns"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: there should be a space between the two items.

@@ -71,8 +72,10 @@ portaudio-backend = ["portaudio-rs"]
pulseaudio-backend = ["libpulse-sys"]

with-tremor = ["tremor"]
with-rust-mdns = ["mdns"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename the feature to with-internal-mdns

@@ -71,8 +72,10 @@ portaudio-backend = ["portaudio-rs"]
pulseaudio-backend = ["libpulse-sys"]

with-tremor = ["tremor"]
with-rust-mdns = ["mdns"]
with-avahi = ["dns-sd"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, with-external-mdns.

dns-sd is actually Apple's API.
Avahi provides a compatibility layer between the two

@marcelveldt
Copy link

If I may chime in too, I don't think it's a great idea that it will force one of the two with no-default-features, in my case for example I'm also compiling for Windows and I need to comment out the dns stuff. So better to specify both of them as a separate feature but pick one as the default. And off course the changes in the code that it will only load (the correct) dns/discovery code if the feature is actually enabled.

I'm really busy atm otherwise I would have provided the PR

@plietar
Copy link
Owner

plietar commented Jun 29, 2017

@marcelveldt currently if --no-default-features is used and neither is chosen explicitly, then it won't include any backend and build fine on Windows.

On the other hand, if both are enabled, it will fail to build, which is a problem to me

@shanemeagher
Copy link
Contributor

@plietar finally getting a chance to revisit this.

Have made most of your suggested changes but have a (probably simple) problem in cargo.toml where I currently have the following features:

with-internal-mdns  = ["mdns"]
with-external-mdns  = ["dns-sd"]

If neither is specified, cargo tries to build with mdns but as mdns is only specified by with-internal-mdns, it fails. I could add with-internal-mdns to the default features but if --no-default-features is used, it will still fail.

Any suggestions?

@plietar
Copy link
Owner

plietar commented Aug 3, 2017

@shanemeagher Did you use #[cfg(mdns)] around the extern crate mdns ?

@shanemeagher
Copy link
Contributor

@plietar I've started a new PR #246 to push the code directly. This should address all your comments above.

@awiouy
Copy link
Contributor Author

awiouy commented Sep 6, 2017

Feature taken over by #246. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants