diff --git a/src/host/wasapi/device.rs b/src/host/wasapi/device.rs index fd9840a..e9e53e6 100644 --- a/src/host/wasapi/device.rs +++ b/src/host/wasapi/device.rs @@ -7,7 +7,7 @@ use std::ops::{Deref, DerefMut}; use std::os::windows::ffi::OsStringExt; use std::ptr; use std::slice; -use std::sync::{Arc, Mutex, MutexGuard, atomic::Ordering}; +use std::sync::{Arc, Mutex, MutexGuard}; use BackendSpecificError; use DefaultFormatError; @@ -72,7 +72,7 @@ use super::winapi::um::mmdeviceapi::{ }; use crate::{traits::DeviceTrait, BuildStreamError, StreamData, StreamError}; -use super::{stream::{Stream, AudioClientFlow, StreamInner, Command}, winapi::um::synchapi}; +use super::{stream::{Stream, AudioClientFlow, StreamInner}, winapi::um::synchapi}; pub type SupportedInputFormats = std::vec::IntoIter; pub type SupportedOutputFormats = std::vec::IntoIter; @@ -267,7 +267,7 @@ pub unsafe fn is_format_supported( // has been found, but not an exact match) so we also treat this as unsupported. match (result, check_result(result)) { (_, Err(ref e)) if e.raw_os_error() == Some(AUDCLNT_E_DEVICE_INVALIDATED) => { - return Err(SupportedFormatsError::DeviceNotAvailable); + Err(SupportedFormatsError::DeviceNotAvailable) }, (_, Err(_)) => { Ok(false) @@ -486,7 +486,7 @@ impl Device { }; // If the default format can't succeed we have no hope of finding other formats. - assert_eq!(try!(is_format_supported(client, default_waveformatex_ptr.0)), true); + assert_eq!(is_format_supported(client, default_waveformatex_ptr.0)?, true); // Copy the format to use as a test format (as to avoid mutating the original format). let mut test_format = { @@ -508,7 +508,7 @@ impl Device { test_format.nSamplesPerSec = rate; test_format.nAvgBytesPerSec = rate * (*default_waveformatex_ptr.0).nBlockAlign as DWORD; - if try!(is_format_supported(client, test_format.as_ptr())) { + if is_format_supported(client, test_format.as_ptr())? { supported_sample_rates.push(rate); } } diff --git a/src/host/wasapi/mod.rs b/src/host/wasapi/mod.rs index ecf7d7a..c7fc241 100644 --- a/src/host/wasapi/mod.rs +++ b/src/host/wasapi/mod.rs @@ -61,8 +61,9 @@ fn check_result_backend_specific(result: HRESULT) -> Result<(), BackendSpecificE match check_result(result) { Ok(()) => Ok(()), Err(err) => { - let description = format!("{}", err); - return Err(BackendSpecificError { description }); + Err(BackendSpecificError { + description: format!("{}", err), + }) } } } diff --git a/src/host/wasapi/stream.rs b/src/host/wasapi/stream.rs index decada6..72a863f 100644 --- a/src/host/wasapi/stream.rs +++ b/src/host/wasapi/stream.rs @@ -1,9 +1,6 @@ use super::check_result; -use super::com; use super::winapi::shared::basetsd::UINT32; -use super::winapi::shared::ksmedia; -use super::winapi::shared::minwindef::{BYTE, DWORD, FALSE, WORD}; -use super::winapi::shared::mmreg; +use super::winapi::shared::minwindef::{BYTE, FALSE, WORD}; use super::winapi::um::audioclient::{self, AUDCLNT_E_DEVICE_INVALIDATED, AUDCLNT_S_BUFFER_EMPTY}; use super::winapi::um::handleapi; use super::winapi::um::synchapi; @@ -13,17 +10,13 @@ use super::winapi::um::winnt; use std::mem; use std::ptr; use std::slice; -use std::sync::Mutex; use std::sync::mpsc::{channel, Sender, Receiver}; -use std::sync::atomic::AtomicUsize; use std::{sync::{Arc}, thread::{self, JoinHandle}}; use crate::traits::StreamTrait; use BackendSpecificError; -use BuildStreamError; -use Format; use PauseStreamError; use PlayStreamError; use SampleFormat; @@ -257,7 +250,7 @@ fn stream_error_from_hresult(hresult: winnt::HRESULT) -> Result<(), StreamError> Ok(()) } -fn run_inner(run_context: RunContext, data_callback: &mut dyn FnMut(StreamData), error_callback: &mut dyn FnMut(StreamError)) -> () { +fn run_inner(run_context: RunContext, data_callback: &mut dyn FnMut(StreamData), error_callback: &mut dyn FnMut(StreamError)) { unsafe { 'stream_loop: loop { // Process queued commands.