diff --git a/src/io/cpal.rs b/src/io/cpal.rs index 9f99e600..35e90d1c 100644 --- a/src/io/cpal.rs +++ b/src/io/cpal.rs @@ -420,7 +420,7 @@ impl AudioBackendManager for CpalBackend { loop { let device_id = crate::media_devices::DeviceId::as_string( - kind as u8, + kind, "cpal".to_string(), device.name().unwrap(), num_channels, diff --git a/src/io/cubeb.rs b/src/io/cubeb.rs index 0f17c331..370559a0 100644 --- a/src/io/cubeb.rs +++ b/src/io/cubeb.rs @@ -411,7 +411,7 @@ impl AudioBackendManager for CubebBackend { loop { let device_id = crate::media_devices::DeviceId::as_string( - kind as u8, + kind, "cubeb".to_string(), device.friendly_name().unwrap().into(), device.max_channels().try_into().unwrap(), diff --git a/src/media_devices/mod.rs b/src/media_devices/mod.rs index 4641110d..0ce54326 100644 --- a/src/media_devices/mod.rs +++ b/src/media_devices/mod.rs @@ -31,7 +31,7 @@ pub fn enumerate_devices_sync() -> Vec { // cf. https://github.com/orottier/web-audio-api-rs/issues/356 #[derive(Hash)] pub(crate) struct DeviceId { - kind: u8, + kind: MediaDeviceInfoKind, host: String, device_name: String, num_channels: u16, @@ -40,7 +40,7 @@ pub(crate) struct DeviceId { impl DeviceId { pub(crate) fn as_string( - kind: u8, + kind: MediaDeviceInfoKind, host: String, device_name: String, num_channels: u16, @@ -61,7 +61,7 @@ impl DeviceId { } /// Describes input/output type of a media device -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub enum MediaDeviceInfoKind { VideoInput, AudioInput,