aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorAlex Chronopoulos <[email protected]>2020-01-10 12:43:51 +0100
committerMatthew Gregan <[email protected]>2020-06-30 22:57:45 +1200
commit575bd443893638da4a88468576e4e10b706c7a6c (patch)
treeaacf87dcb64b1d8ec5873544fcd242cc929ab873 /test
parent7bc4f13d51957cbc0c3887969d2d91d6a1d0e529 (diff)
downloadcubeb-575bd443893638da4a88468576e4e10b706c7a6c.tar.gz
cubeb-575bd443893638da4a88468576e4e10b706c7a6c.zip
resampler: avoid overflow on uint arithmetics
Diffstat (limited to 'test')
-rw-r--r--test/test_resampler.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test_resampler.cpp b/test/test_resampler.cpp
index 7fb133d..8ac878f 100644
--- a/test/test_resampler.cpp
+++ b/test/test_resampler.cpp
@@ -1061,3 +1061,21 @@ TEST(cubeb, passthrough_resampler_fill_input_left) {
ASSERT_EQ(input_frame_count, output_frame_count - 8);
}
+TEST(cubeb, individual_methods) {
+ const uint32_t channels = 2;
+ const uint32_t sample_rate = 44100;
+ const uint32_t frames = 256;
+
+ delay_line<float> dl(10, channels, sample_rate);
+ uint32_t frames_needed1 = dl.input_needed_for_output(0);
+ ASSERT_EQ(frames_needed1, 0u);
+
+ cubeb_resampler_speex_one_way<float> one_way(channels, sample_rate, sample_rate, CUBEB_RESAMPLER_QUALITY_DEFAULT);
+ float buffer[channels * frames] = {0.0};
+ // Add all frames in the resampler's internal buffer.
+ one_way.input(buffer, frames);
+ // Ask for less than the existing frames, this would create a uint overlflow without the fix.
+ uint32_t frames_needed2 = one_way.input_needed_for_output(0);
+ ASSERT_EQ(frames_needed2, 0u);
+}
+