diff options
author | Karl Tomlinson <[email protected]> | 2018-01-13 01:31:49 +1200 |
---|---|---|
committer | Paul Adenot <[email protected]> | 2018-01-12 14:31:49 +0100 |
commit | fc83d6fe975a46af5852e819bcddf34e6e033b37 (patch) | |
tree | 9c202dfb386f9bc2d3a313d705f0b687e54cd08f /test | |
parent | fe643a4fab14d8d73a1d428ee960e28d447f861b (diff) | |
download | cubeb-fc83d6fe975a46af5852e819bcddf34e6e033b37.tar.gz cubeb-fc83d6fe975a46af5852e819bcddf34e6e033b37.zip |
cubeb_resampler_speex: don't call data callback while draining (#398)
* extend resampler_drain test to assert that data callback is not called while draining
* cubeb_resampler_speex: don't call data callback while draining
This support for this was dropped in
https://github.com/kinetiknz/cubeb/commit/06c689c2ad37347bfb20061d2bcb0e5ea037e561#diff-2f55f506bd2dd918b7b8c6ceec8aee0dL238
but documented later in
https://github.com/kinetiknz/cubeb/commit/4b4e6e3db126ee62af7514fff65a7f6bd7346aeb#diff-a2acb4d7d9909e5853f52f32b203283dR301
even though it was no longer provided.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_resampler.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/test/test_resampler.cpp b/test/test_resampler.cpp index 3eebce9..1f5fb8f 100644 --- a/test/test_resampler.cpp +++ b/test/test_resampler.cpp @@ -497,13 +497,15 @@ TEST(cubeb, resampler_output_only_noop) cubeb_resampler_destroy(resampler); } -long test_drain_data_cb(cubeb_stream * /*stm*/, void * /*user_ptr*/, +long test_drain_data_cb(cubeb_stream * /*stm*/, void * user_ptr, const void * input_buffer, void * output_buffer, long frame_count) { EXPECT_TRUE(output_buffer); EXPECT_TRUE(!input_buffer); - return frame_count - 10; + auto cb_count = static_cast<int *>(user_ptr); + (*cb_count)++; + return frame_count - 1; } TEST(cubeb, resampler_drain) @@ -515,10 +517,11 @@ TEST(cubeb, resampler_drain) output_params.channels = 1; output_params.format = CUBEB_SAMPLE_FLOAT32NE; target_rate = 48000; + int cb_count = 0; cubeb_resampler * resampler = cubeb_resampler_create((cubeb_stream*)nullptr, nullptr, &output_params, target_rate, - test_drain_data_cb, nullptr, + test_drain_data_cb, &cb_count, CUBEB_RESAMPLER_QUALITY_VOIP); const long out_frames = 128; @@ -530,9 +533,9 @@ TEST(cubeb, resampler_drain) out_buffer, out_frames); } while (got == out_frames); - /* If the above is not an infinite loop, the drain was a success, just mark - * this test as such. */ - ASSERT_TRUE(true); + /* The callback should be called once but not again after returning < + * frame_count. */ + ASSERT_EQ(cb_count, 1); cubeb_resampler_destroy(resampler); } |