Only allow sync packets after flush or resume to set latency and set an initial default latency.

This commit is contained in:
Mike Brady
2018-01-10 13:02:52 +00:00
parent 4499f63bd7
commit 3c08cedb78
2 changed files with 8 additions and 3 deletions
+5
View File
@@ -1374,6 +1374,11 @@ static void *player_thread_func(void *arg) {
conn->first_packet_timestamp = 0;
conn->flush_requested = 0;
// conn->fix_volume = 0x10000;
if (conn->latency==0) {
debug(1,"No latency has (yet) been specified. Setting 99225 (2.25 seconds) frames as a default.");
conn->latency = 99225;
}
int rc = pthread_mutex_init(&conn->ab_mutex, NULL);
if (rc)
+3 -3
View File
@@ -182,7 +182,7 @@ void *rtp_control_receiver(void *arg) {
uint8_t packet[2048], *pktp;
struct timespec tn;
uint64_t remote_time_of_sync, local_time_now, remote_time_now;
int64_t sync_rtp_timestamp, rtp_timestamp_less_latency;
int64_t sync_rtp_timestamp;
ssize_t nread;
while (conn->please_stop == 0) {
fd_set readfds;
@@ -223,7 +223,6 @@ void *rtp_control_receiver(void *arg) {
// debug(1,"Remote Sync Time: %0llx.",remote_time_of_sync);
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) {
@@ -231,7 +230,8 @@ void *rtp_control_receiver(void *arg) {
debug(1,"Using the user-supplied latency: %lld.",config.userSuppliedLatency);
}
conn->latency = config.userSuppliedLatency;
} else {
} else if (packet[0] & 0x10) { // only set latency if it's a packet just after a flush or resume
int64_t rtp_timestamp_less_latency = monotonic_timestamp(ntohl(*((uint32_t *)&packet[4])), conn);
int64_t la =
sync_rtp_timestamp - rtp_timestamp_less_latency + config.fixedLatencyOffset;
if ((conn->maximum_latency) && (conn->maximum_latency<la))