@@ -16,7 +16,6 @@ use std::io;
1616use std:: pin:: Pin ;
1717use std:: task:: { Context , Poll } ;
1818
19- use cfg_if:: cfg_if;
2019use futures_core:: Stream ;
2120use librespot_core as core;
2221use thiserror:: Error ;
@@ -100,29 +99,24 @@ impl Builder {
10099 let name = self . server_config . name . clone ( ) . into_owned ( ) ;
101100 let server = DiscoveryServer :: new ( self . server_config , & mut port) ?;
102101
103- let svc;
104-
105- cfg_if ! {
106- if #[ cfg( feature = "with-dns-sd" ) ] {
107- svc = dns_sd:: DNSService :: register(
108- Some ( name. as_ref( ) ) ,
109- "_spotify-connect._tcp" ,
110- None ,
111- None ,
112- port,
113- & [ "VERSION=1.0" , "CPath=/" ] ,
114- ) . map_err( |e| Error :: DnsSdError ( io:: Error :: new( io:: ErrorKind :: Unsupported , e) ) ) ?;
115-
116- } else {
117- let responder = libmdns:: Responder :: spawn( & tokio:: runtime:: Handle :: current( ) ) ?;
118- svc = responder. register(
119- "_spotify-connect._tcp" . to_owned( ) ,
120- name,
121- port,
122- & [ "VERSION=1.0" , "CPath=/" ] ,
123- )
124- }
125- } ;
102+ #[ cfg( feature = "with-dns-sd" ) ]
103+ let svc = dns_sd:: DNSService :: register (
104+ Some ( name. as_ref ( ) ) ,
105+ "_spotify-connect._tcp" ,
106+ None ,
107+ None ,
108+ port,
109+ & [ "VERSION=1.0" , "CPath=/" ] ,
110+ )
111+ . map_err ( |e| Error :: DnsSdError ( io:: Error :: new ( io:: ErrorKind :: Unsupported , e) ) ) ?;
112+
113+ #[ cfg( not( feature = "with-dns-sd" ) ) ]
114+ let svc = libmdns:: Responder :: spawn ( & tokio:: runtime:: Handle :: current ( ) ) ?. register (
115+ "_spotify-connect._tcp" . to_owned ( ) ,
116+ name,
117+ port,
118+ & [ "VERSION=1.0" , "CPath=/" ] ,
119+ ) ;
126120
127121 Ok ( Discovery { server, _svc : svc } )
128122 }
0 commit comments