Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/657_implement_warmup' into 657_i…
Browse files Browse the repository at this point in the history
…mplement_warmup
  • Loading branch information
zann136 committed Jan 31, 2024
2 parents 09cc67c + adeb638 commit 0e0b56c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
27 changes: 15 additions & 12 deletions src/internal_modules/roc_audio/watchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void WatchdogConfig::deduce_defaults(core::nanoseconds_t target_latency) {
std::min(300 * core::Millisecond, choppy_playback_timeout / 4);
}

if(warmup_duration < 0){
if (warmup_duration < 0) {
warmup_duration = target_latency;
}
}
Expand Down Expand Up @@ -67,21 +67,22 @@ Watchdog::Watchdog(IFrameReader& reader,
|| config.choppy_playback_window < 0 || config.warmup_duration < 0) {
roc_log(LogError,
"watchdog: invalid config:"
" no_packets_timeout=%ld drops_timeout=%ld drop_detection_window=%ld warmup_ending_pos=%ld",
" no_packets_timeout=%ld drops_timeout=%ld drop_detection_window=%ld "
"warmup_ending_pos=%ld",
(long)config.no_playback_timeout, (long)config.choppy_playback_timeout,
(long)config.choppy_playback_window, (long)config.warmup_duration);
return;
}

if (max_drops_duration_ != 0) {
if (drop_detection_window_ == 0 || drop_detection_window_ > max_drops_duration_) {
roc_log(LogError,
"watchdog: invalid config:"
" drop_detection_window should be in range (0; max_drops_duration]:"
" max_drops_duration=%lu drop_detection_window=%lu warmup_ending_pos=%lu",
(unsigned long)max_drops_duration_,
(unsigned long)drop_detection_window_,
(unsigned long)warmup_ending_pos_);
roc_log(
LogError,
"watchdog: invalid config:"
" drop_detection_window should be in range (0; max_drops_duration]:"
" max_drops_duration=%lu drop_detection_window=%lu warmup_ending_pos=%lu",
(unsigned long)max_drops_duration_, (unsigned long)drop_detection_window_,
(unsigned long)warmup_ending_pos_);
return;
}
}
Expand All @@ -94,7 +95,8 @@ Watchdog::Watchdog(IFrameReader& reader,

roc_log(LogDebug,
"watchdog: initializing:"
" max_blank_duration=%lu max_drops_duration=%lu drop_detection_window=%lu warmup_ending_pos=%lu",
" max_blank_duration=%lu max_drops_duration=%lu drop_detection_window=%lu "
"warmup_ending_pos=%lu",
(unsigned long)max_blank_duration_, (unsigned long)max_drops_duration_,
(unsigned long)drop_detection_window_, (unsigned long)warmup_ending_pos_);

Expand Down Expand Up @@ -172,7 +174,8 @@ bool Watchdog::check_blank_timeout_() const {

roc_log(LogDebug,
"watchdog: blank timeout reached: every frame was blank during timeout:"
" curr_read_pos=%lu last_pos_before_blank=%lu max_blank_duration=%lu warmup_ending_pos=%lu",
" curr_read_pos=%lu last_pos_before_blank=%lu max_blank_duration=%lu "
"warmup_ending_pos=%lu",
(unsigned long)curr_read_pos_, (unsigned long)last_pos_before_blank_,
(unsigned long)max_blank_duration_, (unsigned long)warmup_ending_pos_);

Expand Down Expand Up @@ -207,7 +210,7 @@ void Watchdog::update_drops_timeout_(const Frame& frame,
}
}

void Watchdog::update_warmup_status_(){
void Watchdog::update_warmup_status_() {
warmup_status_ = warmup_status_ && (curr_read_pos_ < warmup_ending_pos_);
}

Expand Down
8 changes: 5 additions & 3 deletions src/tests/roc_audio/test_watchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,9 @@ TEST(watchdog, broken_playback_timeout_disabled) {

// Checks that watchdog works correctly with latency longer than no_playback_timeout
TEST(watchdog, latency_longer_then_no_playback_timeout) {
enum {Latency = NoPlaybackTimeout * 10};
WatchdogConfig config = make_config(NoPlaybackTimeout, BrokenPlaybackTimeout, Latency);
enum { Latency = NoPlaybackTimeout * 10 };
WatchdogConfig config =
make_config(NoPlaybackTimeout, BrokenPlaybackTimeout, Latency);
Watchdog watchdog(test_reader, SampleSpecs, config, arena);
CHECK(watchdog.is_valid());

Expand All @@ -451,7 +452,8 @@ TEST(watchdog, latency_longer_then_no_playback_timeout) {

CHECK(watchdog.is_alive());

for (packet::stream_timestamp_t n = 0; n < NoPlaybackTimeout / SamplesPerFrame - 1; n++) {
for (packet::stream_timestamp_t n = 0; n < NoPlaybackTimeout / SamplesPerFrame - 1;
n++) {
check_read(watchdog, true, SamplesPerFrame, 0);
CHECK(watchdog.is_alive());
}
Expand Down
7 changes: 4 additions & 3 deletions src/tests/roc_pipeline/test_receiver_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ TEST(receiver_source, initial_latency_timeout) {

packet_writer.write_packets(1, SamplesPerPacket, packet_sample_spec);

for (size_t np = 0; np < Timeout / SamplesPerPacket + Latency / SamplesPerPacket; np++) {
for (size_t np = 0; np < Timeout / SamplesPerPacket + Latency / SamplesPerPacket;
np++) {
for (size_t nf = 0; nf < FramesPerPacket; nf++) {
receiver.refresh(frame_reader.refresh_ts());
frame_reader.read_zero_samples(SamplesPerFrame, output_sample_spec);
Expand Down Expand Up @@ -2279,7 +2280,7 @@ TEST(receiver_source, watchdog_timeout_smaller_than_latency) {
CHECK(slot);

packet::IWriter* endpoint1_writer =
create_transport_endpoint(slot, address::Iface_AudioSource, proto1);
create_transport_endpoint(slot, address::Iface_AudioSource, proto1);
CHECK(endpoint1_writer);

test::FrameReader frame_reader(receiver, sample_buffer_factory);
Expand All @@ -2296,7 +2297,7 @@ TEST(receiver_source, watchdog_timeout_smaller_than_latency) {
frame_reader.read_zero_samples(SamplesPerFrame, output_sample_spec);
}

UNSIGNED_LONGS_EQUAL(1, receiver.num_sessions());
UNSIGNED_LONGS_EQUAL(1, receiver.num_sessions());
}

}
Expand Down

0 comments on commit 0e0b56c

Please sign in to comment.