Skip to content

Commit

Permalink
Better logging and step default
Browse files Browse the repository at this point in the history
  • Loading branch information
baranovmv committed Mar 25, 2024
1 parent 28a58c0 commit fddcaa2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
32 changes: 23 additions & 9 deletions src/internal_modules/roc_audio/latency_tuner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ LatencyTuner::LatencyTuner(const LatencyConfig& config, const SampleSpec& sample
, last_target_latency_update_(0)
, lat_update_upper_thrsh_(config.upper_threshold_coef)
, lat_update_dec_step_(upper_coef_to_step_lat_update_(config.upper_threshold_coef))
, lat_update_inc_step_(lower_thrs_to_step_lat_update_(config.upper_threshold_coef)) {
, lat_update_inc_step_(lower_thrs_to_step_lat_update_(config.upper_threshold_coef))
, last_lat_limit_log_(0) {
roc_log(LogDebug,
"latency tuner: initializing:"
" target_latency=%ld(%.3fms) min_latency=%ld(%.3fms) max_latency=%ld(%.3fms)"
Expand Down Expand Up @@ -543,9 +544,15 @@ void LatencyTuner::update_target_latency_(const core::nanoseconds_t max_jitter_n
const packet::stream_timestamp_diff_t new_tl_ts =
sample_spec_.ns_2_stream_timestamp_delta(new_tl_ns);
if (new_tl_ts < min_latency_) {
roc_log(LogDebug, "Latency tuner:"
" not decreasing target latency lower than limit %ld(%.3fms)",
(long)min_latency_, sample_spec_.stream_timestamp_delta_2_ms(min_latency_));
if (now > last_lat_limit_log_ && (now - last_lat_limit_log_) >
5 * core::Second) {
last_lat_limit_log_ = now;
roc_log(LogDebug,
"Latency tuner:"
" not decreasing target latency lower than limit %ld(%.3fms)",
(long)min_latency_,
sample_spec_.stream_timestamp_delta_2_ms(min_latency_));
}
return;
}

Expand Down Expand Up @@ -579,11 +586,18 @@ void LatencyTuner::update_target_latency_(const core::nanoseconds_t max_jitter_n
sample_spec_.ns_2_stream_timestamp_delta(new_tl_ns);

if (new_tl_ts > max_latency_) {
roc_log(LogDebug, "Latency tuner:"
" capping target latency %ld(%.3fms)"
" as max limit is lower %ld(%.3fms)",
(long)new_tl_ts, (double)new_tl_ns / core::Millisecond,
(long)max_latency_, sample_spec_.stream_timestamp_delta_2_ms(max_latency_));
if (now > last_lat_limit_log_ && (now - last_lat_limit_log_) >
5 * core::Second) {
last_lat_limit_log_ = now;

roc_log(LogDebug,
"Latency tuner:"
" capping target latency %ld(%.3fms)"
" as max limit is lower %ld(%.3fms)",
(long)new_tl_ts, (double)new_tl_ns / core::Millisecond,
(long)max_latency_,
sample_spec_.stream_timestamp_delta_2_ms(max_latency_));
}
new_tl_ts = max_latency_;
}

Expand Down
4 changes: 3 additions & 1 deletion src/internal_modules/roc_audio/latency_tuner.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ struct LatencyConfig {
, stale_tolerance(0)
, scaling_interval(0)
, scaling_tolerance(0)
, upper_threshold_coef(0) {
, upper_threshold_coef(1.7f) {
}

//! Automatically fill missing settings.
Expand Down Expand Up @@ -274,6 +274,8 @@ class LatencyTuner : public core::NonCopyable<> {
float lower_thrs_to_step_lat_update_(float upper_threshold_coef);
const float lat_update_dec_step_;
const float lat_update_inc_step_;

core::nanoseconds_t last_lat_limit_log_;
};

//! Get string name of latency backend.
Expand Down

0 comments on commit fddcaa2

Please sign in to comment.