uint32_t AirPlayLatency; // supplied with --AirPlayLatency option
uint32_t ForkedDaapdLatency; // supplied with --ForkedDaapdLatency option
int daemonise;
- int statistics_requested;
+ int statistics_requested,use_negotiated_latencies;
char *cmd_start, *cmd_stop;
int cmd_blocking;
int tolerance; // allow this much drift before attempting to correct it
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.50])
-AC_INIT([shairport-sync], [2.5.0.5], [mikebrady@eircom.net])
+AC_INIT([shairport-sync], [2.5.0.6], [mikebrady@eircom.net])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([shairport.c])
AC_CONFIG_HEADERS([config.h])
time_of_last_audio_packet = get_absolute_time_in_fp();
if (connection_state_to_output) { // if we are supposed to be processing these packets
- if (flush_rtp_timestamp != 0)
- debug(1,"Flush_rtp_timestamp is %u",flush_rtp_timestamp);
+// if (flush_rtp_timestamp != 0)
+// debug(1,"Flush_rtp_timestamp is %u",flush_rtp_timestamp);
-// if ((flush_rtp_timestamp != 0) &&
- if ((0) &&
+ if ((flush_rtp_timestamp != 0) &&
((timestamp == flush_rtp_timestamp) || seq32_order(timestamp, flush_rtp_timestamp))) {
debug(2, "Dropping flushed packet in player_put_packet, seqno %u, timestamp %u, flushing to "
"timestamp: %u.",
}
void player_flush(uint32_t timestamp) {
- debug(1,"Flush requested up to %u. It seems as if 0 is special.",timestamp);
+ // debug(1,"Flush requested up to %u. It seems as if 0 is special.",timestamp);
pthread_mutex_lock(&flush_mutex);
flush_requested = 1;
// if (timestamp!=0)
rtp_timestamp_less_latency = ntohl(*((uint32_t *)&packet[4]));
sync_rtp_timestamp = ntohl(*((uint32_t *)&packet[16]));
- debug(1,"Latency is %u frames.",sync_rtp_timestamp-rtp_timestamp_less_latency);
-
+ if (config.use_negotiated_latencies) {
+ uint32_t la = sync_rtp_timestamp-rtp_timestamp_less_latency+11025;
+ if (la!=config.latency) {
+ config.latency = la;
+ debug(1,"Using negotiated latency of %u frames.",config.latency);
+ }
+ }
+
if (packet[0] & 0x10) {
// if it's a packet right after a flush or resume
sync_rtp_timestamp += 352; // add frame_size -- can't see a reference to this anywhere,
}
static void handle_record(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) {
- debug(1,"Handle Record");
+ //debug(1,"Handle Record");
resp->respcode = 200;
// I think this is for telling the client what the asbsolute minimum latency actually is,
// and when the client specifies a latency, it should be added to this figure.
// Thus, AirPlay's latency figure of 77175, when added to 11025 gives you exactly 88200
// and iTunes' latency figure of 88553, when added to 11025 gives you 99578, pretty close to the 99400 we guessed.
- msg_add_header(resp, "Audio-Latency", "88200");
+ msg_add_header(resp, "Audio-Latency", "11025");
char *p;
uint32_t rtptime = 0;
}
static void handle_setup(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) {
- debug(1,"Handle Setup");
+ // debug(1,"Handle Setup");
int cport, tport;
int lsport, lcport, ltport;
uint32_t active_remote = 0;
// It's probably better to compensate for a delay in the output device using the alsa "audio_backend_latency_offset" setting -- see below.
latencies =
{
+// use_negotiated_latencies = "no"; // set this to "yes" to negotiate latencies with the client, and ignore the static settings listed below
// default = 88200; // used for unrecognised sources and for iTunes up to and including iTunes 9.X.
// itunes = 99400; // used for iTunes 10 or later
// airplay = 88200;
die("Invalid ignore_volume_control option choice \"%s\". It should be \"yes\" or \"no\"");
}
+ /* Get the dynamic latencies setting. */
+ if (config_lookup_string(config.cfg, "latencies.use_negotiated_latencies", &str)) {
+ if (strcasecmp(str, "no") == 0)
+ config.use_negotiated_latencies = 0;
+ else if (strcasecmp(str, "yes") == 0)
+ config.use_negotiated_latencies = 1;
+ else
+ die("Invalid use_negotiated_latencies option choice \"%s\". It should be \"yes\" or \"no\"");
+ }
+
/* Get the default latency. */
if (config_lookup_int(config.cfg, "latencies.default", &value))
config.latency = value;
debug(2, "audio backend desired buffer length is %d.",
config.audio_backend_buffer_desired_length);
debug(2, "audio backend latency offset is %d.", config.audio_backend_latency_offset);
+ debug(2, "use_negotiated_latencies %d.", config.use_negotiated_latencies);
char *realConfigPath = realpath(config.configfile,NULL);
if (realConfigPath) {