diff --git a/src/debug.h b/src/debug.h index 1176db1fd..211cd4dcc 100644 --- a/src/debug.h +++ b/src/debug.h @@ -169,4 +169,13 @@ if (level <= log_level) Logger(level).Get() #endif +#ifdef DEBUG +#define DEBUG_TIMER_EVENT(name) struct timeval name = { 0, 0 }; gettimeofday(&name, NULL) +#define DEBUG_TIMER_START(name) DEBUG_TIMER_EVENT(name##_start); +#define DEBUG_TIMER_STOP(name) DEBUG_TIMER_EVENT(name##_stop); log_msg(LOG_LEVEL_DEBUG2, "%s duration: %lf s\n", #name, tv_diff(name##_stop, name##_start)) // NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) +#else +#define DEBUG_TIMER_START(name) +#define DEBUG_TIMER_STOP(name) +#endif + #endif diff --git a/src/rtp/audio_decoders.cpp b/src/rtp/audio_decoders.cpp index d43cd5e69..70948555c 100644 --- a/src/rtp/audio_decoders.cpp +++ b/src/rtp/audio_decoders.cpp @@ -449,6 +449,7 @@ int decode_audio_frame(struct coded_data *cdata, void *pbuf_data, struct pbuf_st return FALSE; } + DEBUG_TIMER_START(audio_decode); audio_frame2 received_frame; received_frame.init(decoder->saved_desc.ch_count, get_audio_codec_to_tag(decoder->saved_audio_tag), @@ -702,6 +703,7 @@ int decode_audio_frame(struct coded_data *cdata, void *pbuf_data, struct pbuf_st packet_counter_clear(decoder->packet_counter); } + DEBUG_TIMER_START(audio_decode_compute_autoscale); if(!decoder->fixed_scale) { for(int i = 0; i <= decoder->channel_map.max_output; ++i) { double avg = get_avg_volume(s->buffer.data, bps, @@ -710,6 +712,8 @@ int decode_audio_frame(struct coded_data *cdata, void *pbuf_data, struct pbuf_st s->buffer.data_len / output_channels / bps, sample_rate); } } + DEBUG_TIMER_STOP(audio_decode_compute_autoscale); + DEBUG_TIMER_STOP(audio_decode); return TRUE; }