From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Wed, 23 Jun 2021 10:21:32 +0000 (+0100) Subject: Sometimes the output_rtptime_mask seems to be calculated in 32-bit arithmetic (?... X-Git-Tag: 4.1-dev~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=767bed6b9f3a809694c5c38738f35cd24e0442d3;p=thirdparty%2Fshairport-sync.git Sometimes the output_rtptime_mask seems to be calculated in 32-bit arithmetic (?), so do it all explicitly in 64-bit signed int as soon as the output_rtptime_sign_bit is calculated. --- diff --git a/player.c b/player.c index cd09bf8b..1d12e34c 100644 --- a/player.c +++ b/player.c @@ -1807,7 +1807,12 @@ void *player_thread_func(void *arg) { // debug(1, "Output sample ratio is %d.", conn->output_sample_ratio); // debug(1, "Output output_rtptime_sign_bit: %d.", output_rtptime_sign_bit); - conn->max_frame_size_change = + int64_t output_rtptime_mask = 1; + output_rtptime_mask = output_rtptime_mask << (output_rtptime_sign_bit + 1); + output_rtptime_mask = output_rtptime_mask - 1; + debug(3,"output_rtptime_mask is %" PRIx64 ".", output_rtptime_mask); + + conn->max_frame_size_change = 1 * conn->output_sample_ratio; // we add or subtract one frame at the nominal // rate, multiply it by the frame ratio. // but, on some occasions, more than one frame could be added @@ -2331,7 +2336,7 @@ void *player_thread_func(void *arg) { // current_delay is denominated in the frame rate of the outgoing stream int64_t will_be_frame = inframe->given_timestamp; will_be_frame = will_be_frame * conn->output_sample_ratio; - will_be_frame = (will_be_frame - current_delay) & ((1 << (output_rtptime_sign_bit + 1)) - 1); + will_be_frame = (will_be_frame - current_delay) & output_rtptime_mask; sync_error = SIGNEX(should_be_frame - will_be_frame, output_rtptime_sign_bit) ; // all int64_t