From 37e7b5b63bcefecf05dcc95d9a63af41debef3ec Mon Sep 17 00:00:00 2001 From: Viktor Lazarev Date: Wed, 28 Aug 2019 15:14:18 +0200 Subject: [PATCH] Move DeviceTrait implementation to wasapi::device --- src/host/wasapi/device.rs | 27 +++++++++++++++++++++++++++ src/host/wasapi/mod.rs | 27 +-------------------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/host/wasapi/device.rs b/src/host/wasapi/device.rs index 3093b10..a067e47 100644 --- a/src/host/wasapi/device.rs +++ b/src/host/wasapi/device.rs @@ -68,6 +68,8 @@ use super::winapi::um::mmdeviceapi::{ IMMEndpoint, }; +use crate::traits::DeviceTrait; + pub type SupportedInputFormats = std::vec::IntoIter; pub type SupportedOutputFormats = std::vec::IntoIter; @@ -87,6 +89,31 @@ pub struct Device { future_audio_client: Arc>>, // TODO: add NonZero around the ptr } +impl DeviceTrait for Device { + type SupportedInputFormats = SupportedInputFormats; + type SupportedOutputFormats = SupportedOutputFormats; + + fn name(&self) -> Result { + Device::name(self) + } + + fn supported_input_formats(&self) -> Result { + Device::supported_input_formats(self) + } + + fn supported_output_formats(&self) -> Result { + Device::supported_output_formats(self) + } + + fn default_input_format(&self) -> Result { + Device::default_input_format(self) + } + + fn default_output_format(&self) -> Result { + Device::default_output_format(self) + } +} + struct Endpoint { endpoint: *mut IMMEndpoint, } diff --git a/src/host/wasapi/mod.rs b/src/host/wasapi/mod.rs index 239adbf..d833ac4 100644 --- a/src/host/wasapi/mod.rs +++ b/src/host/wasapi/mod.rs @@ -12,7 +12,7 @@ use StreamDataResult; use SupportedFormatsError; use self::winapi::um::winnt::HRESULT; use std::io::Error as IoError; -use traits::{DeviceTrait, EventLoopTrait, HostTrait, StreamIdTrait}; +use traits::{EventLoopTrait, HostTrait, StreamIdTrait}; pub use self::device::{Device, Devices, SupportedInputFormats, SupportedOutputFormats, default_input_device, default_output_device}; pub use self::stream::{EventLoop, StreamId}; @@ -61,31 +61,6 @@ impl HostTrait for Host { } } -impl DeviceTrait for Device { - type SupportedInputFormats = SupportedInputFormats; - type SupportedOutputFormats = SupportedOutputFormats; - - fn name(&self) -> Result { - Device::name(self) - } - - fn supported_input_formats(&self) -> Result { - Device::supported_input_formats(self) - } - - fn supported_output_formats(&self) -> Result { - Device::supported_output_formats(self) - } - - fn default_input_format(&self) -> Result { - Device::default_input_format(self) - } - - fn default_output_format(&self) -> Result { - Device::default_output_format(self) - } -} - impl EventLoopTrait for EventLoop { type Device = Device; type StreamId = StreamId;