diff --git a/cubeb-core/Cargo.toml b/cubeb-core/Cargo.toml index f7a1146..7e0e88f 100644 --- a/cubeb-core/Cargo.toml +++ b/cubeb-core/Cargo.toml @@ -18,7 +18,7 @@ circle-ci = { repository = "mozilla/cubeb-rs" } gecko-in-tree = ["cubeb-sys/gecko-in-tree"] [dependencies] -bitflags = "1.2.0" +bitflags = "2.9.1" cubeb-sys = { path = "../cubeb-sys", version = "0.29" } [build-dependencies] diff --git a/cubeb-core/src/channel.rs b/cubeb-core/src/channel.rs index 4a6c16f..7c9ceab 100644 --- a/cubeb-core/src/channel.rs +++ b/cubeb-core/src/channel.rs @@ -7,6 +7,7 @@ use ffi; bitflags! { /// Some common layout definitions + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] pub struct ChannelLayout: ffi::cubeb_channel_layout { const FRONT_LEFT = ffi::CHANNEL_FRONT_LEFT; const FRONT_RIGHT = ffi::CHANNEL_FRONT_RIGHT; diff --git a/cubeb-core/src/device.rs b/cubeb-core/src/device.rs index 4854aa2..472f57a 100644 --- a/cubeb-core/src/device.rs +++ b/cubeb-core/src/device.rs @@ -20,6 +20,7 @@ pub enum DeviceState { bitflags! { /// Architecture specific sample type. + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] pub struct DeviceFormat: ffi::cubeb_device_fmt { const S16LE = ffi::CUBEB_DEVICE_FMT_S16LE; const S16BE = ffi::CUBEB_DEVICE_FMT_S16BE; @@ -32,11 +33,12 @@ bitflags! { /// Channel type for a `cubeb_stream`. Depending on the backend and platform /// used, this can control inter-stream interruption, ducking, and volume /// control. + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] pub struct DevicePref: ffi::cubeb_device_pref { const MULTIMEDIA = ffi::CUBEB_DEVICE_PREF_MULTIMEDIA; const VOICE = ffi::CUBEB_DEVICE_PREF_VOICE; const NOTIFICATION = ffi::CUBEB_DEVICE_PREF_NOTIFICATION; - const ALL = ffi::CUBEB_DEVICE_PREF_ALL; + const _ = 0x08; } } @@ -47,6 +49,7 @@ impl DevicePref { bitflags! { /// Whether a particular device is an input device (e.g. a microphone), or an /// output device (e.g. headphones). + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] pub struct DeviceType: ffi::cubeb_device_type { const INPUT = ffi::CUBEB_DEVICE_TYPE_INPUT as _; const OUTPUT = ffi::CUBEB_DEVICE_TYPE_OUTPUT as _; @@ -226,8 +229,8 @@ impl DeviceInfoRef { #[cfg(test)] mod tests { - use ffi::cubeb_device; - use Device; + use ffi::{cubeb_device, CUBEB_DEVICE_PREF_ALL}; + use {Device, DevicePref}; #[test] fn device_device_ref_same_ptr() { @@ -236,4 +239,12 @@ mod tests { assert_eq!(device.as_ptr(), ptr); assert_eq!(device.as_ptr(), device.as_ref().as_ptr()); } + + #[test] + fn device_pref_all_same_as_the_constant() { + assert_eq!( + DevicePref::all(), + DevicePref::from_bits_retain(CUBEB_DEVICE_PREF_ALL) + ); + } } diff --git a/cubeb-core/src/stream.rs b/cubeb-core/src/stream.rs index 403ffb3..4d7aaae 100644 --- a/cubeb-core/src/stream.rs +++ b/cubeb-core/src/stream.rs @@ -48,6 +48,7 @@ impl From for ffi::cubeb_state { bitflags! { /// Miscellaneous stream preferences. + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] pub struct StreamPrefs: ffi::cubeb_stream_prefs { const LOOPBACK = ffi::CUBEB_STREAM_PREF_LOOPBACK; const DISABLE_DEVICE_SWITCHING = ffi::CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING; @@ -61,6 +62,7 @@ impl StreamPrefs { bitflags! { /// Input stream processing parameters. + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] pub struct InputProcessingParams: ffi::cubeb_input_processing_params { const ECHO_CANCELLATION = ffi::CUBEB_INPUT_PROCESSING_PARAM_ECHO_CANCELLATION; const NOISE_SUPPRESSION = ffi::CUBEB_INPUT_PROCESSING_PARAM_NOISE_SUPPRESSION;