@@ -204,7 +204,7 @@ fn set_sample_rate(
204204}
205205
206206fn audio_unit_from_device ( device : & Device , input : bool ) -> Result < AudioUnit , coreaudio:: Error > {
207- let output_type = if is_default_device ( device ) && !input {
207+ let output_type = if !input && is_default_output_device ( device ) {
208208 coreaudio:: audio_unit:: IOType :: DefaultOutput
209209 } else {
210210 coreaudio:: audio_unit:: IOType :: HalOutput
@@ -342,13 +342,12 @@ pub struct Device {
342342 pub ( crate ) audio_device_id : AudioDeviceID ,
343343}
344344
345- pub fn is_default_device ( device : & Device ) -> bool {
346- default_input_device ( )
347- . map ( |d| d. audio_device_id == device. audio_device_id )
348- . unwrap_or ( false )
349- || default_output_device ( )
350- . map ( |d| d. audio_device_id == device. audio_device_id )
351- . unwrap_or ( false )
345+ fn is_default_input_device ( device : & Device ) -> bool {
346+ default_input_device ( ) . is_some_and ( |d| d. audio_device_id == device. audio_device_id )
347+ }
348+
349+ fn is_default_output_device ( device : & Device ) -> bool {
350+ default_output_device ( ) . is_some_and ( |d| d. audio_device_id == device. audio_device_id )
352351}
353352
354353impl Device {
@@ -811,7 +810,7 @@ impl Device {
811810 } ) ?;
812811
813812 // Create error callback for stream - either dummy or real based on device type
814- let error_callback_for_stream: super :: ErrorCallback = if is_default_device ( self ) {
813+ let error_callback_for_stream: super :: ErrorCallback = if is_default_input_device ( self ) {
815814 Box :: new ( |_: StreamError | { } )
816815 } else {
817816 let error_callback_clone = error_callback_disconnect. clone ( ) ;
@@ -914,7 +913,7 @@ impl Device {
914913 } ) ?;
915914
916915 // Create error callback for stream - either dummy or real based on device type
917- let error_callback_for_stream: super :: ErrorCallback = if is_default_device ( self ) {
916+ let error_callback_for_stream: super :: ErrorCallback = if is_default_output_device ( self ) {
918917 Box :: new ( |_: StreamError | { } )
919918 } else {
920919 let error_callback_clone = error_callback_disconnect. clone ( ) ;
0 commit comments