From: Mike Brady Date: Fri, 1 Apr 2016 15:30:36 +0000 (+0100) Subject: Add ability to change regtype; clean up some diagnostic messages. X-Git-Tag: 2.9.5.7~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfadbf38013920866feb518168df8295e272da26;p=thirdparty%2Fshairport-sync.git Add ability to change regtype; clean up some diagnostic messages. --- diff --git a/configure.ac b/configure.ac index 05563e51..4dd5ec10 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.50]) -AC_INIT([shairport-sync], [2.9.5.4], [mikebrady@eircom.net]) +AC_INIT([shairport-sync], [2.9.5.5], [mikebrady@eircom.net]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([shairport.c]) AC_CONFIG_HEADERS([config.h]) diff --git a/mdns_dns_sd.c b/mdns_dns_sd.c index 114bb991..216f0571 100644 --- a/mdns_dns_sd.c +++ b/mdns_dns_sd.c @@ -69,7 +69,7 @@ static int mdns_dns_sd_register(char *apname, int port) { } DNSServiceErrorType error; - error = DNSServiceRegister(&service, 0, kDNSServiceInterfaceIndexAny, apname, "_raop._tcp", "", + error = DNSServiceRegister(&service, 0, kDNSServiceInterfaceIndexAny, apname, config.regtype, "", NULL, htons((uint16_t)port), length, buf, NULL, NULL); free(buf); diff --git a/mdns_external.c b/mdns_external.c index f9ba20c6..c3b5dc1b 100644 --- a/mdns_external.c +++ b/mdns_external.c @@ -87,10 +87,10 @@ static int mdns_external_avahi_register(char *apname, int port) { char mdns_port[6]; sprintf(mdns_port, "%d", config.port); - char *argvwithoutmetadata[] = {NULL, apname, "_raop._tcp", mdns_port, + char *argvwithoutmetadata[] = {NULL, apname, config.regtype, mdns_port, MDNS_RECORD_WITHOUT_METADATA, NULL}; #ifdef CONFIG_METADATA - char *argvwithmetadata[] = {NULL, apname, "_raop._tcp", mdns_port, MDNS_RECORD_WITH_METADATA, + char *argvwithmetadata[] = {NULL, apname, config.regtype, mdns_port, MDNS_RECORD_WITH_METADATA, NULL}; #endif char **argv; @@ -126,11 +126,11 @@ static int mdns_external_dns_sd_register(char *apname, int port) { char mdns_port[6]; sprintf(mdns_port, "%d", config.port); - char *argvwithoutmetadata[] = {NULL, apname, "_raop._tcp", mdns_port, + char *argvwithoutmetadata[] = {NULL, apname, config.regtype, mdns_port, MDNS_RECORD_WITHOUT_METADATA, NULL}; #ifdef CONFIG_METADATA - char *argvwithmetadata[] = {NULL, apname, "_raop._tcp", mdns_port, MDNS_RECORD_WITH_METADATA, + char *argvwithmetadata[] = {NULL, apname, config.regtype, mdns_port, MDNS_RECORD_WITH_METADATA, NULL}; #endif diff --git a/mdns_tinysvcmdns.c b/mdns_tinysvcmdns.c index 9452c1f8..60bdf360 100644 --- a/mdns_tinysvcmdns.c +++ b/mdns_tinysvcmdns.c @@ -124,12 +124,20 @@ static int mdns_tinysvcmdns_register(char *apname, int port) { #endif txt = txtwithoutmetadata; + + char* extendedregtype = malloc(strlen(config.regtype)+strlen(".local")+1); - struct mdns_service *svc = - mdnsd_register_svc(svr, apname, "_raop._tcp.local", port, NULL, - (const char **)txt); // TTL should be 75 minutes, i.e. 4500 seconds + if (extendedregtype==NULL) + die("tinysvcmdns: could not allocated memory to request a Zeroconf service"); + + strcpy(extendedregtype,config.regtype); + strcat(extendedregtype,".local"); + struct mdns_service *svc = mdnsd_register_svc(svr, apname, extendedregtype, port, NULL, + (const char **)txt); // TTL should be 75 minutes, i.e. 4500 seconds mdns_service_destroy(svc); + + free(extendedregtype); return 0; } diff --git a/scripts/shairport-sync.conf b/scripts/shairport-sync.conf index 81090364..050ee364 100644 --- a/scripts/shairport-sync.conf +++ b/scripts/shairport-sync.conf @@ -18,6 +18,7 @@ general = // log_verbosity = 0; // "0" means no debug verbosity, "3" is most verbose. // ignore_volume_control = "no"; // set this to "yes" if you want the volume to be at 100% no matter what the source's volume control is set to. // volume_range_db = 60 ; // use this to set the range, in dB, you want between the maximum volume and the minimum volume. Range is 30 to 150 dB. Leave it commented out to use mixer's native range. +// regtype = "_raop._tcp"; // Use this advanced setting to set the service type and transport to be advertised by Zeroconf/Bonjour. Default is "_raop._tcp". }; // How to deal with metadata, including artwork diff --git a/scripts/shairport-sync.conf~ b/scripts/shairport-sync.conf~ new file mode 100644 index 00000000..420bc6a3 --- /dev/null +++ b/scripts/shairport-sync.conf~ @@ -0,0 +1,81 @@ +// Sample Configuration File for Shairport Sync +// Commented out settings are generally the defaults, except where noted. + +// General Settings +general = +{ +// name = "Shairport Sync Player"; // This is the name the service will advertise to iTunes. The default is "Shairport Sync on " +// password = "secret"; // leave this commented out if you don't want to require a password +// interpolation = "basic"; // aka "stuffing". Default is "basic", alternative is "soxr". Use "soxr" only if you have a reasonably fast processor. +// output_backend = "alsa"; // Run "shairport-sync -h" to get a list of all output_backends, e.g. "alsa", "pipe", "stdout". The default is the first one. +// mdns_backend = "avahi"; // Run "shairport-sync -h" to get a list of all mdns_backends. The default is the first one. +// port = 5000; // Listen for service requests on this port +// udp_port_base = 6001; // start allocating UDP ports from this port number when needed +// udp_port_range = 100; // look for free ports in this number of places, starting at the UDP port base (only three are needed). +// statistics = "no"; // set to "yes" to print statistics in the log +// drift = 88; // allow this number of frames of drift away from exact synchronisation before attempting to correct it +// resync_threshold = 2205; // a synchronisation error greater than this will cause resynchronisation; 0 disables it +// log_verbosity = 0; // "0" means no debug verbosity, "3" is most verbose. +// ignore_volume_control = "no"; // set this to "yes" if you want the volume to be at 100% no matter what the source's volume control is set to. +// volume_range_db = 60 ; // use this to set the range, in dB, you want between the maximum volume and the minimum volume. Range is 30 to 150 dB. Leave it commented out to use mixer's native range. +// regtype = "_raop._tcp"; // Use this advanced setting to set the service type and transport to be advertised by zeroconf/bonjour. Default is "_raop._tcp". +}; + +// How to deal with metadata, including artwork +metadata = +{ +// enabled = "no"; // et to yes to get Shairport Sync to solicit metadata from the source and to pass it on via a pipe +// include_cover_art = "no"; // set to "yes" to get Shairport Sync to solicit cover art from the source and pass it via the pipe. You must also set "enabled" to "yes". +// pipe_name = "/tmp/shairport-sync-metadata"; +}; + +// Advanced parameters for controlling how a Shairport Sync runs +sessioncontrol = +{ +// run_this_before_play_begins = "/full/path/to/application and args"; // make sure the application has executable permission. It it's a script, include the #!... stuff on the first line +// run_this_after_play_ends = "/full/path/to/application and args"; // make sure the application has executable permission. It it's a script, include the #!... stuff on the first line +// wait_for_completion = "no"; // set to "yes" to get Shairport Sync to wait until the "run_this..." applications have terminated before continuing +// allow_session_interruption = "no"; // set to "yes" to allow another device to interrupt Shairport Sync while it's playing from an existing audio source +// session_timeout = 120; // wait for this number of seconds after a source disappears before terminating the session and becoming available again. +}; + +// Back End Settings + +// These are parameters for the "alsa" audio back end, the only back end that supports synchronised audio. +alsa = +{ +// output_device = "default"; // the name of the alsa output device. Use "alsamixer" or "aplay" to find out the names of devices, mixers, etc. +// mixer_control_name = "PCM"; // the name of the mixer to use to adjust output volume. If not specified, volume in adjusted in software. +// mixer_device = "default"; // the mixer_device default is whatever the output_device is. Normally you wouldn't have to use this. +// audio_backend_latency_offset = 0; // Set this offset to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -4410. +// audio_backend_buffer_desired_length = 6615; // If set too small, buffer underflow occurs on low-powered machines. Too long and the response times with software mixer become annoying. +// disable_synchronization = "no"; // Set to "yes" to disable synchronization. Default is "no". +// period_size = ; // Use this optional advanced setting to set the alsa period size near to this value +// buffer_size = ; // Use this optional advanced setting to set the alsa buffer size near to this value +}; + +// These are parameters for the "pipe" audio back end, a back end that directs raw CD-style audio output to a pipe. No interpolation is done. +pipe = +{ +// name = "/path/to/pipe"; // there is no default pipe name for the output +// audio_backend_latency_offset = 0; // Set this offset to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -4410. +// audio_backend_buffer_desired_length = 44100; // Having started to send audio at the right time, send all subsequent audio this many frames ahead of time, creating a buffer this size. +}; + +// These are parameters for the "stdout" audio back end, a back end that directs raw CD-style audio output to stdout. No interpolation is done. +stdout = +{ +// audio_backend_latency_offset = 0; // Set this offset to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -4410. +// audio_backend_buffer_desired_length = 44100; // Having started to send audio at the right time, send all subsequent audio this many frames ahead of time, creating a buffer this size. +}; + +// These are parameters for the "ao" audio back end. No interpolation is done. +ao = +{ +// audio_backend_latency_offset = 0; // Set this offset to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -4410. +// audio_backend_buffer_desired_length = 44100; // Having started to send audio at the right time, send all subsequent audio this many frames ahead of time, creating a buffer this size. +}; + +// Static latency settings are deprecated and the settings have been removed. + + diff --git a/shairport.c b/shairport.c index d25d29fb..931c270b 100644 --- a/shairport.c +++ b/shairport.c @@ -411,6 +411,13 @@ int parse_options(int argc, char **argv) { die("Invalid ignore_volume_control option choice \"%s\". It should be \"yes\" or \"no\""); } + /* Get the regtype -- the service type and protocol, separated by a dot. Default is "_raop._tcp" */ + if (config_lookup_string(config.cfg, "general.regtype", &str)) + config.regtype = strdup(str); + else + config.regtype = strdup("_raop._tcp"); + + /* Get the volume range, in dB, that should be used If not set, it means you just use the range set by the mixer. */ if (config_lookup_int(config.cfg, "general.volume_range_db", &value)) { if ((value < 30) || (value > 150)) @@ -958,6 +965,7 @@ int main(int argc, char **argv) { config.audio_backend_buffer_desired_length); debug(1, "audio backend latency offset is %d.", config.audio_backend_latency_offset); debug(1, "volume range in dB (zero means use the range specified by the mixer): %u.", config.volume_range_db); + debug(1, "zeroconf regtype is \"%s\".", config.regtype); char *realConfigPath = realpath(config.configfile,NULL); if (realConfigPath) {