Skip to content

Commit 51c3b43

Browse files
authored
Fix macos non-default audio output (#946)
1 parent 96ce1a7 commit 51c3b43

File tree

1 file changed

+24
-2
lines changed
  • src/host/coreaudio/macos

1 file changed

+24
-2
lines changed

src/host/coreaudio/macos/mod.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,18 @@ impl Device {
296296
let ranges: *mut AudioValueRange = ranges.as_mut_ptr() as *mut _;
297297
let ranges: &'static [AudioValueRange] = slice::from_raw_parts(ranges, n_ranges);
298298

299-
let audio_unit = audio_unit_from_device(self, true)?;
299+
#[allow(non_upper_case_globals)]
300+
let input = match scope {
301+
kAudioObjectPropertyScopeInput => Ok(true),
302+
kAudioObjectPropertyScopeOutput => Ok(false),
303+
_ => Err(BackendSpecificError {
304+
description: format!(
305+
"unexpected scope (neither input nor output): {:?}",
306+
scope
307+
),
308+
}),
309+
}?;
310+
let audio_unit = audio_unit_from_device(self, input)?;
300311
let buffer_size = get_io_buffer_frame_size_range(&audio_unit)?;
301312

302313
// Collect the supported formats for the device.
@@ -398,7 +409,18 @@ impl Device {
398409
}
399410
};
400411

401-
let audio_unit = audio_unit_from_device(self, true)?;
412+
#[allow(non_upper_case_globals)]
413+
let input = match scope {
414+
kAudioObjectPropertyScopeInput => Ok(true),
415+
kAudioObjectPropertyScopeOutput => Ok(false),
416+
_ => Err(BackendSpecificError {
417+
description: format!(
418+
"unexpected scope (neither input nor output): {:?}",
419+
scope
420+
),
421+
}),
422+
}?;
423+
let audio_unit = audio_unit_from_device(self, input)?;
402424
let buffer_size = get_io_buffer_frame_size_range(&audio_unit)?;
403425

404426
let config = SupportedStreamConfig {

0 commit comments

Comments
 (0)