@@ -402,7 +402,7 @@ static void swr_alloc_cleanup_handler(void *arg) {
402402}
403403
404404static void av_packet_alloc_cleanup_handler (void * arg ) {
405- debug (3 , "av_packet_alloc_cleanup_handler" );
405+ debug (4 , "av_packet_alloc_cleanup_handler" );
406406 AVPacket * * pkt = arg ;
407407 av_packet_free (pkt );
408408}
@@ -1144,7 +1144,7 @@ int64_t avframe_to_audio(rtsp_conn_info *conn, AVFrame *decoded_frame, uint8_t *
11441144
11451145 int number_of_output_samples_expected = swr_get_out_samples (conn -> swr , decoded_frame -> nb_samples );
11461146
1147- debug (3 , "A maximum of %d output samples expected for %d input samples." ,
1147+ debug (4 , "A maximum of %d output samples expected for %d input samples." ,
11481148 number_of_output_samples_expected , decoded_frame -> nb_samples );
11491149 // allocate enough space for the required number of output channels
11501150 // and the number of samples decoded
@@ -1155,10 +1155,10 @@ int64_t avframe_to_audio(rtsp_conn_info *conn, AVFrame *decoded_frame, uint8_t *
11551155 int samples_generated =
11561156 swr_convert (conn -> swr , & pcm_audio , number_of_output_samples_expected ,
11571157 (const uint8_t * * )decoded_frame -> extended_data , decoded_frame -> nb_samples );
1158- debug (3 , "conversion time for %u incoming samples: %.3f milliseconds." , decoded_frame -> nb_samples ,
1158+ debug (4 , "conversion time for %u incoming samples: %.3f milliseconds." , decoded_frame -> nb_samples ,
11591159 (get_absolute_time_in_ns () - conversion_start_time ) * 0.000001 );
11601160 if (samples_generated > 0 ) {
1161- debug (3 , "swr generated %d frames of %" PRId64 " channels." , samples_generated ,
1161+ debug (4 , "swr generated %d frames of %" PRId64 " channels." , samples_generated ,
11621162 conn -> resampler_output_channels );
11631163 // samples_generated will be different from
11641164 // the number of samples input if the output rate is different from the input
@@ -2296,7 +2296,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn, int resync_requested) {
22962296 uint64_t should_be_time ;
22972297 frame_to_local_time (curframe -> timestamp , & should_be_time , conn );
22982298 int64_t time_difference = should_be_time - get_absolute_time_in_ns ();
2299- debug (3 , "Check packet from buffer %u, timestamp %u, %f seconds ahead." , conn -> ab_read ,
2299+ debug (4 , "Check packet from buffer %u, timestamp %u, %f seconds ahead." , conn -> ab_read ,
23002300 curframe -> timestamp , 0.000000001 * time_difference );
23012301 } else {
23022302 debug (3 , "Check packet from buffer %u, empty." , conn -> ab_read );
@@ -3210,8 +3210,8 @@ int stuff_buffer_soxr_32(int32_t *inptr, int length, sps_format_t l_output_forma
32103210 };
32113211 }
32123212
3213- if (packets_processed % 1250 == 0 ) {
3214- debug (3 ,
3213+ if (( packets_processed % 1250 == 0 ) && ( stat_n > 0 ) ) {
3214+ debug (4 ,
32153215 "soxr_oneshot execution time in nanoseconds: mean, standard deviation and max "
32163216 "for %" PRId32 " interpolations in the last "
32173217 "1250 packets. %10.6f, %10.6f, %10.6f." ,
@@ -4269,7 +4269,7 @@ void *player_thread_func(void *arg) {
42694269 output_buffer_delay_time =
42704270 output_buffer_delay_time /
42714271 RATE_FROM_ENCODED_FORMAT (config .current_output_configuration );
4272- debug (3 ,
4272+ debug (4 ,
42734273 "current_delay: %" PRId64 ", output_buffer_delay_time: %.3f, output rate: %u." ,
42744274 current_delay , output_buffer_delay_time * 0.000000001 ,
42754275 RATE_FROM_ENCODED_FORMAT (config .current_output_configuration ));
@@ -4352,8 +4352,9 @@ void *player_thread_func(void *arg) {
43524352 gap_to_fix = - inframe -> timestamp_gap ; // this is frames at the input rate
43534353 int64_t gap_to_fix_ns = (gap_to_fix * 1000000000 ) / conn -> input_rate ;
43544354 gap_to_fix = (gap_to_fix_ns *
4355- RATE_FROM_ENCODED_FORMAT (config .current_output_configuration )) /
4355+ RATE_FROM_ENCODED_FORMAT (config .current_output_configuration ) + 1000000000 / 2 ) /
43564356 1000000000 ; // this is frames at the output rate
4357+ debug (3 , "gap_to_fix: %u frames at input rate, %" PRId64 " frames at output rate." , - inframe -> timestamp_gap , gap_to_fix );
43574358 // debug(3, "due to timstamp gap of %d frames, skip %" PRId64 " output
43584359 // frames.", inframe->timestamp_gap, gap_to_fix);
43594360 }
@@ -4471,16 +4472,16 @@ void *player_thread_func(void *arg) {
44714472 amount_to_stuff = -1 * (inbuflength / 350 );
44724473 if (amount_to_stuff == 0 )
44734474 amount_to_stuff = -1 ;
4474- debug (3 , "drop a frame, inbuflength is %d, amount_to_stuff is %d." ,
4475+ debug (4 , "drop a frame, inbuflength is %d, amount_to_stuff is %d." ,
44754476 inbuflength , amount_to_stuff );
44764477 } else if (centered_sync_error_ns < (- tolerance_ns )) {
44774478 amount_to_stuff = +1 * (inbuflength / 350 );
44784479 if (amount_to_stuff == 0 )
44794480 amount_to_stuff = 1 ;
4480- debug (3 , "add a frame, inbuflength is %d, amount_to_stuff is %d." ,
4481+ debug (4 , "add a frame, inbuflength is %d, amount_to_stuff is %d." ,
44814482 inbuflength , amount_to_stuff );
44824483 } else {
4483- debug (3 ,
4484+ debug (4 ,
44844485 "error is within tolerance: centered_sync_error_ns: %" PRId64
44854486 ", tolerance_ns: %" PRId64 " ns." ,
44864487 centered_sync_error_ns , tolerance_ns );
@@ -4490,7 +4491,7 @@ void *player_thread_func(void *arg) {
44904491 }
44914492
44924493 if (amount_to_stuff )
4493- debug (3 ,
4494+ debug (4 ,
44944495 // "stuff: %+d, sync_error: %+5.3f milliseconds.",
44954496 // amount_to_stuff, sync_error * 1000);
44964497 "stuff: %+d, sync_errors actual: %+5.3f milliseconds, bufferlength: %d, "
@@ -4775,19 +4776,23 @@ void *player_thread_func(void *arg) {
47754776 frames_to_skip -= play_samples ;
47764777 } else {
47774778
4778- char * offset = conn -> outbuf ;
4779- offset +=
4780- frames_to_skip *
4779+
4780+
4781+ size_t bytes_to_skip = frames_to_skip *
47814782 CHANNELS_FROM_ENCODED_FORMAT (config .current_output_configuration ) *
47824783 sps_format_sample_size (
47834784 FORMAT_FROM_ENCODED_FORMAT (config .current_output_configuration ));
4784- config .output -> play (offset , play_samples - frames_to_skip ,
4785+
4786+ char * play_starting_point = conn -> outbuf + bytes_to_skip ;
4787+
4788+ config .output -> play (play_starting_point , play_samples - frames_to_skip ,
47854789 play_samples_are_timed , inframe -> timestamp ,
47864790 should_be_time );
47874791
4788- debug (3 , "skipping the first %u frames in a packet of %u frames." ,
4792+ debug (3 , "skipping the first %u frames (listed below) in a packet of %u frames." ,
47894793 frames_to_skip , play_samples );
4790- debug_print_buffer (3 , conn -> outbuf , offset - conn -> outbuf );
4794+
4795+ debug_print_buffer (3 , conn -> outbuf , bytes_to_skip );
47914796
47924797 frames_played += play_samples - frames_to_skip ;
47934798 frames_to_skip = 0 ;
@@ -4967,7 +4972,7 @@ static void player_send_volume_metadata(uint8_t vol_mode_both, double airplay_vo
49674972}
49684973
49694974void player_volume_without_notification (double airplay_volume , rtsp_conn_info * conn ) {
4970- debug_mutex_lock (& conn -> volume_control_mutex , 5000 , 1 );
4975+ debug_mutex_lock (& conn -> volume_control_mutex , 5000 , 4 );
49714976 // first, see if we are hw only, sw only, both with hw attenuation on the top or both with sw
49724977 // attenuation on top
49734978
@@ -5149,7 +5154,7 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c
51495154 double temp_fix_volume = 65536.0 * pow (10 , software_attenuation / 2000 );
51505155
51515156 if (config .ignore_volume_control == 0 )
5152- debug (3 , "Software attenuation set to %f, i.e %f out of 65,536, for airplay volume of %f" ,
5157+ debug (4 , "Software attenuation set to %f, i.e %f out of 65,536, for airplay volume of %f" ,
51535158 software_attenuation , temp_fix_volume , airplay_volume );
51545159 else
51555160 debug (3 , "Software attenuation set to %f, i.e %f out of 65,536. Volume control is ignored." ,
@@ -5158,7 +5163,7 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c
51585163 conn -> fix_volume = temp_fix_volume ;
51595164 }
51605165 if (conn != NULL )
5161- debug (3 , "Connection %d: AirPlay Volume set to %.3f, Output Level set to: %.2f dB." ,
5166+ debug (4 , "Connection %d: AirPlay Volume set to %.3f, Output Level set to: %.2f dB." ,
51625167 conn -> connection_number , airplay_volume , scaled_attenuation / 100.0 );
51635168 else
51645169 debug (3 , "AirPlay Volume set to %.3f, Output Level set to: %.2f dB. NULL conn." ,
@@ -5176,7 +5181,7 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c
51765181 config .output -> mute (0 );
51775182 conn -> software_mute_enabled = 0 ;
51785183
5179- debug (3 ,
5184+ debug (4 ,
51805185 "player_volume_without_notification: volume mode is %d, airplay volume is %.2f, "
51815186 "software_attenuation dB: %.2f, hardware_attenuation dB: %.2f, muting "
51825187 "is disabled." ,
@@ -5185,7 +5190,7 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c
51855190 // here, store the volume for possible use in the future
51865191 config .airplay_volume = airplay_volume ;
51875192 conn -> own_airplay_volume = airplay_volume ;
5188- debug_mutex_unlock (& conn -> volume_control_mutex , 3 );
5193+ debug_mutex_unlock (& conn -> volume_control_mutex , 4 );
51895194}
51905195
51915196void player_volume (double airplay_volume , rtsp_conn_info * conn ) {
0 commit comments