aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorPaul Adenot <[email protected]>2020-09-15 17:33:25 +0200
committerPaul Adenot <[email protected]>2020-09-21 19:36:43 +0200
commit9820ea03bf5122350eeb88222f1f81202b30a61b (patch)
tree98c7cacc58b4ecd1fb9968d9939ce3ed569aeffd /test
parentb66d91554b8c3bf3159c04577bcf46a1a451e718 (diff)
downloadcubeb-9820ea03bf5122350eeb88222f1f81202b30a61b.tar.gz
cubeb-9820ea03bf5122350eeb88222f1f81202b30a61b.zip
Add a test case for WASAPI reconfigure event
Diffstat (limited to 'test')
-rw-r--r--test/test_sanity.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/test_sanity.cpp b/test/test_sanity.cpp
index 56099d2..e775227 100644
--- a/test/test_sanity.cpp
+++ b/test/test_sanity.cpp
@@ -639,6 +639,62 @@ TEST(cubeb, drain)
do_drain = 0;
}
+TEST(cubeb, device_reset)
+{
+ int r;
+ cubeb * ctx;
+ cubeb_stream * stream;
+ cubeb_stream_params params;
+ uint64_t position;
+
+ r = common_init(&ctx, "test_sanity");
+ ASSERT_EQ(r, CUBEB_OK);
+ ASSERT_NE(ctx, nullptr);
+
+ if (strcmp(cubeb_get_backend_id(ctx), "wasapi")) {
+ // cubeb_stream_reset_default_device is only useful and implemented in the
+ // WASAPI backend.
+ return;
+ }
+
+ params.format = STREAM_FORMAT;
+ params.rate = STREAM_RATE;
+ params.channels = STREAM_CHANNELS;
+ params.layout = STREAM_LAYOUT;
+ params.prefs = CUBEB_STREAM_PREF_NONE;
+
+ r = cubeb_stream_init(ctx, &stream, "test", NULL, NULL, NULL, &params, STREAM_LATENCY,
+ test_data_callback, test_state_callback, &dummy);
+ ASSERT_EQ(r, CUBEB_OK);
+ ASSERT_NE(stream, nullptr);
+
+ r = cubeb_stream_start(stream);
+ ASSERT_EQ(r, CUBEB_OK);
+
+ uint32_t iterations = 5;
+ uint64_t previous_position = 0;
+ while (iterations--) {
+ r = cubeb_stream_get_position(stream, &position);
+ ASSERT_EQ(r, CUBEB_OK);
+ ASSERT_GE(position, previous_position);
+ delay(100);
+ }
+
+ r = cubeb_stream_reset_default_device(stream);
+ ASSERT_EQ(r, CUBEB_OK);
+
+ iterations = 5;
+ while (iterations--) {
+ r = cubeb_stream_get_position(stream, &position);
+ ASSERT_EQ(r, CUBEB_OK);
+ ASSERT_GE(position, previous_position);
+ delay(100);
+ }
+
+ cubeb_stream_destroy(stream);
+ cubeb_destroy(ctx);
+}
+
TEST(cubeb, DISABLED_eos_during_prefill)
{
// This test needs to be implemented.