Skip to content

Commit

Permalink
Fix macos non-default audio output (#946)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlsteele authored Feb 16, 2025
1 parent 96ce1a7 commit 51c3b43
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/host/coreaudio/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,18 @@ impl Device {
let ranges: *mut AudioValueRange = ranges.as_mut_ptr() as *mut _;
let ranges: &'static [AudioValueRange] = slice::from_raw_parts(ranges, n_ranges);

let audio_unit = audio_unit_from_device(self, true)?;
#[allow(non_upper_case_globals)]
let input = match scope {
kAudioObjectPropertyScopeInput => Ok(true),
kAudioObjectPropertyScopeOutput => Ok(false),
_ => Err(BackendSpecificError {
description: format!(
"unexpected scope (neither input nor output): {:?}",
scope
),
}),
}?;
let audio_unit = audio_unit_from_device(self, input)?;
let buffer_size = get_io_buffer_frame_size_range(&audio_unit)?;

// Collect the supported formats for the device.
Expand Down Expand Up @@ -398,7 +409,18 @@ impl Device {
}
};

let audio_unit = audio_unit_from_device(self, true)?;
#[allow(non_upper_case_globals)]
let input = match scope {
kAudioObjectPropertyScopeInput => Ok(true),
kAudioObjectPropertyScopeOutput => Ok(false),
_ => Err(BackendSpecificError {
description: format!(
"unexpected scope (neither input nor output): {:?}",
scope
),
}),
}?;
let audio_unit = audio_unit_from_device(self, input)?;
let buffer_size = get_io_buffer_frame_size_range(&audio_unit)?;

let config = SupportedStreamConfig {
Expand Down

0 comments on commit 51c3b43

Please # to comment.