From: Mike Brady Date: Mon, 23 May 2016 13:03:38 +0000 (+0100) Subject: Add setting for the time to wait for the metadata pipe to come ready, otherwise give... X-Git-Tag: 2.8.3.11~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f36352dc4ece27fda24ef736183b8ff5729b8c96;p=thirdparty%2Fshairport-sync.git Add setting for the time to wait for the metadata pipe to come ready, otherwise give up. Default 5,000 milliseconds. --- diff --git a/common.c b/common.c index 6800de6f..d7c32f2f 100644 --- a/common.c +++ b/common.c @@ -514,7 +514,7 @@ uint64_t get_absolute_time_in_fp() { } ssize_t non_blocking_write(int fd, const void *buf, size_t count) { - void *ibuf = buf; + void *ibuf = (void *)buf; size_t bytes_remaining = count; int rc = 0; struct pollfd ufds[1]; @@ -522,11 +522,11 @@ ssize_t non_blocking_write(int fd, const void *buf, size_t count) { // check that we can do some writing ufds[0].fd = fd; ufds[0].events = POLLOUT; - rc = poll(ufds, 1, 5000); + rc = poll(ufds, 1, config.metadata_pipe_timeout); if (rc < 0) { debug(1, "error waiting for pipe to become ready for writing..."); } else if (rc == 0) { - debug(1, "timeout waiting for pipe to become ready for writing"); + warn("timeout waiting for pipe to become ready for writing"); rc = -2; } else { //rc > 0, implying it might be ready size_t bytes_written = write(fd,ibuf,bytes_remaining); diff --git a/common.h b/common.h index dc44af4c..5924be79 100644 --- a/common.h +++ b/common.h @@ -54,6 +54,7 @@ typedef struct { char *service_name; // the name for the shairport service, e.g. "Shairport Sync Version %v running on host %h" #ifdef CONFIG_METADATA int metadata_enabled; + int metadata_pipe_timeout; // in milliseconds char *metadata_pipename; char *metadata_sockaddr; int metadata_sockport; @@ -97,9 +98,8 @@ typedef struct { char *regtype; // The regtype is the service type followed by the protocol, separated by a dot, by default “_raop._tcp.”. long audio_backend_buffer_desired_length; // this will be the desired number of frames in the // audio backend buffer -- the DAC buffer for ALSA - long audio_backend_latency_offset; // this will be the offset to compensate for any fixed latency + long audio_backend_latency_offset; // this will be the offset to compensate for any fixed latency there might be in the audio path uint32_t volume_range_db; // the range, in dB, from max dB to min dB. Zero means use the mixer's native range. - // there might be in the audio } shairport_cfg; // true if Shairport Sync is supposed to be sending output to the output device, false otherwise diff --git a/configure.ac b/configure.ac index dc9d7236..d52a032f 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.8.3.10], [mikebrady@eircom.net]) +AC_INIT([shairport-sync], [2.8.3.11], [mikebrady@eircom.net]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([shairport.c]) AC_CONFIG_HEADERS([config.h]) diff --git a/scripts/shairport-sync.conf b/scripts/shairport-sync.conf index 4dd57505..ec0ce541 100644 --- a/scripts/shairport-sync.conf +++ b/scripts/shairport-sync.conf @@ -34,6 +34,7 @@ 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"; +// pipe_timeout = 5000; // wait for this number of milliseconds for a blocked pipe to unblock before giving up // socket_address = "226.0.0.1"; // if set to a host name or IP address, UDP packets containing metadata will be sent to this address. May be a multicast address. "socket-port" must be non-zero and "enabled" must be set to yes" // socket_port = "5555"; // if socket_address is set, the port to send UDP packets to // socket_msglength = "65000"; // the maximum packet size for any UDP metadata. This will be clipped to be between 500 or 65000. The default is 500. diff --git a/shairport.c b/shairport.c index b79788e9..8c80bfec 100644 --- a/shairport.c +++ b/shairport.c @@ -490,6 +490,15 @@ int parse_options(int argc, char **argv) { if (config_lookup_int(config.cfg, "metadata.socket_msglength", &value)) { config.metadata_sockmsglength = value < 500 ? 500 : value > 65000 ? 65000 : value; } + if (config_lookup_int(config.cfg, "metadata.pipe_timeout", &value)) { + + if ((value < 1) || (value > 150000)) + die("Invalid timeout range \"%sd\". It should be in the range 1 to 150,000 milliseconds.", + value); + else + config.metadata_pipe_timeout = value; + } + #endif if (config_lookup_string(config.cfg, "sessioncontrol.run_this_before_play_begins", &str)) { @@ -754,6 +763,7 @@ int main(int argc, char **argv) { //snprintf(config.service_name, 20 + 100, "Shairport Sync on %s", hostname); set_requested_connection_state_to_output(1); // we expect to be able to connect to the output device config.audio_backend_buffer_desired_length = 6615; // 0.15 seconds. + config.metadata_pipe_timeout = 5000; //milliseconds config.udp_port_base = 6001; config.udp_port_range = 100;