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 /include | |
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 'include')
-rw-r--r-- | include/cubeb/cubeb.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/include/cubeb/cubeb.h b/include/cubeb/cubeb.h index 1caba7b..5e09e2d 100644 --- a/include/cubeb/cubeb.h +++ b/include/cubeb/cubeb.h @@ -8,6 +8,7 @@ #define CUBEB_c2f983e9_c96f_e71c_72c3_bbf62992a382 #include <stdint.h> +#include <stdlib.h> #include "cubeb_export.h" #if defined(__cplusplus) @@ -352,16 +353,16 @@ typedef struct { unsigned int max_rate; /**< Maximum sample rate supported. */ unsigned int min_rate; /**< Minimum sample rate supported. */ - unsigned int latency_lo; /**< Lowest possible latency in frames. */ - unsigned int latency_hi; /**< Higest possible latency in frames. */ + unsigned int latency_lo; /**< Lowest possible latency in frames. */ + unsigned int latency_hi; /**< Higest possible latency in frames. */ } cubeb_device_info; /** Device collection. * Returned by `cubeb_enumerate_devices` and destroyed by * `cubeb_device_collection_destroy`. */ typedef struct { - uint32_t count; /**< Device count in collection. */ - cubeb_device_info * device[1]; /**< Array of pointers to device info. */ + cubeb_device_info * device; /**< Array of pointers to device info. */ + size_t count; /**< Device count in collection. */ } cubeb_device_collection; /** User supplied data callback. @@ -612,7 +613,7 @@ CUBEB_EXPORT int cubeb_stream_register_device_changed_callback(cubeb_stream * st @retval CUBEB_ERROR_NOT_SUPPORTED */ CUBEB_EXPORT int cubeb_enumerate_devices(cubeb * context, cubeb_device_type devtype, - cubeb_device_collection ** collection); + cubeb_device_collection * collection); /** Destroy a cubeb_device_collection, and its `cubeb_device_info`. @param context |