Skip to content

Commit

Permalink
refactor: properly type device kind
Browse files Browse the repository at this point in the history
  • Loading branch information
b-ma committed Sep 17, 2023
1 parent 4d97b50 commit 4abf229
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/io/cpal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/io/cubeb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions src/media_devices/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn enumerate_devices_sync() -> Vec<MediaDeviceInfo> {
// 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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 4abf229

Please sign in to comment.