char *mdns_name;
mdns_backend *mdns;
int buffer_start_fill;
- int64_t latency;
int64_t userSuppliedLatency; // overrides all other latencies -- use with caution
int64_t fixedLatencyOffset; // add this to all automatic latencies supplied to get the actual total latency
// the total latency will be limited to the min and max-latency values, if supplied
// debug(1, "Output sample ratio is %d", conn->output_sample_ratio);
int64_t delta = (conn->first_packet_timestamp - reference_timestamp) +
- config.latency * conn->output_sample_ratio +
+ conn->latency * conn->output_sample_ratio +
(int64_t)(config.audio_backend_latency_offset * config.output_rate);
if (delta >= 0) {
if (conn->first_packet_time_to_play != 0) {
// recalculate conn->first_packet_time_to_play -- the latency might change
int64_t delta = (conn->first_packet_timestamp - reference_timestamp) +
- config.latency * conn->output_sample_ratio +
+ conn->latency * conn->output_sample_ratio +
(int64_t)(config.audio_backend_latency_offset * config.output_rate);
if (delta >= 0) {
int64_t packet_timestamp = curframe->timestamp; // types okay
int64_t delta = packet_timestamp - reference_timestamp;
int64_t offset =
- config.latency * conn->output_sample_ratio +
+ conn->latency * conn->output_sample_ratio +
(int64_t)(config.audio_backend_latency_offset * config.output_rate) -
config.audio_backend_buffer_desired_length *
config.output_rate; // all arguments are int32_t, so expression promotion okay
// check that there are enough buffers to accommodate the desired latency and the latency offset
int maximum_latency =
- config.latency + (int)(config.audio_backend_latency_offset * config.output_rate);
+ conn->latency + (int)(config.audio_backend_latency_offset * config.output_rate);
if ((maximum_latency + (352 - 1)) / 352 + 10 > BUFFER_FRAMES)
die("Not enough buffers available for a total latency of %d frames. A maximum of %d 352-frame "
"packets may be accommodated.",
// if negative, the packet will be early -- the delay is less than expected.
sync_error =
- delay - (config.latency * conn->output_sample_ratio +
+ delay - (conn->latency * conn->output_sample_ratio +
(int64_t)(config.audio_backend_latency_offset *
config.output_rate)); // int64_t from int64_t - int32_t, so okay
typedef struct {
int connection_number; // for debug ID purposes, nothing else...
+ int64_t latency; // the actual latency used for this play session
int64_t minimum_latency; // set if an a=min-latency: line appears in the ANNOUNCE message; zero otherwise
int64_t maximum_latency; // set if an a=max-latency: line appears in the ANNOUNCE message; zero otherwise
/*
* Apple RTP protocol handler. This file is part of Shairport.
* Copyright (c) James Laird 2013
- * Copyright (c) Mike Brady 2014 -- 2017
+ * Copyright (c) Mike Brady 2014 -- 2018
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
rtp_timestamp_less_latency = monotonic_timestamp(ntohl(*((uint32_t *)&packet[4])), conn);
sync_rtp_timestamp = monotonic_timestamp(ntohl(*((uint32_t *)&packet[16])), conn);
-
+
if (config.userSuppliedLatency) {
- if (config.userSuppliedLatency != config.latency) {
+ if (config.userSuppliedLatency != conn->latency) {
debug(1,"Using the user-supplied latency: %lld.",config.userSuppliedLatency);
}
- config.latency = config.userSuppliedLatency;
+ conn->latency = config.userSuppliedLatency;
} else {
int64_t la =
sync_rtp_timestamp - rtp_timestamp_less_latency + config.fixedLatencyOffset;
if ((conn->minimum_latency) && (conn->minimum_latency>la))
la = conn->minimum_latency;
- if (la != config.latency) {
- config.latency = la;
+ if (la != conn->latency) {
+ conn->latency = la;
debug(1,"New latency: %lld, sync latency: %lld, minimum latency: %lld, maximum latency: %lld, fixed offset: %lld.",
la,sync_rtp_timestamp - rtp_timestamp_less_latency,conn->minimum_latency,conn->maximum_latency,config.fixedLatencyOffset);
}
// it's as if the first sync after a flush or resume is the timing of the next packet
// after the one whose RTP is given. Weird.
}
+
pthread_mutex_lock(&conn->reference_time_mutex);
conn->remote_reference_timestamp_time = remote_time_of_sync;
conn->reference_timestamp_time =
strcat(configuration_file_path, ".conf");
config.configfile = configuration_file_path;
- config.statistics_requested = 0; // don't print stats in the log
- config.latency = -1; // -1 means not set. 88200 works well. This is also reset in rtsp.c when play
- // is about to start
- config.userSuppliedLatency = 0; // zero means none supplied
+ //config.statistics_requested = 0; // don't print stats in the log
+ //config.userSuppliedLatency = 0; // zero means none supplied
config.resyncthreshold = 0.05; // 50 ms
config.timeout = 120; // this number of seconds to wait for [more] audio before switching to idle.
config.tolerance =