diff options
author | Dan Glastonbury <[email protected]> | 2017-05-23 14:20:11 +1000 |
---|---|---|
committer | Dan Glastonbury <[email protected]> | 2017-05-25 14:24:02 +1000 |
commit | 4efb2e695630d289c01bcb4bbd5c4505d37f4e0e (patch) | |
tree | c6d214564f35c6cdcf2865cfeeaacf1890dc40f0 /test/test_devices.cpp | |
parent | c9641ca143e3263779137f08c58ef43ab0a7c75d (diff) | |
download | cubeb-4efb2e695630d289c01bcb4bbd5c4505d37f4e0e.tar.gz cubeb-4efb2e695630d289c01bcb4bbd5c4505d37f4e0e.zip |
Rework device collection (#309)
Rust compatiblity change to cubeb_device_collection.
Replace the C dynamic allocation with magic header into a structure
that hold pointer + count of entries. This is the same memory layout
that rust uses for fat pointers for &[T], Box<[T]>, etc.
Diffstat (limited to 'test/test_devices.cpp')
-rw-r--r-- | test/test_devices.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/test/test_devices.cpp b/test/test_devices.cpp index d0a524d..8bc9190 100644 --- a/test/test_devices.cpp +++ b/test/test_devices.cpp @@ -102,14 +102,14 @@ print_device_collection(cubeb_device_collection * collection, FILE * f) uint32_t i; for (i = 0; i < collection->count; i++) - print_device_info(collection->device[i], f); + print_device_info(&collection->device[i], f); } TEST(cubeb, enumerate_devices) { int r; cubeb * ctx = NULL; - cubeb_device_collection * collection = NULL; + cubeb_device_collection collection; r = common_init(&ctx, "Cubeb audio test"); ASSERT_EQ(r, CUBEB_OK) << "Error initializing cubeb library"; @@ -128,9 +128,9 @@ TEST(cubeb, enumerate_devices) } ASSERT_EQ(r, CUBEB_OK) << "Error enumerating devices " << r; - fprintf(stdout, "Found %u input devices\n", collection->count); - print_device_collection(collection, stdout); - cubeb_device_collection_destroy(ctx, collection); + fprintf(stdout, "Found %zu input devices\n", collection.count); + print_device_collection(&collection, stdout); + cubeb_device_collection_destroy(ctx, &collection); fprintf(stdout, "Enumerating output devices for backend %s\n", cubeb_get_backend_id(ctx)); @@ -138,7 +138,7 @@ TEST(cubeb, enumerate_devices) r = cubeb_enumerate_devices(ctx, CUBEB_DEVICE_TYPE_OUTPUT, &collection); ASSERT_EQ(r, CUBEB_OK) << "Error enumerating devices " << r; - fprintf(stdout, "Found %u output devices\n", collection->count); - print_device_collection(collection, stdout); - cubeb_device_collection_destroy(ctx, collection); + fprintf(stdout, "Found %zu output devices\n", collection.count); + print_device_collection(&collection, stdout); + cubeb_device_collection_destroy(ctx, &collection); } |