diff --git a/src/tests/roc_pipeline/test_helpers/frame_reader.h b/src/tests/roc_pipeline/test_helpers/frame_reader.h index f8d27504b..bf8ca0766 100644 --- a/src/tests/roc_pipeline/test_helpers/frame_reader.h +++ b/src/tests/roc_pipeline/test_helpers/frame_reader.h @@ -132,8 +132,8 @@ class FrameReader : public core::NonCopyable<> { const core::nanoseconds_t capture_ts = base_ts + sample_spec.samples_per_chan_2_ns(abs_offset_); - expect_capture_timestamp(capture_ts, frame.capture_timestamp(), - TimestampEpsilon); + expect_capture_timestamp(capture_ts, frame.capture_timestamp(), sample_spec, + TimestampEpsilonSmpls); } } diff --git a/src/tests/roc_pipeline/test_helpers/packet_reader.h b/src/tests/roc_pipeline/test_helpers/packet_reader.h index e8fbd3ee4..10b50a61f 100644 --- a/src/tests/roc_pipeline/test_helpers/packet_reader.h +++ b/src/tests/roc_pipeline/test_helpers/packet_reader.h @@ -186,7 +186,7 @@ class PacketReader : public core::NonCopyable<> { base_ts + sample_spec.samples_per_chan_2_ns(abs_offset_); expect_capture_timestamp(capture_ts, pkt.rtp()->capture_timestamp, - TimestampEpsilon); + sample_spec, TimestampEpsilonSmpls); } } diff --git a/src/tests/roc_pipeline/test_helpers/utils.h b/src/tests/roc_pipeline/test_helpers/utils.h index 800042bc6..dbbddb947 100644 --- a/src/tests/roc_pipeline/test_helpers/utils.h +++ b/src/tests/roc_pipeline/test_helpers/utils.h @@ -25,8 +25,7 @@ namespace { const double SampleEpsilon = 0.00001; -const core::nanoseconds_t TimestampEpsilon = - (core::nanoseconds_t)(1. / DefaultSampleRate * core::Second); +const size_t TimestampEpsilonSmpls = 1; inline audio::sample_t nth_sample(uint8_t n) { return audio::sample_t(n) / 1024; @@ -40,7 +39,10 @@ inline address::SocketAddr new_address(int port) { inline void expect_capture_timestamp(core::nanoseconds_t expected, core::nanoseconds_t actual, - core::nanoseconds_t epsilon) { + const audio::SampleSpec& sample_spec, + const size_t epsilon_smpls) { + const core::nanoseconds_t epsilon = sample_spec.samples_per_chan_2_ns(epsilon_smpls); + if (!core::ns_equal_delta(expected, actual, epsilon)) { char sbuff[256]; snprintf(sbuff, sizeof(sbuff), diff --git a/src/tests/roc_pipeline/test_receiver_source.cpp b/src/tests/roc_pipeline/test_receiver_source.cpp index 7221de61d..b11ca72a5 100644 --- a/src/tests/roc_pipeline/test_receiver_source.cpp +++ b/src/tests/roc_pipeline/test_receiver_source.cpp @@ -1744,9 +1744,9 @@ TEST(receiver_source, recv_timestamp_mapping_remixing) { const core::nanoseconds_t expected_capture_ts = first_ts + output_sample_spec.samples_overall_2_ns(frame_num * frame_size); - test::expect_capture_timestamp(expected_capture_ts, - frame.capture_timestamp(), - test::TimestampEpsilon); + test::expect_capture_timestamp( + expected_capture_ts, frame.capture_timestamp(), output_sample_spec, + test::TimestampEpsilonSmpls); frame_num++; } diff --git a/src/tests/roc_pipeline/test_sender_sink.cpp b/src/tests/roc_pipeline/test_sender_sink.cpp index 86c9911ce..a41fb337f 100644 --- a/src/tests/roc_pipeline/test_sender_sink.cpp +++ b/src/tests/roc_pipeline/test_sender_sink.cpp @@ -384,8 +384,6 @@ TEST(sender_sink, timestamp_mapping_remixing_packet_reader) { InputChans = Chans_Stereo, PacketChans = Chans_Mono }; - const core::nanoseconds_t eps_resampled = - core::nanoseconds_t(1.f / PacketRate * core::Second); init(InputRate, InputChans, PacketRate, PacketChans); @@ -428,7 +426,8 @@ TEST(sender_sink, timestamp_mapping_remixing_packet_reader) { CHECK(cts >= unix_base); } else { test::expect_capture_timestamp(cts, pp->rtp()->capture_timestamp, - eps_resampled); + packet_sample_spec, + test::TimestampEpsilonSmpls); } cts += packet_sample_spec.samples_per_chan_2_ns(pp->rtp()->duration); }